This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ping patch] enhancing gengtype for plugins?
2009/6/12 Basile STARYNKEVITCH <basile@starynkevitch.net>:
> gcc/ChangeLog:
> 2009-06-12 Â Basile Starynkevitch Â<basile@starynkevitch.net>
> Â* doc/plugins.texi (Interacting with the GCC Garbage Collector): Mention the plugin mode
> Âof gengtype.
> Â* doc/gty.texi (Source Files Containing Type Information): Likewise.
> Â* gengtype.c: Updated copyright.
>
> Â (plugin_files, nb_plugin_files) Added new static variables.
> Â (measure_input_list) Care about plugin_files.
> Â (write_rtx_next): Added early return in plugin mode.
> Â (create_file): Updated copyright year in generated file. Added asserts.
> Â (oprintf): Added early return if null outf.
> Â (get_output_file_with_visibility): Care of plugin_files.
> Â (get_output_file_name): May return null.
> Â (close_output_files) Emit a verbose message in plugin mode.
> Â (write_local): Added early return.
> Â (put_mangled_filename): Ditto.
> Â (finish_root_table): Added check for base_files.
> Â (write_roots): Care about null when plugins.
> Â (main): added plugin mode.
>
> Index: gcc/doc/gty.texi
> ===================================================================
> --- gcc/doc/gty.texi (revision 148436)
> +++ gcc/doc/gty.texi (working copy)
> @@ -450,6 +450,13 @@ For language frontends, there is another file that
> somewhere. It will be called @file{gtype-@var{lang}.h}, where
> @var{lang} is the name of the subdirectory the language is contained in.
>
> +Plugins can add additional root tables. Run the @code{gengtype}
> +utility in plugin mode as @code{gengtype -p @var{source-dir}
> +@var{file-list} @var{plugin*.c}} with your plugin files
> +@var{plugin*.c} using @code{GTY} to generate the corresponding
> +@var{gt-plugin*.h} files.
> +
> +
Add a note stating that for this to work, a build tree for the
GCC version to be used with the plugin must be present.
> @@ -128,18 +128,24 @@ typedef struct outf * outf_p;
>
> /* An output file, suitable for definitions, that can see declarations
> made in INPUT_FILE and is linked into every language that uses
> - INPUT_FILE. */
> + INPUT_FILE. May return null in plugin mode. */
s/null/NULL/
> -/* Print, like fprintf, to O. */
> +/* Print, like fprintf, to O. No-op if O is nil. */
s/nil/NULL/
> @@ -455,6 +461,12 @@ read_input_list (const char *listname)
> /* Update the global counts now that we know accurately how many
> things there are. (We do not bother resizing the arrays down.) */
> num_lang_dirs = langno;
> + /* add the plugin files if provided */
Comments should start capitalized and end in '. */'
> + if (plugin_files) {
Open brace below the if().
> + int i=0;
No need to initialize I twice.
> + for (i=0; i<nb_plugin_files; i++)
Spaces around '=' and '<'.
> @@ -1495,6 +1511,11 @@ oprintf (outf_p o, const char *format, ...)
> size_t slength;
> va_list ap;
>
> + /* in plugin mode, the O could be a null pointer, so avoid crashing
> + in that case */
Capitalize start of comment. End it in '. */'
> + /* in plugin mode, return null unless the input_file is one of the
> + plugin_files */
> + if (plugin_files && nb_plugin_files > 0)
> + {
> + int ix= -1, i;
> + for (i= 0; i<nb_plugin_files && ix<0; i++)
Space around '=' and '<'.
> + if (!strcmp(input_file, plugin_files[i]))
Do strcmp() comparisons with '== 0'.
> + ix=i;
> + if (ix<0)
Space around '=' and '<'. There are other instances of this,
please fix them to follow the GNU coding conventions. In other
instances, there are too many spaces around the operators.
> @@ -1737,6 +1773,7 @@ get_output_file_with_visibility (const char *input
> /* If not, create it. */
> r = create_file (for_name, output_name);
>
> + gcc_assert(r && r->name);
Likewise.
> @@ -1787,6 +1827,9 @@ close_output_files (void)
> fatal ("opening output file %s: %s", of->name, strerror (errno));
> if (fwrite (of->buf, 1, of->bufused, newfile) != of->bufused)
> fatal ("writing output file %s: %s", of->name, strerror (errno));
> + if (plugin_files && nb_plugin_files > 0)
> + fprintf (stderr, "gengtype wrote output file %s for plugins\n",
> + of->name);
No output unless there is a warning or error to show.
> + "\t| gengtype -p srcdir input-list plugin... #for plugins");
Change to
"\t gengtype [-p] srcdir input-list [file1 file2 ... fileN]");
to highlight the optional arguments.
OK with those changes.
Diego.