diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/birdlib.h | 6 | ||||
-rw-r--r-- | lib/slists.h | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/birdlib.h b/lib/birdlib.h index 04fb7fed..c49c5b99 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -33,6 +33,12 @@ #define ABS(a) ((a)>=0 ? (a) : -(a)) #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a))) +#define BIT32_VAL(p) (((u32) 1) << ((p) % 32)) +#define BIT32_TEST(b,p) ((b)[(p)/32] & BIT32_VAL(p)) +#define BIT32_SET(b,p) ((b)[(p)/32] |= BIT32_VAL(p)) +#define BIT32_CLR(b,p) ((b)[(p)/32] &= ~BIT32_VAL(p)) +#define BIT32_ZERO(b,l) memset((b), 0, (l)/8) + #ifndef NULL #define NULL ((void *) 0) #endif diff --git a/lib/slists.h b/lib/slists.h index 2334e36a..d98d02d2 100644 --- a/lib/slists.h +++ b/lib/slists.h @@ -68,10 +68,12 @@ typedef struct siterator { #define SNODE (snode *) #define SHEAD(list) ((void *)((list).head)) #define STAIL(list) ((void *)((list).tail)) -#define WALK_SLIST(n,list) for(n=SHEAD(list);(SNODE (n))->next; \ - n=(void *)((SNODE (n))->next)) +#define SNODE_NEXT(n) ((void *)((SNODE (n))->next)) +#define SNODE_VALID(n) ((SNODE (n))->next) + +#define WALK_SLIST(n,list) for(n=SHEAD(list); SNODE_VALID(n); n=SNODE_NEXT(n)) #define WALK_SLIST_DELSAFE(n,nxt,list) \ - for(n=SHEAD(list); nxt=(void *)((SNODE (n))->next); n=(void *) nxt) + for(n=SHEAD(list); nxt=SNODE_NEXT(n); n=(void *) nxt) #define EMPTY_SLIST(list) (!(list).head->next) void s_add_tail(slist *, snode *); |