diff options
author | dzwdz | 2024-07-14 23:20:35 +0200 |
---|---|---|
committer | dzwdz | 2024-07-15 00:12:54 +0200 |
commit | fb7949549435e735acef3674b10f429fa4c4789e (patch) | |
tree | e9822bd08a806897e042c48a6279db5ad14cc175 /man/queue.9 | |
parent | ad99cc4245dd2dfda37e40146609e09cf2e409c6 (diff) |
kernel: new queue abstraction
The postqueue functions remain as-is, as that's a more "specialized" interface.
They're mostly wrappers around queue.h, though.
Diffstat (limited to 'man/queue.9')
-rw-r--r-- | man/queue.9 | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/man/queue.9 b/man/queue.9 new file mode 100644 index 0000000..d53adf8 --- /dev/null +++ b/man/queue.9 @@ -0,0 +1,43 @@ +.Dd July 14, 2024 +.Dt QUEUE 9 +.Os Camellia +.Sh NAME +.Nm QUEUE_INIT , +.Nm QUEUE_APPEND , +.Nm QUEUE_POP +.Nd macros for intrusive linked lists +.Sh SYNOPSIS +.In kernel/queue.h +.Bd -literal +struct YourNode { + ... + struct YourNode *NAME_next; +}; +struct YourHead { + struct YourNode *head, **slot; +}; +.Ed +.Fn QUEUE_INIT "YourHead *q" +.Fn QUEUE_APPEND "YourHead *q" "NAME" "YourNode *el" +.Ft YourNode * +.Fn QUEUE_POP "YourHead *q" "NAME" +.Sh DESCRIPTION +These macros, inspired by BSD's +.In sys/queue.h , +operate on intrusive linked lists. +Currently, only +.Em queues +\(em singly-linked lists with O(1) insertions at the end \(em +are supported. +.Pp +The linked list internals are intentionally exposed, as they're also meant +to be used by e.g. memory management code for integrity checks. +It's fine to modify them directly. +.Sh RATIONALE +The macros are a bit ugly, but they prevent code duplication, +and using the same implementation everywhere probably makes bugs less likely. +.Pp +I've considered just using +.In sys/queue.h , +which has the benefit of being more familiar to other programmers, +but I dislike how it hides the list internals from the programmer. |