From: Basile Starynkevitch <basile@starynkevitch.net>
To: gcc-patches@gcc.gnu.org
Subject: PATCH [trunk] gengtype should generate ggc_alloc macros in plugin mode.
Date: Mon, 04 Apr 2011 19:54:00 -0000 [thread overview]
Message-ID: <20110404215335.032d7b9c.basile@starynkevitch.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 890 bytes --]
Hello All,
When gengtype is used in plugin mode, it should also generate various
#define ggc_alloc_* macro definitions. It seems that the 4.6.0 gengtype
don't do that (and that is a bug).
The attached patch, to trunk rev171950, fixes this issue.
############# gcc/ChangeLog entry
2011-04-04 Basile Starynkevitch <basile@starynkevitch.net>
* gengtype.c (write_typed_alloc_def): Gets extra outf_p argument
and use it.
(write_typed_struct_alloc_def, write_typed_typedef_alloc_def)
(write_typed_alloc_defns): Likewise.
(main): Calls write_typed_alloc_defns with output_header.
#############
Ok for trunk? Comments are welcome!
Cheers.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
[-- Attachment #2: gengtype-alloc-r171950.diff --]
[-- Type: text/x-diff, Size: 6440 bytes --]
Index: gcc/gengtype.c
===================================================================
--- gcc/gengtype.c (revision 171950)
+++ gcc/gengtype.c (working copy)
@@ -4197,52 +4197,56 @@ enum alloc_zone
the allocator will be zone-specific. */
static void
-write_typed_alloc_def (bool variable_size, const char *type_specifier,
+write_typed_alloc_def (outf_p f,
+ bool variable_size, const char *type_specifier,
const char *type_name, const char *allocator_type,
enum alloc_quantity quantity, enum alloc_zone zone)
{
bool two_args = variable_size && (quantity == vector);
bool third_arg = ((zone == specific_zone)
&& (variable_size || (quantity == vector)));
-
- oprintf (header_file, "#define ggc_alloc_%s%s", allocator_type, type_name);
- oprintf (header_file, "(%s%s%s%s%s) ",
+ if (!f)
+ return;
+ oprintf (f, "#define ggc_alloc_%s%s", allocator_type, type_name);
+ oprintf (f, "(%s%s%s%s%s) ",
(variable_size ? "SIZE" : ""),
(two_args ? ", " : ""),
(quantity == vector) ? "n" : "",
(third_arg ? ", " : ""), (zone == specific_zone) ? "z" : "");
- oprintf (header_file, "((%s%s *)", type_specifier, type_name);
- oprintf (header_file, "(ggc_internal_%salloc_stat (", allocator_type);
+ oprintf (f, "((%s%s *)", type_specifier, type_name);
+ oprintf (f, "(ggc_internal_%salloc_stat (", allocator_type);
if (zone == specific_zone)
- oprintf (header_file, "z, ");
+ oprintf (f, "z, ");
if (variable_size)
- oprintf (header_file, "SIZE");
+ oprintf (f, "SIZE");
else
- oprintf (header_file, "sizeof (%s%s)", type_specifier, type_name);
+ oprintf (f, "sizeof (%s%s)", type_specifier, type_name);
if (quantity == vector)
- oprintf (header_file, ", n");
- oprintf (header_file, " MEM_STAT_INFO)))\n");
+ oprintf (f, ", n");
+ oprintf (f, " MEM_STAT_INFO)))\n");
}
/* Writes a typed allocator definition for a struct or union S. */
static void
-write_typed_struct_alloc_def (const type_p s, const char *allocator_type,
+write_typed_struct_alloc_def (outf_p f,
+ const type_p s, const char *allocator_type,
enum alloc_quantity quantity,
enum alloc_zone zone)
{
- write_typed_alloc_def (variable_size_p (s), get_type_specifier (s),
+ write_typed_alloc_def (f, variable_size_p (s), get_type_specifier (s),
s->u.s.tag, allocator_type, quantity, zone);
}
/* Writes a typed allocator definition for a typedef P. */
static void
-write_typed_typedef_alloc_def (const pair_p p, const char *allocator_type,
+write_typed_typedef_alloc_def (outf_p f,
+ const pair_p p, const char *allocator_type,
enum alloc_quantity quantity,
enum alloc_zone zone)
{
- write_typed_alloc_def (variable_size_p (p->type), "", p->name,
+ write_typed_alloc_def (f, variable_size_p (p->type), "", p->name,
allocator_type, quantity, zone);
}
@@ -4250,43 +4254,46 @@ static void
TYPEDEFS that are used by GC. */
static void
-write_typed_alloc_defns (const type_p structures, const pair_p typedefs)
+write_typed_alloc_defns (outf_p f,
+ const type_p structures, const pair_p typedefs)
{
type_p s;
pair_p p;
- oprintf (header_file,
+ if (!f)
+ return;
+ oprintf (f,
"\n/* Allocators for known structs and unions. */\n\n");
for (s = structures; s; s = s->next)
{
if (!USED_BY_TYPED_GC_P (s))
continue;
- write_typed_struct_alloc_def (s, "", single, any_zone);
- write_typed_struct_alloc_def (s, "cleared_", single, any_zone);
- write_typed_struct_alloc_def (s, "vec_", vector, any_zone);
- write_typed_struct_alloc_def (s, "cleared_vec_", vector, any_zone);
- write_typed_struct_alloc_def (s, "zone_", single, specific_zone);
- write_typed_struct_alloc_def (s, "zone_cleared_", single,
+ write_typed_struct_alloc_def (f, s, "", single, any_zone);
+ write_typed_struct_alloc_def (f, s, "cleared_", single, any_zone);
+ write_typed_struct_alloc_def (f, s, "vec_", vector, any_zone);
+ write_typed_struct_alloc_def (f, s, "cleared_vec_", vector, any_zone);
+ write_typed_struct_alloc_def (f, s, "zone_", single, specific_zone);
+ write_typed_struct_alloc_def (f, s, "zone_cleared_", single,
specific_zone);
- write_typed_struct_alloc_def (s, "zone_vec_", vector, specific_zone);
- write_typed_struct_alloc_def (s, "zone_cleared_vec_", vector,
+ write_typed_struct_alloc_def (f, s, "zone_vec_", vector, specific_zone);
+ write_typed_struct_alloc_def (f, s, "zone_cleared_vec_", vector,
specific_zone);
}
- oprintf (header_file, "\n/* Allocators for known typedefs. */\n");
+ oprintf (f, "\n/* Allocators for known typedefs. */\n");
for (p = typedefs; p; p = p->next)
{
s = p->type;
if (!USED_BY_TYPED_GC_P (s) || (strcmp (p->name, s->u.s.tag) == 0))
continue;
- write_typed_typedef_alloc_def (p, "", single, any_zone);
- write_typed_typedef_alloc_def (p, "cleared_", single, any_zone);
- write_typed_typedef_alloc_def (p, "vec_", vector, any_zone);
- write_typed_typedef_alloc_def (p, "cleared_vec_", vector, any_zone);
- write_typed_typedef_alloc_def (p, "zone_", single, specific_zone);
- write_typed_typedef_alloc_def (p, "zone_cleared_", single,
+ write_typed_typedef_alloc_def (f, p, "", single, any_zone);
+ write_typed_typedef_alloc_def (f, p, "cleared_", single, any_zone);
+ write_typed_typedef_alloc_def (f, p, "vec_", vector, any_zone);
+ write_typed_typedef_alloc_def (f, p, "cleared_vec_", vector, any_zone);
+ write_typed_typedef_alloc_def (f, p, "zone_", single, specific_zone);
+ write_typed_typedef_alloc_def (f, p, "zone_cleared_", single,
specific_zone);
- write_typed_typedef_alloc_def (p, "zone_cleared_vec_", vector,
+ write_typed_typedef_alloc_def (f, p, "zone_cleared_vec_", vector,
specific_zone);
}
}
@@ -4990,8 +4997,8 @@ main (int argc, char **argv)
open_base_files ();
write_enum_defn (structures, param_structs);
- write_typed_alloc_defns (structures, typedefs);
output_header = plugin_output ? plugin_output : header_file;
+ write_typed_alloc_defns (output_header, structures, typedefs);
DBGPRINT_COUNT_TYPE ("structures before write_types outputheader",
structures);
DBGPRINT_COUNT_TYPE ("param_structs before write_types outputheader",
next reply other threads:[~2011-04-04 19:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-04 19:54 Basile Starynkevitch [this message]
2011-04-07 2:46 ` Laurynas Biveinis
2011-04-08 5:46 ` Basile Starynkevitch
2011-04-08 6:22 ` Duncan Sands
2011-04-08 12:30 ` Laurynas Biveinis
2011-04-08 17:57 ` Basile Starynkevitch
2011-04-10 18:47 ` Laurynas Biveinis
2011-04-10 18:51 ` Basile Starynkevitch
2011-04-11 1:37 ` PATCH [trunk] gengtype should generate ggc_alloc macros in plugin mode on for plugin files Basile Starynkevitch
2011-04-15 4:24 ` Laurynas Biveinis
2011-04-15 7:26 ` Basile Starynkevitch
2011-04-19 7:13 ` Laurynas Biveinis
2011-04-19 10:12 ` Basile Starynkevitch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110404215335.032d7b9c.basile@starynkevitch.net \
--to=basile@starynkevitch.net \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).