From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH v2 01/12] kconfig: import list_move(_tail) and list_for_each_entry_reverse macros
Date: Tue, 18 Jun 2024 19:35:20 +0900 [thread overview]
Message-ID: <20240618103541.3508486-2-masahiroy@kernel.org> (raw)
In-Reply-To: <20240618103541.3508486-1-masahiroy@kernel.org>
Import more macros from include/linux/list.h.
These will be used in the next commit.
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---
Changes in v2:
- Import list_for_each_entry_reverse too
scripts/kconfig/list.h | 53 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
index 882859ddf9f4..409201cd495b 100644
--- a/scripts/kconfig/list.h
+++ b/scripts/kconfig/list.h
@@ -127,6 +127,29 @@ static inline void list_del(struct list_head *entry)
entry->prev = LIST_POISON2;
}
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+ __list_del_entry(list);
+ list_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+ struct list_head *head)
+{
+ __list_del_entry(list);
+ list_add_tail(list, head);
+}
+
/**
* list_is_head - tests whether @list is the list @head
* @list: the entry to test
@@ -166,6 +189,17 @@ static inline int list_empty(const struct list_head *head)
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
+/**
+ * list_last_entry - get the last element from a list
+ * @ptr: the list head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_head within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_last_entry(ptr, type, member) \
+ list_entry((ptr)->prev, type, member)
+
/**
* list_next_entry - get the next element in list
* @pos: the type * to cursor
@@ -174,6 +208,14 @@ static inline int list_empty(const struct list_head *head)
#define list_next_entry(pos, member) \
list_entry((pos)->member.next, typeof(*(pos)), member)
+/**
+ * list_prev_entry - get the prev element in list
+ * @pos: the type * to cursor
+ * @member: the name of the list_head within the struct.
+ */
+#define list_prev_entry(pos, member) \
+ list_entry((pos)->member.prev, typeof(*(pos)), member)
+
/**
* list_entry_is_head - test if the entry points to the head of the list
* @pos: the type * to cursor
@@ -194,6 +236,17 @@ static inline int list_empty(const struct list_head *head)
!list_entry_is_head(pos, head, member); \
pos = list_next_entry(pos, member))
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_head within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_last_entry(head, typeof(*pos), member); \
+ !list_entry_is_head(pos, head, member); \
+ pos = list_prev_entry(pos, member))
+
/**
* list_for_each_entry_safe - iterate over list of given type. Safe against removal of list entry
* @pos: the type * to use as a loop cursor.
--
2.43.0
next prev parent reply other threads:[~2024-06-18 10:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-18 10:35 [PATCH v2 00/12] kconfig: fix choice value calculation with misc cleanups Masahiro Yamada
2024-06-18 10:35 ` Masahiro Yamada [this message]
2024-06-18 10:35 ` [PATCH v2 02/12] kconfig: refactor choice value calculation Masahiro Yamada
2024-08-31 17:30 ` Niklas Söderlund
2024-09-01 9:10 ` Masahiro Yamada
2024-09-01 9:32 ` Niklas Söderlund
2024-06-18 10:35 ` [PATCH v2 03/12] kconfig: remove sym_get_choice_value() Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 04/12] kconfig: remove conf_unsaved in conf_read_simple() Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 05/12] kconfig: change sym_choice_default() to take the choice menu Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 06/12] kconfig: use menu_list_for_each_sym() in sym_choice_default() Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 07/12] kconfig: remove expr_list_for_each_sym() macro Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 08/12] kconfig: use sym_get_choice_menu() in sym_check_print_recursive() Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 09/12] kconfig: use sym_get_choice_menu() in sym_check_choice_deps() Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 10/12] kconfig: use sym_get_choice_menu() in sym_check_deps() Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 11/12] kconfig: remove P_CHOICE property Masahiro Yamada
2024-06-18 10:35 ` [PATCH v2 12/12] kconfig: remove E_LIST expression type Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240618103541.3508486-2-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox