[libc-commits] [libc] [libc] Provide sys/queue.h (PR #78081)
Petr Hosek via libc-commits
libc-commits at lists.llvm.org
Wed Jan 17 09:57:08 PST 2024
================
@@ -96,27 +148,61 @@
struct type *next; \
}
+#define STAILQ_CLASS_ENTRY(type) \
+ struct { \
+ class type *next; \
+ }
+
// Singly-linked tail queue access methods.
#define STAILQ_EMPTY(head) ((head)->first == NULL)
#define STAILQ_FIRST(head) ((head)->first)
+#define STAILQ_LAST(head, type, field) \
+ STAILQ_EMPTY(head) \
+ ? NULL \
+ : (QUEUE_TYPEOF(type) *)((char *)(head)->last - \
+ offsetof(QUEUE_TYPEOF(type), field))
#define STAILQ_NEXT(elem, field) ((elem)->field.next)
#define STAILQ_FOREACH(var, head, field) \
for ((var) = STAILQ_FIRST(head); (var); (var) = STAILQ_NEXT(var, field))
+#define STAILQ_FOREACH_FROM(var, head, field) \
+ for ((var) = ((var) ? (var) : STAILQ_FIRST(head)); (var); \
+ (var) = STAILQ_NEXT(var, field))
+
#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
for ((var) = STAILQ_FIRST(head); \
(var) && ((tvar) = STAILQ_NEXT(var, field), 1); (var) = (tvar))
+#define STAILQ_FOREACH_SAFE(var, head, field, tvar) \
+ for ((var) = ((var) ? (var) : STAILQ_FIRST(head)); \
+ (var) && ((tvar) = STAILQ_NEXT(var, field), 1); (var) = (tvar))
----------------
petrhosek wrote:
Done.
https://github.com/llvm/llvm-project/pull/78081
More information about the libc-commits
mailing list