[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1299997825-18977-6-git-send-email-mmarek@suse.cz>
Date: Sun, 13 Mar 2011 07:30:23 +0100
From: Michal Marek <mmarek@...e.cz>
To: linux-kbuild@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 5/7] 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@...e.cz>
---
scripts/genksyms/genksyms.c | 10 ++++++----
scripts/genksyms/genksyms.h | 2 +-
scripts/genksyms/lex.c_shipped | 3 +--
scripts/genksyms/lex.l | 3 +--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index d17b7a2..4a35081 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)
return t;
}
-struct symbol *find_symbol(const char *name, enum symbol_type ns)
+struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact)
{
unsigned long h = crc32(name) % HASH_BUCKETS;
struct symbol *sym;
@@ -167,6 +167,8 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns)
sym->is_declared)
break;
+ if (exact && sym && sym->type != ns)
+ return NULL;
return sym;
}
@@ -511,7 +513,7 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
break;
case SYM_TYPEDEF:
- subsym = find_symbol(cur->string, cur->tag);
+ subsym = find_symbol(cur->string, cur->tag, 0);
/* FIXME: Bad reference files can segfault here. */
if (subsym->expansion_trail) {
if (flag_dump_defs)
@@ -528,7 +530,7 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc)
case SYM_STRUCT:
case SYM_UNION:
case SYM_ENUM:
- subsym = find_symbol(cur->string, cur->tag);
+ subsym = find_symbol(cur->string, cur->tag, 0);
if (!subsym) {
struct string_list *n;
@@ -582,7 +584,7 @@ void export_symbol(const char *name)
{
struct symbol *sym;
- sym = find_symbol(name, SYM_NORMAL);
+ sym = find_symbol(name, SYM_NORMAL, 0);
if (!sym)
error_with_pos("export undefined symbol %s", name);
else {
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
index 25c4d40..9fdafb6 100644
--- a/scripts/genksyms/genksyms.h
+++ b/scripts/genksyms/genksyms.h
@@ -58,7 +58,7 @@ typedef struct string_list **yystype;
extern int cur_line;
extern char *cur_filename;
-struct symbol *find_symbol(const char *name, enum symbol_type ns);
+struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact);
struct symbol *add_symbol(const char *name, enum symbol_type type,
struct string_list *defn, int is_extern);
void export_symbol(const char *);
diff --git a/scripts/genksyms/lex.c_shipped b/scripts/genksyms/lex.c_shipped
index d0a0423..f231c08 100644
--- a/scripts/genksyms/lex.c_shipped
+++ b/scripts/genksyms/lex.c_shipped
@@ -2347,8 +2347,7 @@ repeat:
}
if (!suppress_type_lookup)
{
- struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF);
- if (sym && sym->type == SYM_TYPEDEF)
+ if (find_symbol(yytext, SYM_TYPEDEF, 1))
token = TYPE;
}
}
diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l
index 4687b1d..c125d06 100644
--- a/scripts/genksyms/lex.l
+++ b/scripts/genksyms/lex.l
@@ -193,8 +193,7 @@ repeat:
}
if (!suppress_type_lookup)
{
- struct symbol *sym = find_symbol(yytext, SYM_TYPEDEF);
- if (sym && sym->type == SYM_TYPEDEF)
+ if (find_symbol(yytext, SYM_TYPEDEF, 1))
token = TYPE;
}
}
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists