diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2013-11-14 03:58:18 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2013-11-20 03:26:30 +0400 |
commit | d29fe0f2c667085ec403c4856efca8686c52ceef (patch) | |
tree | 3d35f921a2d785f225aafdeaa5db8e9a9f22a1f8 | |
parent | b73967e9a0c1178bdb83dcf115fe7b07c37fdc94 (diff) |
src: make queue.h c++ compatible
This is a cherry-pick of commit joyent/libuv@0520464.
-rw-r--r-- | src/queue.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/queue.h b/src/queue.h index fa42e7f1cf7..075d37fd0a1 100644 --- a/src/queue.h +++ b/src/queue.h @@ -19,20 +19,20 @@ typedef void *QUEUE[2]; /* Private macros. */ -#define QUEUE_NEXT(q) ((*(q))[0]) -#define QUEUE_PREV(q) ((*(q))[1]) -#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT((QUEUE *) QUEUE_PREV(q))) -#define QUEUE_NEXT_PREV(q) (QUEUE_PREV((QUEUE *) QUEUE_NEXT(q))) +#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) +#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1])) +#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) +#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) /* Public macros. */ #define QUEUE_DATA(ptr, type, field) \ - ((type *) ((char *) (ptr) - ((long) &((type *) 0)->field))) + ((type *) ((char *) (ptr) - ((char *) &((type *) 0)->field))) #define QUEUE_FOREACH(q, h) \ - for ((q) = (QUEUE *) (*(h))[0]; (q) != (h); (q) = (QUEUE *) (*(q))[0]) + for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) #define QUEUE_EMPTY(q) \ - (QUEUE_NEXT(q) == (q)) + ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) #define QUEUE_HEAD(q) \ (QUEUE_NEXT(q)) |