aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2011-01-18 10:28:06 -0500
committerMichal Marek <mmarek@suse.cz>2011-03-17 10:13:55 -0400
commit7ec8eda154cbdcabb5305d90fb0952973dcaa560 (patch)
tree54cd5d99acda48bac597e158614e97423b59e797 /scripts
parent95f1d639ade8fdf9572ac8a926f62b29dd66eaba (diff)
genksyms: Simplify printing of symbol types
Instead of special-casing SYM_NORMAL, do not map any name to it. Also explicitly set the single-letter name of the symbol type, which will be needed by a further patch. The only user-visible change is one debug printf. Signed-off-by: Michal Marek <mmarek@suse.cz> Acked-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/genksyms/genksyms.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index f99115ebe925..2a1a3b84beba 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -53,8 +53,15 @@ static int nsyms;
53static struct symbol *expansion_trail; 53static struct symbol *expansion_trail;
54static struct symbol *visited_symbols; 54static struct symbol *visited_symbols;
55 55
56static const char *const symbol_type_name[] = { 56static const struct {
57 "normal", "typedef", "enum", "struct", "union" 57 int n;
58 const char *name;
59} symbol_types[] = {
60 [SYM_NORMAL] = { 0, NULL},
61 [SYM_TYPEDEF] = {'t', "typedef"},
62 [SYM_ENUM] = {'e', "enum"},
63 [SYM_STRUCT] = {'s', "struct"},
64 [SYM_UNION] = {'u', "union"},
58}; 65};
59 66
60static int equal_list(struct string_list *a, struct string_list *b); 67static int equal_list(struct string_list *a, struct string_list *b);
@@ -247,8 +254,12 @@ static struct symbol *__add_symbol(const char *name, enum symbol_type type,
247 sym->is_override = 0; 254 sym->is_override = 0;
248 255
249 if (flag_debug) { 256 if (flag_debug) {
250 fprintf(debugfile, "Defn for %s %s == <", 257 if (symbol_types[type].name)
251 symbol_type_name[type], name); 258 fprintf(debugfile, "Defn for %s %s == <",
259 symbol_types[type].name, name);
260 else
261 fprintf(debugfile, "Defn for type%d %s == <",
262 type, name);
252 if (is_extern) 263 if (is_extern)
253 fputs("extern ", debugfile); 264 fputs("extern ", debugfile);
254 print_list(debugfile, defn); 265 print_list(debugfile, defn);
@@ -346,8 +357,8 @@ static struct string_list *read_node(FILE *f)
346 if (node.string[1] == '#') { 357 if (node.string[1] == '#') {
347 int n; 358 int n;
348 359
349 for (n = 0; n < ARRAY_SIZE(symbol_type_name); n++) { 360 for (n = 0; n < ARRAY_SIZE(symbol_types); n++) {
350 if (node.string[0] == symbol_type_name[n][0]) { 361 if (node.string[0] == symbol_types[n].n) {
351 node.tag = n; 362 node.tag = n;
352 node.string += 2; 363 node.string += 2;
353 return copy_node(&node); 364 return copy_node(&node);
@@ -397,8 +408,8 @@ static void read_reference(FILE *f)
397 408
398static void print_node(FILE * f, struct string_list *list) 409static void print_node(FILE * f, struct string_list *list)
399{ 410{
400 if (list->tag != SYM_NORMAL) { 411 if (symbol_types[list->tag].n) {
401 putc(symbol_type_name[list->tag][0], f); 412 putc(symbol_types[list->tag].n, f);
402 putc('#', f); 413 putc('#', f);
403 } 414 }
404 fputs(list->string, f); 415 fputs(list->string, f);
@@ -491,11 +502,11 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
491 struct string_list *n, *t = NULL; 502 struct string_list *n, *t = NULL;
492 503
493 error_with_pos("expand undefined %s %s", 504 error_with_pos("expand undefined %s %s",
494 symbol_type_name[cur->tag], 505 symbol_types[cur->tag].name,
495 cur->string); 506 cur->string);
496 507
497 n = xmalloc(sizeof(*n)); 508 n = xmalloc(sizeof(*n));
498 n->string = xstrdup(symbol_type_name[cur->tag]); 509 n->string = xstrdup(symbol_types[cur->tag].name);
499 n->tag = SYM_NORMAL; 510 n->tag = SYM_NORMAL;
500 n->next = t; 511 n->next = t;
501 t = n; 512 t = n;
@@ -530,11 +541,11 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
530 if (subsym->expansion_trail) { 541 if (subsym->expansion_trail) {
531 if (flag_dump_defs) { 542 if (flag_dump_defs) {
532 fprintf(debugfile, "%s %s ", 543 fprintf(debugfile, "%s %s ",
533 symbol_type_name[cur->tag], 544 symbol_types[cur->tag].name,
534 cur->string); 545 cur->string);
535 } 546 }
536 547
537 crc = partial_crc32(symbol_type_name[cur->tag], 548 crc = partial_crc32(symbol_types[cur->tag].name,
538 crc); 549 crc);
539 crc = partial_crc32_one(' ', crc); 550 crc = partial_crc32_one(' ', crc);
540 crc = partial_crc32(cur->string, crc); 551 crc = partial_crc32(cur->string, crc);
@@ -624,8 +635,8 @@ static void print_location(void)
624 635
625static void print_type_name(enum symbol_type type, const char *name) 636static void print_type_name(enum symbol_type type, const char *name)
626{ 637{
627 if (type != SYM_NORMAL) 638 if (symbol_types[type].name)
628 fprintf(stderr, "%s %s", symbol_type_name[type], name); 639 fprintf(stderr, "%s %s", symbol_types[type].name, name);
629 else 640 else
630 fprintf(stderr, "%s", name); 641 fprintf(stderr, "%s", name);
631} 642}
@@ -771,8 +782,8 @@ int main(int argc, char **argv)
771 782
772 if (sym->is_override) 783 if (sym->is_override)
773 fputs("override ", dumpfile); 784 fputs("override ", dumpfile);
774 if (sym->type != SYM_NORMAL) { 785 if (symbol_types[sym->type].n) {
775 putc(symbol_type_name[sym->type][0], dumpfile); 786 putc(symbol_types[sym->type].n, dumpfile);
776 putc('#', dumpfile); 787 putc('#', dumpfile);
777 } 788 }
778 fputs(sym->name, dumpfile); 789 fputs(sym->name, dumpfile);