aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Marek <mmarek@suse.cz>2011-02-15 09:11:36 -0500
committerMichal Marek <mmarek@suse.cz>2011-03-17 10:13:55 -0400
commit01762c4ec5f6f62c550304b9c70e824293cefdd0 (patch)
tree4a457cec48321f5b591966e56ddaea33733df5cc
parent68eb8563a1adf27fae18dde4c95fb796c17563df (diff)
genksyms: simplify usage of find_symbol()
Allow searching for symbols of an exact type. The lexer does this and a subsequent patch will add one more usage. Signed-off-by: Michal Marek <mmarek@suse.cz> Acked-by: Sam Ravnborg <sam@ravnborg.org>
-rw-r--r--scripts/genksyms/genksyms.c10
-rw-r--r--scripts/genksyms/genksyms.h2
-rw-r--r--scripts/genksyms/lex.c_shipped3
-rw-r--r--scripts/genksyms/lex.l3
4 files changed, 9 insertions, 9 deletions
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index d17b7a2b941f..4a350816a9e8 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -156,7 +156,7 @@ static enum symbol_type map_to_ns(enum symbol_type t)
156 return t; 156 return t;
157} 157}
158 158
159struct symbol *find_symbol(const char *name, enum symbol_type ns) 159struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact)
160{ 160{
161 unsigned long h = crc32(name) % HASH_BUCKETS; 161 unsigned long h = crc32(name) % HASH_BUCKETS;
162 struct symbol *sym; 162 struct symbol *sym;
@@ -167,6 +167,8 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns)
167 sym->is_declared) 167 sym->is_declared)
168 break; 168 break;
169 169
170 if (exact && sym && sym->type != ns)
171 return NULL;
170 return sym; 172 return sym;
171} 173}
172 174
@@ -511,7 +513,7 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
511 break; 513 break;
512 514
513 case SYM_TYPEDEF: 515 case SYM_TYPEDEF:
514 subsym = find_symbol(cur->string, cur->tag); 516 subsym = find_symbol(cur->string, cur->tag, 0);
515 /* FIXME: Bad reference files can segfault here. */ 517 /* FIXME: Bad reference files can segfault here. */
516 if (subsym->expansion_trail) { 518 if (subsym->expansion_trail) {
517 if (flag_dump_defs) 519 if (flag_dump_defs)
@@ -528,7 +530,7 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
528 case SYM_STRUCT: 530 case SYM_STRUCT:
529 case SYM_UNION: 531 case SYM_UNION:
530 case SYM_ENUM: 532 case SYM_ENUM:
531 subsym = find_symbol(cur->string, cur->tag); 533 subsym = find_symbol(cur->string, cur->tag, 0);
532 if (!subsym) { 534 if (!subsym) {
533 struct string_list *n; 535 struct string_list *n;
534 536
@@ -582,7 +584,7 @@ void export_symbol(const char *name)
582{ 584{
583 struct symbol *sym; 585 struct symbol *sym;
584 586
585 sym = find_symbol(name, SYM_NORMAL); 587 sym = find_symbol(name, SYM_NORMAL, 0);
586 if (!sym) 588 if (!sym)
587 error_with_pos("export undefined symbol %s", name); 589 error_with_pos("export undefined symbol %s", name);
588 else { 590 else {
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
index 25c4d40cefc1..9fdafb667e76 100644
--- a/scripts/genksyms/genksyms.h
+++ b/scripts/genksyms/genksyms.h
@@ -58,7 +58,7 @@ typedef struct string_list **yystype;
58extern int cur_line; 58extern int cur_line;
59extern char *cur_filename; 59extern char *cur_filename;
60 60
61struct symbol *find_symbol(const char *name, enum symbol_type ns); 61struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
62struct symbol *add_symbol(const char *name, enum symbol_type type, 62struct symbol *add_symbol(const char *name, enum symbol_type type,
63 struct string_list *defn, int is_extern); 63 struct string_list *defn, int is_extern);
64void export_symbol(const char *); 64void export_symbol(const char *);
diff --git a/scripts/genksyms/lex.c_shipped b/scripts/genksyms/lex.c_shipped
index d0a0423361fd..f231c0810c60 100644
--- a/scripts/genksyms/lex.c_shipped
+++ b/scripts/genksyms/lex.c_shipped
@@ -2347,8 +2347,7 @@ repeat:
2347 } 2347 }
2348 if (!suppress_type_lookup) 2348 if (!suppress_type_lookup)
2349 { 2349 {
2350 struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF); 2350 if (find_symbol(yytext, SYM_TYPEDEF, 1))
2351 if (sym && sym->type == SYM_TYPEDEF)
2352 token = TYPE; 2351 token = TYPE;
2353 } 2352 }
2354 } 2353 }
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index 4687b1d147de..c125d06fbd36 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -193,8 +193,7 @@ repeat:
193 } 193 }
194 if (!suppress_type_lookup) 194 if (!suppress_type_lookup)
195 { 195 {
196 struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF); 196 if (find_symbol(yytext, SYM_TYPEDEF, 1))
197 if (sym && sym->type == SYM_TYPEDEF)
198 token = TYPE; 197 token = TYPE;
199 } 198 }
200 } 199 }