From 7973fd2aeddbdd9fc4595ef2d34fa57d1c3c75cb Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Mon, 6 Jun 2005 21:14:31 +0000 Subject: [PATCH] libiberty.h (XOBFINISH): New. libiberty/ 2005-06-06 Gabriel Dos Reis * libiberty.h (XOBFINISH): New. gcc/ 2005-06-06 Gabriel Dos Reis * c-lex.c (lex_string): Use XOBFINISH. * collect2.c (extract_string, dump_file): Likewise. * dbxout.c (dbxout_finish_complex_stabs): Likewise. * gcc.c (init_spec, build_search_list, convert_filename, set_collect_gcc_options, do_spec_2, do_spec_1, main): * Likewise. * genpreds.c (write_predicate_subfunction): Likewise. * genflags.c (main): Likewise. * read-rtl.c (mode_attr_index, apply_macro_to_string, join_c_conditions, read_quoted_string, read_braced_string, read_rtx_1): Likewise. * stringpool.c (ggc_alloc_string): Likewise. * tlink.c (obstack_fgets, recompile_files): Likewise. From-SVN: r100678 --- gcc/ChangeLog | 15 +++++++++++++++ gcc/c-lex.c | 2 +- gcc/collect2.c | 4 ++-- gcc/dbxout.c | 4 ++-- gcc/gcc.c | 42 +++++++++++++++++++++--------------------- gcc/genflags.c | 2 +- gcc/genpreds.c | 2 +- gcc/read-rtl.c | 12 ++++++------ gcc/stringpool.c | 2 +- gcc/tlink.c | 4 ++-- gcc/tree-sra.c | 2 +- include/ChangeLog | 4 ++++ include/libiberty.h | 2 +- 13 files changed, 58 insertions(+), 39 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a087a3d3616..7d5f07c39e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2005-06-06 Gabriel Dos Reis + + * c-lex.c (lex_string): Use XOBFINISH. + * collect2.c (extract_string, dump_file): Likewise. + * dbxout.c (dbxout_finish_complex_stabs): Likewise. + * gcc.c (init_spec, build_search_list, convert_filename, + set_collect_gcc_options, do_spec_2, do_spec_1, main): Likewise. + * genpreds.c (write_predicate_subfunction): Likewise. + * genflags.c (main): Likewise. + * read-rtl.c (mode_attr_index, apply_macro_to_string, + join_c_conditions, read_quoted_string, read_braced_string, + read_rtx_1): Likewise. + * stringpool.c (ggc_alloc_string): Likewise. + * tlink.c (obstack_fgets, recompile_files): Likewise. + 2005-06-06 Jakub Jelinek * intl.h (G_): New macro. diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 052c3f69122..3282dd12f66 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -762,7 +762,7 @@ lex_string (const cpp_token *tok, tree *valp, bool objc_string) /* We have read one more token than we want. */ _cpp_backup_tokens (parse_in, 1); if (concats) - strs = (cpp_string *) obstack_finish (&str_ob); + strs = XOBFINISH (&str_ob, cpp_string *); if (concats && !objc_string && !in_system_header) warning (OPT_Wtraditional, diff --git a/gcc/collect2.c b/gcc/collect2.c index f89a925124c..98416efb3f2 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -453,7 +453,7 @@ extract_string (const char **pp) obstack_1grow (&temporary_obstack, '\0'); *pp = p; - return obstack_finish (&temporary_obstack); + return XOBFINISH (&temporary_obstack, char *); } void @@ -474,7 +474,7 @@ dump_file (const char *name, FILE *to) const char *word, *p; char *result; obstack_1grow (&temporary_obstack, '\0'); - word = obstack_finish (&temporary_obstack); + word = XOBFINISH (&temporary_obstack, const char *); if (*word == '.') ++word, putc ('.', to); diff --git a/gcc/dbxout.c b/gcc/dbxout.c index a4a036bb51f..be03d8129bc 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -856,7 +856,7 @@ dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code, obstack_1grow (&stabstr_ob, '\0'); len = obstack_object_size (&stabstr_ob); - chunk = str = obstack_finish (&stabstr_ob); + chunk = str = XOBFINISH (&stabstr_ob, char *); /* Within the buffer are a sequence of NUL-separated strings, each of which is to be written out as a separate stab @@ -889,7 +889,7 @@ dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code, comma than to do a two-character fputs. */ obstack_grow (&stabstr_ob, "\",", 2); len = obstack_object_size (&stabstr_ob); - str = obstack_finish (&stabstr_ob); + str = XOBFINISH (&stabstr_ob, char *); fwrite (str, 1, len, asm_out_file); DBX_FINISH_STABS (sym, code, line, addr, label, number); diff --git a/gcc/gcc.c b/gcc/gcc.c index 9be4a293371..076d224bebd 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1736,7 +1736,7 @@ init_spec (void) } obstack_1grow (&obstack, '\0'); - libgcc_spec = obstack_finish (&obstack); + libgcc_spec = XOBFINISH (&obstack, const char *); } #endif #ifdef USE_AS_TRADITIONAL_FORMAT @@ -1745,14 +1745,14 @@ init_spec (void) static const char tf[] = "--traditional-format "; obstack_grow (&obstack, tf, sizeof(tf) - 1); obstack_grow0 (&obstack, asm_spec, strlen (asm_spec)); - asm_spec = obstack_finish (&obstack); + asm_spec = XOBFINISH (&obstack, const char *); } #endif #ifdef LINK_EH_SPEC /* Prepend LINK_EH_SPEC to whatever link_spec we had before. */ obstack_grow (&obstack, LINK_EH_SPEC, sizeof(LINK_EH_SPEC) - 1); obstack_grow0 (&obstack, link_spec, strlen (link_spec)); - link_spec = obstack_finish (&obstack); + link_spec = XOBFINISH (&obstack, const char *); #endif specs = sl; @@ -2393,7 +2393,7 @@ build_search_list (struct path_prefix *paths, const char *prefix, } obstack_1grow (&collect_obstack, '\0'); - return obstack_finish (&collect_obstack); + return XOBFINISH (&collect_obstack, char *); } /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables @@ -2980,7 +2980,7 @@ convert_filename (const char *name, int do_exe ATTRIBUTE_UNUSED, { obstack_grow (&obstack, name, len - 2); obstack_grow0 (&obstack, TARGET_OBJECT_SUFFIX, strlen (TARGET_OBJECT_SUFFIX)); - name = obstack_finish (&obstack); + name = XOBFINISH (&obstack, const char *); } #endif @@ -3001,7 +3001,7 @@ convert_filename (const char *name, int do_exe ATTRIBUTE_UNUSED, obstack_grow (&obstack, name, len); obstack_grow0 (&obstack, TARGET_EXECUTABLE_SUFFIX, strlen (TARGET_EXECUTABLE_SUFFIX)); - name = obstack_finish (&obstack); + name = XOBFINISH (&obstack, const char *); #endif return name; @@ -4154,7 +4154,7 @@ set_collect_gcc_options (void) } } obstack_grow (&collect_obstack, "\0", 1); - putenv (obstack_finish (&collect_obstack)); + putenv (XOBFINISH (&collect_obstack, char *)); } /* Process a spec string, accumulating and running commands. */ @@ -4253,7 +4253,7 @@ do_spec_2 (const char *spec) if (arg_going) { obstack_1grow (&obstack, 0); - string = obstack_finish (&obstack); + string = XOBFINISH (&obstack, const char *); if (this_is_library_file) string = find_file (string); store_arg (string, delete_this_arg, this_is_output_file); @@ -4488,7 +4488,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) if (arg_going) { obstack_1grow (&obstack, 0); - string = obstack_finish (&obstack); + string = XOBFINISH (&obstack, const char *); if (this_is_library_file) string = find_file (string); store_arg (string, delete_this_arg, this_is_output_file); @@ -4533,7 +4533,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) if (arg_going) { obstack_1grow (&obstack, 0); - string = obstack_finish (&obstack); + string = XOBFINISH (&obstack, const char *); if (this_is_library_file) string = find_file (string); store_arg (string, delete_this_arg, this_is_output_file); @@ -4552,7 +4552,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) if (arg_going) { obstack_1grow (&obstack, 0); - string = obstack_finish (&obstack); + string = XOBFINISH (&obstack, const char *); if (this_is_library_file) string = find_file (string); store_arg (string, delete_this_arg, this_is_output_file); @@ -4914,7 +4914,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) if (arg_going) { obstack_1grow (&obstack, 0); - string = obstack_finish (&obstack); + string = XOBFINISH (&obstack, const char *); if (this_is_library_file) string = find_file (string); store_arg (string, delete_this_arg, this_is_output_file); @@ -5243,7 +5243,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) if (processing_spec_function && arg_going) { obstack_1grow (&obstack, 0); - string = obstack_finish (&obstack); + string = XOBFINISH (&obstack, const char *); if (this_is_library_file) string = find_file (string); store_arg (string, delete_this_arg, this_is_output_file); @@ -6037,21 +6037,21 @@ main (int argc, const char **argv) obstack_grow (&multilib_obstack, p, strlen (p)); obstack_1grow (&multilib_obstack, 0); - multilib_select = obstack_finish (&multilib_obstack); + multilib_select = XOBFINISH (&multilib_obstack, const char *); q = multilib_matches_raw; while ((p = *q++) != (char *) 0) obstack_grow (&multilib_obstack, p, strlen (p)); obstack_1grow (&multilib_obstack, 0); - multilib_matches = obstack_finish (&multilib_obstack); + multilib_matches = XOBFINISH (&multilib_obstack, const char *); q = multilib_exclusions_raw; while ((p = *q++) != (char *) 0) obstack_grow (&multilib_obstack, p, strlen (p)); obstack_1grow (&multilib_obstack, 0); - multilib_exclusions = obstack_finish (&multilib_obstack); + multilib_exclusions = XOBFINISH (&multilib_obstack, const char *); need_space = FALSE; for (i = 0; i < ARRAY_SIZE (multilib_defaults_raw); i++) @@ -6065,7 +6065,7 @@ main (int argc, const char **argv) } obstack_1grow (&multilib_obstack, 0); - multilib_defaults = obstack_finish (&multilib_obstack); + multilib_defaults = XOBFINISH (&multilib_obstack, const char *); } /* Set up to remember the pathname of gcc and any options @@ -6074,7 +6074,7 @@ main (int argc, const char **argv) obstack_init (&collect_obstack); obstack_grow (&collect_obstack, "COLLECT_GCC=", sizeof ("COLLECT_GCC=") - 1); obstack_grow (&collect_obstack, argv[0], strlen (argv[0]) + 1); - putenv (obstack_finish (&collect_obstack)); + putenv (XOBFINISH (&collect_obstack, char *)); #ifdef INIT_ENVIRONMENT /* Set up any other necessary machine specific environment variables. */ @@ -6160,7 +6160,7 @@ main (int argc, const char **argv) { obstack_grow (&obstack, "%(sysroot_spec) ", strlen ("%(sysroot_spec) ")); obstack_grow0 (&obstack, link_spec, strlen (link_spec)); - set_spec ("link", obstack_finish (&obstack)); + set_spec ("link", XOBFINISH (&obstack, const char *)); } #endif @@ -6349,7 +6349,7 @@ main (int argc, const char **argv) obstack_init (&obstack); do_spec_1 (THREAD_MODEL_SPEC, 0, thread_model); obstack_1grow (&obstack, '\0'); - thrmod = obstack_finish (&obstack); + thrmod = XOBFINISH (&obstack, const char *); #else thrmod = thread_model; #endif @@ -7077,7 +7077,7 @@ set_multilib_dir (void) obstack_grow (&multilib_obstack, start, end - start); obstack_1grow (&multilib_obstack, 0); - mdswitches[i].str = obstack_finish (&multilib_obstack); + mdswitches[i].str = XOBFINISH (&multilib_obstack, const char *); mdswitches[i++].len = end - start; if (*end == '\0') diff --git a/gcc/genflags.c b/gcc/genflags.c index a52e18a9def..0710b4a4667 100644 --- a/gcc/genflags.c +++ b/gcc/genflags.c @@ -267,7 +267,7 @@ main (int argc, char **argv) /* Print out the prototypes now. */ dummy = (rtx) 0; obstack_grow (&obstack, &dummy, sizeof (rtx)); - insns = (rtx *) obstack_finish (&obstack); + insns = XOBFINISH (&obstack, rtx *); for (insn_ptr = insns; *insn_ptr; insn_ptr++) gen_proto (*insn_ptr); diff --git a/gcc/genpreds.c b/gcc/genpreds.c index b07abedc5b0..e03e609ae98 100644 --- a/gcc/genpreds.c +++ b/gcc/genpreds.c @@ -122,7 +122,7 @@ write_predicate_subfunction (struct pred_data *p) obstack_grow (rtl_obstack, p->name, strlen (p->name)); obstack_grow (rtl_obstack, "_1 (op, mode)", sizeof "_1 (op, mode)"); - match_test_str = obstack_finish (rtl_obstack); + match_test_str = XOBFINISH (rtl_obstack, const char *); /* Add the function-call expression to the complete expression to be evaluated. */ diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 1b1a329d2ff..efd1dd44e8f 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -321,7 +321,7 @@ mode_attr_index (struct map_value **mode_maps, const char *string) /* Copy the attribute string into permanent storage, without the angle brackets around it. */ obstack_grow0 (&string_obstack, string + 1, strlen (string) - 2); - p = (char *) obstack_finish (&string_obstack); + p = XOBFINISH (&string_obstack, char *); mv = XNEW (struct map_value); mv->number = *mode_maps == 0 ? 0 : (*mode_maps)->number + 1; @@ -404,7 +404,7 @@ apply_macro_to_string (const char *string, struct mapping *macro, int value) if (base != copy) { obstack_grow (&string_obstack, base, strlen (base) + 1); - copy = obstack_finish (&string_obstack); + copy = XOBFINISH (&string_obstack, char *); copy_rtx_ptr_loc (copy, string); return copy; } @@ -785,7 +785,7 @@ join_c_conditions (const char *cond1, const char *cond2) obstack_ptr_grow (&joined_conditions_obstack, result); obstack_ptr_grow (&joined_conditions_obstack, cond1); obstack_ptr_grow (&joined_conditions_obstack, cond2); - entry = obstack_finish (&joined_conditions_obstack); + entry = XOBFINISH (&joined_conditions_obstack, const void **); *htab_find_slot (joined_conditions, entry, INSERT) = entry; return result; } @@ -998,7 +998,7 @@ read_quoted_string (FILE *infile) } obstack_1grow (&string_obstack, 0); - return (char *) obstack_finish (&string_obstack); + return XOBFINISH (&string_obstack, char *); } /* Read a braced string (a la Tcl) onto the string obstack. Caller @@ -1036,7 +1036,7 @@ read_braced_string (FILE *infile) } obstack_1grow (&string_obstack, 0); - return (char *) obstack_finish (&string_obstack); + return XOBFINISH (&string_obstack, char *); } /* Read some kind of string constant. This is the high-level routine @@ -1581,7 +1581,7 @@ read_rtx_1 (FILE *infile, struct map_value **mode_maps) obstack_grow (&string_obstack, fn, strlen (fn)); sprintf (line_name, ":%d", read_rtx_lineno); obstack_grow (&string_obstack, line_name, strlen (line_name)+1); - stringbuf = (char *) obstack_finish (&string_obstack); + stringbuf = XOBFINISH (&string_obstack, char *); } if (star_if_braced) diff --git a/gcc/stringpool.c b/gcc/stringpool.c index ec744715993..f75fb935519 100644 --- a/gcc/stringpool.c +++ b/gcc/stringpool.c @@ -95,7 +95,7 @@ ggc_alloc_string (const char *contents, int length) return digit_string (contents[0] - '0'); obstack_grow0 (&string_stack, contents, length); - return obstack_finish (&string_stack); + return XOBFINISH (&string_stack, const char *); } /* Return an IDENTIFIER_NODE whose name is TEXT (a null-terminated string). diff --git a/gcc/tlink.c b/gcc/tlink.c index 44e516ba0e8..e8fe756b762 100644 --- a/gcc/tlink.c +++ b/gcc/tlink.c @@ -311,7 +311,7 @@ obstack_fgets (FILE *stream, struct obstack *ob) if (obstack_object_size (ob) == 0) return NULL; obstack_1grow (ob, '\0'); - return obstack_finish (ob); + return XOBFINISH (ob, char *); } static char * @@ -528,7 +528,7 @@ recompile_files (void) done: obstack_ptr_grow (&temporary_obstack, f->main); obstack_ptr_grow (&temporary_obstack, NULL); - argv = obstack_finish (&temporary_obstack); + argv = XOBFINISH (&temporary_obstack, char **); if (tlink_verbose) fprintf (stderr, _("collect: recompiling %s\n"), f->main); diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 973f84c12eb..7abdd3de34e 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -1094,7 +1094,7 @@ build_element_name (struct sra_elt *elt) { build_element_name_1 (elt); obstack_1grow (&sra_obstack, '\0'); - return obstack_finish (&sra_obstack); + return XOBFINISH (&sra_obstack, char *); } /* Instantiate an element as an independent variable. */ diff --git a/include/ChangeLog b/include/ChangeLog index 3122162f20a..abe0b1b1dd5 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2005-06-06 Gabriel Dos Reis + + * libiberty.h (XOBFINISH): New. + 2005-06-01 Kaveh R. Ghazi * libiberty.h (vsnprintf): Add format attribute. diff --git a/include/libiberty.h b/include/libiberty.h index a9a75eaa8ec..4b0d532db78 100644 --- a/include/libiberty.h +++ b/include/libiberty.h @@ -326,7 +326,7 @@ extern double physmem_available (void); /* Type-safe obstack allocator. */ #define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T))) - +#define XOBFINISH(O, T) ((T) obstack_finish ((O))) /* hex character manipulation routines */