kbuild: move some helper headers from scripts/kconfig/ to scripts/include/
PATCH 1/2 kbuild: move some helper headers from scripts/kconfig/ to scripts/include/
Move array_size.h, hashtable.h, list.h, list_types.h from scripts/kconfig/ to scripts/include/.
These headers will be useful for other host programs.
Remove scripts/mod/list.h.
Signed-off-by Masahiro Yamada <[email protected]>
---
MAINTAINERS | 1 +
Makefile | 6 +-
scripts/{kconfig => include}/array_size.h | 0
scripts/{kconfig => include}/hashtable.h | 0
scripts/{kconfig => include}/list.h | 0
scripts/{kconfig => include}/list_types.h | 0
scripts/kconfig/expr.h | 3 +-
scripts/kconfig/internal.h | 2 +-
scripts/kconfig/mconf.c | 2 +-
scripts/kconfig/menu.c | 2 +-
scripts/kconfig/mnconf-common.c | 2 +-
scripts/kconfig/mnconf-common.h | 2 +
scripts/kconfig/nconf.c | 2 +-
scripts/kconfig/preprocess.c | 4 +-
scripts/kconfig/util.c | 2 +-
scripts/mod/list.h | 213 ----------------------
scripts/mod/modpost.c | 2 +
scripts/mod/modpost.h | 2 +-
18 files changed, 19 insertions(+), 226 deletions(-)
rename scripts/{kconfig => include}/array_size.h (100%)
rename scripts/{kconfig => include}/hashtable.h (100%)
rename scripts/{kconfig => include}/list.h (100%)
rename scripts/{kconfig => include}/list_types.h (100%)
delete mode 100644 scripts/mod/list.hMAINTAINERS +1 -0
@@ -11943,6 +11943,7 @@ F: scripts/Makefile* F: scripts/basic/ F: scripts/clang-tools/ F: scripts/dummy-tools/ +F: scripts/include/ F: scripts/mk* F: scripts/mod/ F: scripts/package/
Makefile +4 -2
@@ -458,8 +458,10 @@ export rust_common_flags := --edition=2021 \ -Dclippy::no_mangle_with_rust_abi \ -Wclippy::dbg_macro -KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) -KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) +KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \ + $(HOSTCFLAGS) -I $(srctree)/scripts/include +KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \ + -I $(srctree)/scripts/include KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \ -Zallow-features= $(HOSTRUSTFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
scripts/include/array_size.h renamed from scripts/kconfig/array_size.h +0 -0
scripts/include/hashtable.h renamed from scripts/kconfig/hashtable.h +0 -0
scripts/include/list.h renamed from scripts/kconfig/list.h +0 -0
scripts/include/list_types.h renamed from scripts/kconfig/list_types.h +0 -0
scripts/kconfig/expr.h +1 -2
@@ -12,12 +12,11 @@ extern "C" {#include <assert.h> #include <stdio.h> -#include "list_types.h" #ifndef __cplusplus#include <stdbool.h> #endif -#include "list_types.h" +#include <list_types.h> typedef enum tristate { no, mod, yes
scripts/kconfig/internal.h +1 -1
@@ -2,7 +2,7 @@#ifndef INTERNAL_H #define INTERNAL_H -#include "hashtable.h" +#include <hashtable.h> #define SYMBOL_HASHSIZE (1U << 14)
scripts/kconfig/mconf.c +1 -1
@@ -19,7 +19,7 @@#include <signal.h> #include <unistd.h> -#include "list.h" +#include <list.h> #include "lkc.h" #include "lxdialog/dialog.h" #include "mnconf-common.h"
scripts/kconfig/menu.c +1 -1
@@ -8,9 +8,9 @@#include <stdlib.h> #include <string.h> +#include <list.h> #include "lkc.h" #include "internal.h" -#include "list.h" static const char nohelp_text[] ="There is no help available for this option." ;
scripts/kconfig/mnconf-common.c +1 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only +#include <list.h> #include "expr.h" -#include "list.h" #include "mnconf-common.h" int jump_key_char;
scripts/kconfig/mnconf-common.h +2 -0
@@ -4,6 +4,8 @@#include <stddef.h> +#include <list_types.h> +struct search_data {struct list_head *head;struct menu *target;
scripts/kconfig/nconf.c +1 -1
@@ -11,7 +11,7 @@#include <strings.h> #include <stdlib.h> -#include "list.h" +#include <list.h> #include "lkc.h" #include "mnconf-common.h" #include "nconf.h"
scripts/kconfig/preprocess.c +2 -2
@@ -9,9 +9,9 @@#include <stdlib.h> #include <string.h> -#include "array_size.h" +#include <array_size.h> +#include <list.h> #include "internal.h" -#include "list.h" #include "lkc.h" #include "preprocess.h"
scripts/kconfig/util.c +1 -1
@@ -8,7 +8,7 @@#include <stdlib.h> #include <string.h> -#include "hashtable.h" +#include <hashtable.h> #include "lkc.h" unsigned int strhash (const char *s)
scripts/mod/list.h deleted +0 -213
213 lines not on this page · raw message
scripts/mod/modpost.c +2 -0
@@ -20,6 +20,8 @@#include <limits.h> #include <stdbool.h> #include <errno.h> + +#include <list.h> #include "modpost.h" #include "../../include/linux/license.h"
scripts/mod/modpost.h +1 -1
@@ -13,7 +13,7 @@#include <elf.h> #include "../../include/linux/module_symbol.h" -#include "list.h" +#include <list_types.h> #include "elfconfig.h" /* On BSD-alike OSes elf.h defines these according to host's word size */
Signature · 1 line
2.43.0
PATCH 2/2 modpost: use generic macros for hash table implementation
Use macros provided by hashtable.h
Signed-off-by Masahiro Yamada <[email protected]>
---
scripts/mod/modpost.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
scripts/mod/modpost.c +5 -13
@@ -21,6 +21,7 @@#include <stdbool.h> #include <errno.h> +#include <hashtable.h> #include <list.h> #include "modpost.h" #include "../../include/linux/license.h"
@@ -201,13 +202,8 @@ static struct module *new_module(const char *name, size_t namelen)return mod; } -/* A hash of all exported symbols, -* struct symbol is also used for lists of unresolved symbols */ - -#define SYMBOL_HASH_SIZE 1024 -struct symbol { -struct symbol *next; +struct hlist_node hnode;/* link to hash table */ struct list_head list;/* link to module::exported_symbols or module::unresolved_symbols */ struct module *module;char *namespace;
@@ -220,7 +216,7 @@ struct symbol {char name[]; }; -static struct symbol *symbolhash[SYMBOL_HASH_SIZE ]; +static HASHTABLE_DEFINE(symbol_hashtable, 1U << 10);/* This is based on the hash algorithm from gdbm, via tdb */ static inline unsigned int tdb_hash (const char *name)
@@ -252,11 +248,7 @@ static struct symbol *alloc_symbol(const char *name)/* For the hash of exported symbols */ static void hash_add_symbol (struct symbol *sym) { -unsigned int hash; - - hash =tdb_hash (sym->name) %SYMBOL_HASH_SIZE ; - sym->next = symbolhash[hash]; - symbolhash[hash] = sym; +hash_add (symbol_hashtable, &sym->hnode,tdb_hash (sym->name)); }static void sym_add_unresolved (const char *name,struct module *mod,bool weak)
@@ -277,7 +269,7 @@ static struct symbol *sym_find_with_module(const char *name, struct module *mod)if (name[0 ] =='.' ) name++; -for (s = symbolhash[tdb_hash (name) %SYMBOL_HASH_SIZE ]; s; s = s->next) { +hash_for_each_possible (symbol_hashtable, s, hnode,tdb_hash (name)) {if (strcmp (s->name, name) ==0 && (!mod || s->module == mod))return s; }
Signature · 1 line
2.43.0