fprintf: Support packed enums
Check if the size is different than sizeof(int), which should be good enough for now for both 64-bit and 32-bit targets. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
f77a442f09
commit
28a3bc7add
|
@ -355,8 +355,19 @@ size_t enumeration__fprintf(const struct tag *tag, const struct cu *cu,
|
||||||
printed += fprintf(fp, "%.*s\t%s = %u,\n", indent, tabs,
|
printed += fprintf(fp, "%.*s\t%s = %u,\n", indent, tabs,
|
||||||
enumerator__name(pos, cu), pos->value);
|
enumerator__name(pos, cu), pos->value);
|
||||||
|
|
||||||
return printed + fprintf(fp, "%.*s}%s%s", indent, tabs,
|
printed += fprintf(fp, "%.*s}", indent, tabs);
|
||||||
conf->suffix ? " " : "", conf->suffix ?: "");
|
|
||||||
|
/*
|
||||||
|
* XXX: find out how to precisely determine the max size for an
|
||||||
|
* enumeration, use sizeof(int) for now.
|
||||||
|
*/
|
||||||
|
if (type->size / 8 != sizeof(int))
|
||||||
|
printed += fprintf(fp, " __attribute__((__packed__))", conf->suffix);
|
||||||
|
|
||||||
|
if (conf->suffix)
|
||||||
|
printed += fprintf(fp, " %s", conf->suffix);
|
||||||
|
|
||||||
|
return printed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *tag__prefix(const struct cu *cu, const uint32_t tag,
|
static const char *tag__prefix(const struct cu *cu, const uint32_t tag,
|
||||||
|
|
Loading…
Reference in New Issue