kconfig: split list_head into a separate header

The struct list_head is often embedded in other structures, while other
code is used in C functions.

By separating struct list_head into its own header, other headers are no
longer required to include the entire list.h.

This is similar to the kernel space, where struct list_head is defined
in <linux/types.h> instead of <linux/list.h>.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
Masahiro Yamada 2024-02-03 00:58:17 +09:00
parent 5b058034e3
commit 4dae9cf5cb
6 changed files with 15 additions and 7 deletions

View file

@ -12,7 +12,7 @@ extern "C" {
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "list.h" #include "list_types.h"
#ifndef __cplusplus #ifndef __cplusplus
#include <stdbool.h> #include <stdbool.h>
#endif #endif

View file

@ -2,6 +2,8 @@
#ifndef LIST_H #ifndef LIST_H
#define LIST_H #define LIST_H
#include "list_types.h"
/* /*
* Copied from include/linux/... * Copied from include/linux/...
*/ */
@ -20,12 +22,6 @@
const typeof( ((type *)0)->member ) *__mptr = (ptr); \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );}) (type *)( (char *)__mptr - offsetof(type,member) );})
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) } #define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \ #define LIST_HEAD(name) \

View file

@ -0,0 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef LIST_TYPES_H
#define LIST_TYPES_H
struct list_head {
struct list_head *next, *prev;
};
#endif /* LIST_TYPES_H */

View file

@ -19,6 +19,7 @@
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include "list.h"
#include "lkc.h" #include "lkc.h"
#include "lxdialog/dialog.h" #include "lxdialog/dialog.h"
#include "mnconf-common.h" #include "mnconf-common.h"

View file

@ -10,6 +10,7 @@
#include "lkc.h" #include "lkc.h"
#include "internal.h" #include "internal.h"
#include "list.h"
static const char nohelp_text[] = "There is no help available for this option."; static const char nohelp_text[] = "There is no help available for this option.";

View file

@ -11,6 +11,7 @@
#include <strings.h> #include <strings.h>
#include <stdlib.h> #include <stdlib.h>
#include "list.h"
#include "lkc.h" #include "lkc.h"
#include "mnconf-common.h" #include "mnconf-common.h"
#include "nconf.h" #include "nconf.h"