summaryrefslogtreecommitdiff
path: root/src/apk_defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/apk_defines.h')
-rw-r--r--src/apk_defines.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/apk_defines.h b/src/apk_defines.h
index afd9f13..ea4da76 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -14,8 +14,9 @@
#include <string.h>
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#define BIT(x) (1 << (x))
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#define BIT(x) (1 << (x))
+#define max(a, b) ((a) > (b) ? (a) : (b))
#ifndef TRUE
#define TRUE 1
@@ -259,7 +260,7 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
__list_add(new, head->prev, head);
}
-static inline void __list_del(struct list_head * prev, struct list_head * next)
+static inline void __list_del(struct list_head *prev, struct list_head *next)
{
next->prev = prev;
prev->next = next;
@@ -272,6 +273,13 @@ static inline void list_del(struct list_head *entry)
entry->prev = LIST_POISON2;
}
+static inline void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = NULL;
+ entry->prev = NULL;
+}
+
static inline int list_hashed(const struct list_head *n)
{
return n->next != n && n->next != NULL;
@@ -282,8 +290,17 @@ static inline int list_empty(const struct list_head *n)
return n->next == n;
}
+static inline struct list_head *__list_pop(struct list_head *head)
+{
+ struct list_head *n = head->next;
+ list_del_init(n);
+ return n;
+}
+
#define list_entry(ptr, type, member) container_of(ptr,type,member)
+#define list_pop(head, type, member) container_of(__list_pop(head),type,member)
+
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)