diff options
| author | Ingo Molnar <mingo@kernel.org> | 2024-03-25 13:32:29 +0300 | 
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2024-03-25 13:32:29 +0300 | 
| commit | f4566a1e73957800df75a3dd2dccee8a4697f327 (patch) | |
| tree | b043b875228c0b25988af66c680d60cae69d761d /scripts/kconfig/util.c | |
| parent | b9e6e28663928cab836a19abbdec3d036a07db3b (diff) | |
| parent | 4cece764965020c22cff7665b18a012006359095 (diff) | |
| download | linux-f4566a1e73957800df75a3dd2dccee8a4697f327.tar.xz | |
Merge tag 'v6.9-rc1' into sched/core, to pick up fixes and to refresh the branch
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'scripts/kconfig/util.c')
| -rw-r--r-- | scripts/kconfig/util.c | 47 | 
1 files changed, 36 insertions, 11 deletions
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 92e5b2b9761d..439c131b424e 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -7,25 +7,50 @@  #include <stdarg.h>  #include <stdlib.h>  #include <string.h> + +#include "hashtable.h"  #include "lkc.h" +unsigned int strhash(const char *s) +{ +	/* fnv32 hash */ +	unsigned int hash = 2166136261U; + +	for (; *s; s++) +		hash = (hash ^ *s) * 0x01000193; +	return hash; +} + +/* hash table of all parsed Kconfig files */ +static HASHTABLE_DEFINE(file_hashtable, 1U << 11); + +struct file { +	struct hlist_node node; +	char name[]; +}; +  /* file already present in list? If not add it */ -struct file *file_lookup(const char *name) +const char *file_lookup(const char *name)  {  	struct file *file; +	size_t len; +	int hash = strhash(name); -	for (file = file_list; file; file = file->next) { -		if (!strcmp(name, file->name)) { -			return file; -		} -	} +	hash_for_each_possible(file_hashtable, file, node, hash) +		if (!strcmp(name, file->name)) +			return file->name; -	file = xmalloc(sizeof(*file)); +	len = strlen(name); +	file = xmalloc(sizeof(*file) + len + 1);  	memset(file, 0, sizeof(*file)); -	file->name = xstrdup(name); -	file->next = file_list; -	file_list = file; -	return file; +	memcpy(file->name, name, len); +	file->name[len] = '\0'; + +	hash_add(file_hashtable, &file->node, hash); + +	str_printf(&autoconf_cmd, "\t%s \\\n", name); + +	return file->name;  }  /* Allocate initial growable string */  | 
