From 396b5dfe954fc6f1e1e9be5ed2def73ee1159605 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Wed, 13 Apr 2011 11:25:49 +0400 Subject: [PATCH] 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 --- nasmlib.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nasmlib.h b/nasmlib.h index 4d67e8b6..cddb6b94 100644 --- a/nasmlib.h +++ b/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 -- 2.11.4.GIT