add LIST_FIRST_ENTRY, LIST_LAST_ENTRY macro 13/174313/1
authorBoram Park <boram1288.park@samsung.com>
Fri, 30 Mar 2018 04:04:00 +0000 (13:04 +0900)
committerBoram Park <boram1288.park@samsung.com>
Fri, 30 Mar 2018 04:08:48 +0000 (13:08 +0900)
Change-Id: I98adf7df5ecb3dd94627e06bda3eb253033b289d

include/tdm_list.h

index 7475894..3873817 100644 (file)
@@ -112,6 +112,12 @@ static inline int list_length(struct list_head *item)
 #define LIST_ENTRY(__type, __item, __field)   \
        ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
 
+#define LIST_FIRST_ENTRY(__ptr, __type, __field)   \
+       LIST_ENTRY(__type, (__ptr)->next, __field)
+
+#define LIST_LAST_ENTRY(__ptr, __type, __field)   \
+       LIST_ENTRY(__type, (__ptr)->prev, __field)
+
 #define LIST_IS_EMPTY(__list)                   \
        ((__list)->next == (__list))