summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/util/dlinklist.h16
-rw-r--r--source3/lib/ldb/include/dlinklist.h16
-rw-r--r--source4/lib/ldb/include/dlinklist.h16
3 files changed, 48 insertions, 0 deletions
diff --git a/lib/util/dlinklist.h b/lib/util/dlinklist.h
index 693b43dd27..c1f01e616a 100644
--- a/lib/util/dlinklist.h
+++ b/lib/util/dlinklist.h
@@ -51,6 +51,22 @@ do { \
if ((p) != (list)) (p)->next = (p)->prev = NULL; \
} while (0)
+#define DLIST_HEAD(p, result_head) \
+do { \
+ (result_head) = (p); \
+ while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \
+} while(0)
+
+/* return the last element in the list */
+#define DLIST_TAIL(list, result_tail) \
+do { \
+ (result_tail) = (list); \
+ while ((result_tail) && (result_tail)->next) (result_tail) = (result_tail)->next; \
+} while (0);
+
+/* return the previous element in the list. */
+#define DLIST_PREV(p) ((p)?(p)->prev:NULL)
+
/* promote an element to the top of the list */
#define DLIST_PROMOTE(list, p) \
do { \
diff --git a/source3/lib/ldb/include/dlinklist.h b/source3/lib/ldb/include/dlinklist.h
index 62f885dd30..0bd80a79df 100644
--- a/source3/lib/ldb/include/dlinklist.h
+++ b/source3/lib/ldb/include/dlinklist.h
@@ -51,6 +51,22 @@ do { \
if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
} while (0)
+#define DLIST_HEAD(p, result_head) \
+do { \
+ (result_head) = (p); \
+ while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \
+} while(0)
+
+/* return the last element in the list */
+#define DLIST_TAIL(list, result_tail) \
+do { \
+ (result_tail) = (list); \
+ while ((result_tail) && (result_tail)->next) (result_tail) = (result_tail)->next; \
+} while (0);
+
+/* return the previous element in the list. */
+#define DLIST_PREV(p) ((p)?(p)->prev:NULL)
+
/* promote an element to the top of the list */
#define DLIST_PROMOTE(list, p) \
do { \
diff --git a/source4/lib/ldb/include/dlinklist.h b/source4/lib/ldb/include/dlinklist.h
index 62f885dd30..0bd80a79df 100644
--- a/source4/lib/ldb/include/dlinklist.h
+++ b/source4/lib/ldb/include/dlinklist.h
@@ -51,6 +51,22 @@ do { \
if ((p) && ((p) != (list))) (p)->next = (p)->prev = NULL; \
} while (0)
+#define DLIST_HEAD(p, result_head) \
+do { \
+ (result_head) = (p); \
+ while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \
+} while(0)
+
+/* return the last element in the list */
+#define DLIST_TAIL(list, result_tail) \
+do { \
+ (result_tail) = (list); \
+ while ((result_tail) && (result_tail)->next) (result_tail) = (result_tail)->next; \
+} while (0);
+
+/* return the previous element in the list. */
+#define DLIST_PREV(p) ((p)?(p)->prev:NULL)
+
/* promote an element to the top of the list */
#define DLIST_PROMOTE(list, p) \
do { \