mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-19 18:00:23 +08:00
nasmlib: Add list_reverse helper
There is no way to make it as a helper function for a while, we need to unify list processing in general (ie to use abstract list type). Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
parent
87225da76d
commit
396b5dfe95
13
nasmlib.h
13
nasmlib.h
@ -258,6 +258,19 @@ void standard_extension(char *inname, char *outname, char *extension);
|
||||
#define list_last(pos, head) \
|
||||
for (pos = head; pos && pos->next; pos = pos->next) \
|
||||
;
|
||||
#define list_reverse(head, prev, next) \
|
||||
do { \
|
||||
if (!head || !head->next) \
|
||||
break; \
|
||||
prev = NULL; \
|
||||
while (head) { \
|
||||
next = head->next; \
|
||||
head->next = prev; \
|
||||
prev = head; \
|
||||
head = next; \
|
||||
} \
|
||||
head = prev; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Power of 2 align helpers
|
||||
|
Loading…
x
Reference in New Issue
Block a user