summaryrefslogtreecommitdiff
path: root/src/apk_defines.h
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2013-06-11 14:06:06 +0300
committerTimo Teräs <timo.teras@iki.fi>2013-06-13 18:22:00 +0300
commitb8c44536ca911418fee1c9ab4eecbb913a1ca852 (patch)
treea89e68b12f4d3daf089c475beeb71c53ffb8cc3a /src/apk_defines.h
parentf292a858677ae0e1af8910ffbd4b338f4b36c18b (diff)
downloadapk-tools-b8c44536ca911418fee1c9ab4eecbb913a1ca852.tar.gz
apk-tools-b8c44536ca911418fee1c9ab4eecbb913a1ca852.tar.bz2
apk-tools-b8c44536ca911418fee1c9ab4eecbb913a1ca852.tar.xz
apk-tools-b8c44536ca911418fee1c9ab4eecbb913a1ca852.zip
solver: rewrite as deductive solver -- core features
Implementing basic dependency handling, install_if and awareness of pinning.
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)