[SeaBIOS] [PATCH 1/4] Add basic linked list operations
Alexey Korolev
alexey.korolev at endace.com
Wed Mar 28 06:28:11 CEST 2012
This linked list implementation is partially based on kernel code. So it
should be quite stable
Signed-off-by: Alexey Korolev <alexey.korolev at endace.com>
---
src/util.h | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/util.h b/src/util.h
index 70d3c4c..17df3cf 100644
--- a/src/util.h
+++ b/src/util.h
@@ -195,6 +195,27 @@ struct descloc_s {
u32 addr;
} PACKED;
+// Double linked lists with a single pointer list head
+#define list_foreach_entry_safe(head, next, entry) \
+ for (entry = head; entry && ({next=entry->next; 1;}); \
+ entry = next)
+
+#define list_del(entry) \
+ do { \
+ *(entry)->pprev = (entry)->next; \
+ if ((entry)->next) \
+ (entry)->next->pprev = (entry)->pprev; \
+ } while (0)
+
+#define list_add_head(phead, entry) \
+ do { \
+ (entry)->next = *(phead); \
+ if (*(phead)) \
+ (*(phead))->pprev = &(entry)->next; \
+ *(phead) = entry; \
+ (entry)->pprev = phead; \
+ } while (0)
+
// util.c
void cpuid(u32 index, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
struct bregs;
--
1.7.5.4
More information about the SeaBIOS
mailing list