aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-06-11 23:04:41 +0300
committerStefan Bucur <stefanb@zytor.com>2008-06-11 23:04:41 +0300
commit0faff07bff238831dc4135d3cbb0047b216cb7c3 (patch)
tree9c872dc94a68977060222a76d7dca3eadbe74da1
parent19f9ce0fe3b9f2a1e6ed2ef0c46d99f87066a4c4 (diff)
downloadsyslinux-elf-0faff07bff238831dc4135d3cbb0047b216cb7c3.tar.gz
syslinux-elf-0faff07bff238831dc4135d3cbb0047b216cb7c3.tar.xz
syslinux-elf-0faff07bff238831dc4135d3cbb0047b216cb7c3.zip
Fixed the Linux linked list implementation dependencies.
-rw-r--r--elf/linux_list.h29
1 files changed, 21 insertions, 8 deletions
diff --git a/elf/linux_list.h b/elf/linux_list.h
index 73c56869..3b92e254 100644
--- a/elf/linux_list.h
+++ b/elf/linux_list.h
@@ -18,6 +18,7 @@
*/
#include <stdlib.h>
+#include <stddef.h>
struct list_head {
struct list_head *next, *prev;
@@ -34,6 +35,18 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
list->prev = list;
}
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+
+
/*
* Insert a new entry between two known consecutive entries.
*
@@ -267,7 +280,7 @@ static inline void list_splice_init(struct list_head *list,
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
- for (pos = (head)->next; prefetch(pos->next), pos != (head); \
+ for (pos = (head)->next; pos != (head); \
pos = pos->next)
/**
@@ -289,7 +302,7 @@ static inline void list_splice_init(struct list_head *list,
* @head: the head for your list.
*/
#define list_for_each_prev(pos, head) \
- for (pos = (head)->prev; prefetch(pos->prev), pos != (head); \
+ for (pos = (head)->prev; pos != (head); \
pos = pos->prev)
/**
@@ -310,7 +323,7 @@ static inline void list_splice_init(struct list_head *list,
*/
#define list_for_each_prev_safe(pos, n, head) \
for (pos = (head)->prev, n = pos->prev; \
- prefetch(pos->prev), pos != (head); \
+ pos != (head); \
pos = n, n = pos->prev)
/**
@@ -321,7 +334,7 @@ static inline void list_splice_init(struct list_head *list,
*/
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
+ &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
@@ -332,7 +345,7 @@ static inline void list_splice_init(struct list_head *list,
*/
#define list_for_each_entry_reverse(pos, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member); \
- prefetch(pos->member.prev), &pos->member != (head); \
+ &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
/**
@@ -357,7 +370,7 @@ static inline void list_splice_init(struct list_head *list,
*/
#define list_for_each_entry_continue(pos, head, member) \
for (pos = list_entry(pos->member.next, typeof(*pos), member); \
- prefetch(pos->member.next), &pos->member != (head); \
+ &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
@@ -371,7 +384,7 @@ static inline void list_splice_init(struct list_head *list,
*/
#define list_for_each_entry_continue_reverse(pos, head, member) \
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
- prefetch(pos->member.prev), &pos->member != (head); \
+ &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
/**
@@ -383,7 +396,7 @@ static inline void list_splice_init(struct list_head *list,
* Iterate over list of given type, continuing from current position.
*/
#define list_for_each_entry_from(pos, head, member) \
- for (; prefetch(pos->member.next), &pos->member != (head); \
+ for (; &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**