svn commit: r310589 - head/sys/compat/linuxkpi/common/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Dec 26 10:41:53 UTC 2016
Author: hselasky
Date: Mon Dec 26 10:41:51 2016
New Revision: 310589
URL: https://svnweb.freebsd.org/changeset/base/310589
Log:
Implement more list header file functions.
Add definition guard for the list_head structure.
Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies
Modified:
head/sys/compat/linuxkpi/common/include/linux/list.h
Modified: head/sys/compat/linuxkpi/common/include/linux/list.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/list.h Mon Dec 26 10:24:48 2016 (r310588)
+++ head/sys/compat/linuxkpi/common/include/linux/list.h Mon Dec 26 10:41:51 2016 (r310589)
@@ -72,10 +72,18 @@
#define prefetch(x)
+#define LINUX_LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LINUX_LIST_HEAD(name) \
+ struct list_head name = LINUX_LIST_HEAD_INIT(name)
+
+#ifndef LIST_HEAD_DEF
+#define LIST_HEAD_DEF
struct list_head {
struct list_head *next;
struct list_head *prev;
};
+#endif
static inline void
INIT_LIST_HEAD(struct list_head *list)
@@ -91,12 +99,26 @@ list_empty(const struct list_head *head)
return (head->next == head);
}
+static inline int
+list_empty_careful(const struct list_head *head)
+{
+ struct list_head *next = head->next;
+
+ return ((next == head) && (next == head->prev));
+}
+
+static inline void
+__list_del(struct list_head *prev, struct list_head *next)
+{
+ next->prev = prev;
+ WRITE_ONCE(prev->next, next);
+}
+
static inline void
list_del(struct list_head *entry)
{
- entry->next->prev = entry->prev;
- entry->prev->next = entry->next;
+ __list_del(entry->prev, entry->next);
}
static inline void
@@ -183,6 +205,11 @@ list_del_init(struct list_head *entry)
for (p = list_entry((h)->prev, typeof(*p), field); &(p)->field != (h); \
p = list_entry((p)->field.prev, typeof(*p), field))
+#define list_for_each_entry_safe_reverse(p, n, h, field) \
+ for (p = list_entry((h)->prev, typeof(*p), field), \
+ n = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
+ p = n, n = list_entry(n->field.prev, typeof(*n), field))
+
#define list_for_each_entry_continue_reverse(p, h, field) \
for (p = list_entry((p)->field.prev, typeof(*p), field); &(p)->field != (h); \
p = list_entry((p)->field.prev, typeof(*p), field))
More information about the svn-src-all
mailing list