diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-08-05 22:20:36 +0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-08-05 22:20:36 +0300 |
commit | b5a306ef73f9c31499f2d97f8b9d3db514b56a09 (patch) | |
tree | 9f1970d84dc720b7bc86824242d95cdedee784e1 /src/basic/list.h | |
parent | 8dbf626535136b6fe6e1cf7d4ff251b2f505087c (diff) | |
parent | 9b57d9aee48e78bb591baecea1c3dbafd974759f (diff) |
Merge pull request #877 from crawford/dhcp-private-options-v4
networkd: save private-zone DHCP options
Diffstat (limited to 'src/basic/list.h')
-rw-r--r-- | src/basic/list.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/basic/list.h b/src/basic/list.h index 2939216adb..760abcdab3 100644 --- a/src/basic/list.h +++ b/src/basic/list.h @@ -123,6 +123,32 @@ } \ } while(false) +/* Insert an item before another one (a = where, b = what) */ +#define LIST_INSERT_BEFORE(name,head,a,b) \ + do { \ + typeof(*(head)) **_head = &(head), *_a = (a), *_b = (b); \ + assert(_b); \ + if (!_a) { \ + if (!*_head) { \ + _b->name##_next = NULL; \ + _b->name##_prev = NULL; \ + *_head = _b; \ + } else { \ + typeof(*(head)) *_tail = (head); \ + while (_tail->name##_next) \ + _tail = _tail->name##_next; \ + _b->name##_next = NULL; \ + _b->name##_prev = _tail; \ + _tail->name##_next = _b; \ + } \ + } else { \ + if ((_b->name##_prev = _a->name##_prev)) \ + _b->name##_prev->name##_next = _b; \ + _b->name##_next = _a; \ + _a->name##_prev = _b; \ + } \ + } while(false) + #define LIST_JUST_US(name,item) \ (!(item)->name##_prev && !(item)->name##_next) \ |