Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <masahiroy@kernel.org>

+19 -226
+1
MAINTAINERS
··· 11943 11943 F: scripts/basic/ 11944 11944 F: scripts/clang-tools/ 11945 11945 F: scripts/dummy-tools/ 11946 + F: scripts/include/ 11946 11947 F: scripts/mk* 11947 11948 F: scripts/mod/ 11948 11949 F: scripts/package/
+4 -2
Makefile
··· 458 458 -Dclippy::no_mangle_with_rust_abi \ 459 459 -Wclippy::dbg_macro 460 460 461 - KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) 462 - KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) 461 + KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \ 462 + $(HOSTCFLAGS) -I $(srctree)/scripts/include 463 + KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) \ 464 + -I $(srctree)/scripts/include 463 465 KBUILD_HOSTRUSTFLAGS := $(rust_common_flags) -O -Cstrip=debuginfo \ 464 466 -Zallow-features= $(HOSTRUSTFLAGS) 465 467 KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
scripts/kconfig/array_size.h scripts/include/array_size.h
+1 -2
scripts/kconfig/expr.h
··· 12 12 13 13 #include <assert.h> 14 14 #include <stdio.h> 15 - #include "list_types.h" 16 15 #ifndef __cplusplus 17 16 #include <stdbool.h> 18 17 #endif 19 18 20 - #include "list_types.h" 19 + #include <list_types.h> 21 20 22 21 typedef enum tristate { 23 22 no, mod, yes
scripts/kconfig/hashtable.h scripts/include/hashtable.h
+1 -1
scripts/kconfig/internal.h
··· 2 2 #ifndef INTERNAL_H 3 3 #define INTERNAL_H 4 4 5 - #include "hashtable.h" 5 + #include <hashtable.h> 6 6 7 7 #define SYMBOL_HASHSIZE (1U << 14) 8 8
scripts/kconfig/list.h scripts/include/list.h
scripts/kconfig/list_types.h scripts/include/list_types.h
+1 -1
scripts/kconfig/mconf.c
··· 19 19 #include <signal.h> 20 20 #include <unistd.h> 21 21 22 - #include "list.h" 22 + #include <list.h> 23 23 #include "lkc.h" 24 24 #include "lxdialog/dialog.h" 25 25 #include "mnconf-common.h"
+1 -1
scripts/kconfig/menu.c
··· 8 8 #include <stdlib.h> 9 9 #include <string.h> 10 10 11 + #include <list.h> 11 12 #include "lkc.h" 12 13 #include "internal.h" 13 - #include "list.h" 14 14 15 15 static const char nohelp_text[] = "There is no help available for this option."; 16 16
+1 -1
scripts/kconfig/mnconf-common.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 + #include <list.h> 2 3 #include "expr.h" 3 - #include "list.h" 4 4 #include "mnconf-common.h" 5 5 6 6 int jump_key_char;
+2
scripts/kconfig/mnconf-common.h
··· 4 4 5 5 #include <stddef.h> 6 6 7 + #include <list_types.h> 8 + 7 9 struct search_data { 8 10 struct list_head *head; 9 11 struct menu *target;
+1 -1
scripts/kconfig/nconf.c
··· 11 11 #include <strings.h> 12 12 #include <stdlib.h> 13 13 14 - #include "list.h" 14 + #include <list.h> 15 15 #include "lkc.h" 16 16 #include "mnconf-common.h" 17 17 #include "nconf.h"
+2 -2
scripts/kconfig/preprocess.c
··· 9 9 #include <stdlib.h> 10 10 #include <string.h> 11 11 12 - #include "array_size.h" 12 + #include <array_size.h> 13 + #include <list.h> 13 14 #include "internal.h" 14 - #include "list.h" 15 15 #include "lkc.h" 16 16 #include "preprocess.h" 17 17
+1 -1
scripts/kconfig/util.c
··· 8 8 #include <stdlib.h> 9 9 #include <string.h> 10 10 11 - #include "hashtable.h" 11 + #include <hashtable.h> 12 12 #include "lkc.h" 13 13 14 14 unsigned int strhash(const char *s)
-213
scripts/mod/list.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef LIST_H 3 - #define LIST_H 4 - 5 - #include <stdbool.h> 6 - #include <stddef.h> 7 - 8 - /* Are two types/vars the same type (ignoring qualifiers)? */ 9 - #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) 10 - 11 - /** 12 - * container_of - cast a member of a structure out to the containing structure 13 - * @ptr: the pointer to the member. 14 - * @type: the type of the container struct this is embedded in. 15 - * @member: the name of the member within the struct. 16 - * 17 - */ 18 - #define container_of(ptr, type, member) ({ \ 19 - void *__mptr = (void *)(ptr); \ 20 - _Static_assert(__same_type(*(ptr), ((type *)0)->member) || \ 21 - __same_type(*(ptr), void), \ 22 - "pointer type mismatch in container_of()"); \ 23 - ((type *)(__mptr - offsetof(type, member))); }) 24 - 25 - #define LIST_POISON1 ((void *) 0x100) 26 - #define LIST_POISON2 ((void *) 0x122) 27 - 28 - /* 29 - * Circular doubly linked list implementation. 30 - * 31 - * Some of the internal functions ("__xxx") are useful when 32 - * manipulating whole lists rather than single entries, as 33 - * sometimes we already know the next/prev entries and we can 34 - * generate better code by using them directly rather than 35 - * using the generic single-entry routines. 36 - */ 37 - 38 - struct list_head { 39 - struct list_head *next, *prev; 40 - }; 41 - 42 - #define LIST_HEAD_INIT(name) { &(name), &(name) } 43 - 44 - #define LIST_HEAD(name) \ 45 - struct list_head name = LIST_HEAD_INIT(name) 46 - 47 - /** 48 - * INIT_LIST_HEAD - Initialize a list_head structure 49 - * @list: list_head structure to be initialized. 50 - * 51 - * Initializes the list_head to point to itself. If it is a list header, 52 - * the result is an empty list. 53 - */ 54 - static inline void INIT_LIST_HEAD(struct list_head *list) 55 - { 56 - list->next = list; 57 - list->prev = list; 58 - } 59 - 60 - /* 61 - * Insert a new entry between two known consecutive entries. 62 - * 63 - * This is only for internal list manipulation where we know 64 - * the prev/next entries already! 65 - */ 66 - static inline void __list_add(struct list_head *new, 67 - struct list_head *prev, 68 - struct list_head *next) 69 - { 70 - next->prev = new; 71 - new->next = next; 72 - new->prev = prev; 73 - prev->next = new; 74 - } 75 - 76 - /** 77 - * list_add - add a new entry 78 - * @new: new entry to be added 79 - * @head: list head to add it after 80 - * 81 - * Insert a new entry after the specified head. 82 - * This is good for implementing stacks. 83 - */ 84 - static inline void list_add(struct list_head *new, struct list_head *head) 85 - { 86 - __list_add(new, head, head->next); 87 - } 88 - 89 - /** 90 - * list_add_tail - add a new entry 91 - * @new: new entry to be added 92 - * @head: list head to add it before 93 - * 94 - * Insert a new entry before the specified head. 95 - * This is useful for implementing queues. 96 - */ 97 - static inline void list_add_tail(struct list_head *new, struct list_head *head) 98 - { 99 - __list_add(new, head->prev, head); 100 - } 101 - 102 - /* 103 - * Delete a list entry by making the prev/next entries 104 - * point to each other. 105 - * 106 - * This is only for internal list manipulation where we know 107 - * the prev/next entries already! 108 - */ 109 - static inline void __list_del(struct list_head *prev, struct list_head *next) 110 - { 111 - next->prev = prev; 112 - prev->next = next; 113 - } 114 - 115 - static inline void __list_del_entry(struct list_head *entry) 116 - { 117 - __list_del(entry->prev, entry->next); 118 - } 119 - 120 - /** 121 - * list_del - deletes entry from list. 122 - * @entry: the element to delete from the list. 123 - * Note: list_empty() on entry does not return true after this, the entry is 124 - * in an undefined state. 125 - */ 126 - static inline void list_del(struct list_head *entry) 127 - { 128 - __list_del_entry(entry); 129 - entry->next = LIST_POISON1; 130 - entry->prev = LIST_POISON2; 131 - } 132 - 133 - /** 134 - * list_is_head - tests whether @list is the list @head 135 - * @list: the entry to test 136 - * @head: the head of the list 137 - */ 138 - static inline int list_is_head(const struct list_head *list, const struct list_head *head) 139 - { 140 - return list == head; 141 - } 142 - 143 - /** 144 - * list_empty - tests whether a list is empty 145 - * @head: the list to test. 146 - */ 147 - static inline int list_empty(const struct list_head *head) 148 - { 149 - return head->next == head; 150 - } 151 - 152 - /** 153 - * list_entry - get the struct for this entry 154 - * @ptr: the &struct list_head pointer. 155 - * @type: the type of the struct this is embedded in. 156 - * @member: the name of the list_head within the struct. 157 - */ 158 - #define list_entry(ptr, type, member) \ 159 - container_of(ptr, type, member) 160 - 161 - /** 162 - * list_first_entry - get the first element from a list 163 - * @ptr: the list head to take the element from. 164 - * @type: the type of the struct this is embedded in. 165 - * @member: the name of the list_head within the struct. 166 - * 167 - * Note, that list is expected to be not empty. 168 - */ 169 - #define list_first_entry(ptr, type, member) \ 170 - list_entry((ptr)->next, type, member) 171 - 172 - /** 173 - * list_next_entry - get the next element in list 174 - * @pos: the type * to cursor 175 - * @member: the name of the list_head within the struct. 176 - */ 177 - #define list_next_entry(pos, member) \ 178 - list_entry((pos)->member.next, typeof(*(pos)), member) 179 - 180 - /** 181 - * list_entry_is_head - test if the entry points to the head of the list 182 - * @pos: the type * to cursor 183 - * @head: the head for your list. 184 - * @member: the name of the list_head within the struct. 185 - */ 186 - #define list_entry_is_head(pos, head, member) \ 187 - (&pos->member == (head)) 188 - 189 - /** 190 - * list_for_each_entry - iterate over list of given type 191 - * @pos: the type * to use as a loop cursor. 192 - * @head: the head for your list. 193 - * @member: the name of the list_head within the struct. 194 - */ 195 - #define list_for_each_entry(pos, head, member) \ 196 - for (pos = list_first_entry(head, typeof(*pos), member); \ 197 - !list_entry_is_head(pos, head, member); \ 198 - pos = list_next_entry(pos, member)) 199 - 200 - /** 201 - * list_for_each_entry_safe - iterate over list of given type. Safe against removal of list entry 202 - * @pos: the type * to use as a loop cursor. 203 - * @n: another type * to use as temporary storage 204 - * @head: the head for your list. 205 - * @member: the name of the list_head within the struct. 206 - */ 207 - #define list_for_each_entry_safe(pos, n, head, member) \ 208 - for (pos = list_first_entry(head, typeof(*pos), member), \ 209 - n = list_next_entry(pos, member); \ 210 - !list_entry_is_head(pos, head, member); \ 211 - pos = n, n = list_next_entry(n, member)) 212 - 213 - #endif /* LIST_H */
+2
scripts/mod/modpost.c
··· 20 20 #include <limits.h> 21 21 #include <stdbool.h> 22 22 #include <errno.h> 23 + 24 + #include <list.h> 23 25 #include "modpost.h" 24 26 #include "../../include/linux/license.h" 25 27
+1 -1
scripts/mod/modpost.h
··· 13 13 #include <elf.h> 14 14 #include "../../include/linux/module_symbol.h" 15 15 16 - #include "list.h" 16 + #include <list_types.h> 17 17 #include "elfconfig.h" 18 18 19 19 /* On BSD-alike OSes elf.h defines these according to host's word size */