Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 199500
b: refs/heads/master
c: e66f25d
h: refs/heads/master
v: v3
  • Loading branch information
Andi Kleen authored and Michal Marek committed Feb 2, 2010
1 parent 8626c4b commit b90495a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 62718979780720e526a411dc66e810288aaa7bf6
refs/heads/master: e66f25d7d1be19e177cf55126a40799757efae89
5 changes: 2 additions & 3 deletions trunk/scripts/kconfig/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct symbol {
struct expr_value rev_dep;
};

#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)

#define SYMBOL_CONST 0x0001 /* symbol is const */
#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
Expand All @@ -108,8 +108,7 @@ struct symbol {
#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */

#define SYMBOL_MAXLENGTH 256
#define SYMBOL_HASHSIZE 257
#define SYMBOL_HASHMASK 0xff
#define SYMBOL_HASHSIZE 9973

/* A property represent the config options that can be associated
* with a config "symbol".
Expand Down
29 changes: 17 additions & 12 deletions trunk/scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,20 @@ bool sym_is_changable(struct symbol *sym)
return sym->visible > sym->rev_dep.tri;
}

static unsigned strhash(const char *s)
{
/* fnv32 hash */
unsigned hash = 2166136261U;
for (; *s; s++)
hash = (hash ^ *s) * 0x01000193;
return hash;
}

struct symbol *sym_lookup(const char *name, int flags)
{
struct symbol *symbol;
const char *ptr;
char *new_name;
int hash = 0;
int hash;

if (name) {
if (name[0] && !name[1]) {
Expand All @@ -666,20 +674,19 @@ struct symbol *sym_lookup(const char *name, int flags)
case 'n': return &symbol_no;
}
}
for (ptr = name; *ptr; ptr++)
hash += *ptr;
hash &= 0xff;
hash = strhash(name) % SYMBOL_HASHSIZE;

for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
if (!strcmp(symbol->name, name) &&
if (symbol->name &&
!strcmp(symbol->name, name) &&
(flags ? symbol->flags & flags
: !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
return symbol;
}
new_name = strdup(name);
} else {
new_name = NULL;
hash = 256;
hash = 0;
}

symbol = malloc(sizeof(*symbol));
Expand All @@ -697,7 +704,6 @@ struct symbol *sym_lookup(const char *name, int flags)
struct symbol *sym_find(const char *name)
{
struct symbol *symbol = NULL;
const char *ptr;
int hash = 0;

if (!name)
Expand All @@ -710,12 +716,11 @@ struct symbol *sym_find(const char *name)
case 'n': return &symbol_no;
}
}
for (ptr = name; *ptr; ptr++)
hash += *ptr;
hash &= 0xff;
hash = strhash(name) % SYMBOL_HASHSIZE;

for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
if (!strcmp(symbol->name, name) &&
if (symbol->name &&
!strcmp(symbol->name, name) &&
!(symbol->flags & SYMBOL_CONST))
break;
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/scripts/kconfig/zconf.tab.c_shipped
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);

struct symbol *symbol_hash[257];
struct symbol *symbol_hash[SYMBOL_HASHSIZE];

static struct menu *current_menu, *current_entry;

Expand Down
2 changes: 1 addition & 1 deletion trunk/scripts/kconfig/zconf.y
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void zconf_error(const char *err, ...);
static void zconferror(const char *err);
static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);

struct symbol *symbol_hash[257];
struct symbol *symbol_hash[SYMBOL_HASHSIZE];

static struct menu *current_menu, *current_entry;

Expand Down

0 comments on commit b90495a

Please sign in to comment.