Mercurial > MadButterfly
comparison src/tools.h @ 93:c3c41f88e776
-
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 24 Aug 2008 01:18:58 +0800 |
parents | 9ab15ebc9061 |
children | ca94493b75bb |
comparison
equal
deleted
inserted
replaced
92:3f619ae03678 | 93:c3c41f88e776 |
---|---|
43 do { \ | 43 do { \ |
44 (follow)->field = (elm)->field; \ | 44 (follow)->field = (elm)->field; \ |
45 (elm)->field = follow; \ | 45 (elm)->field = follow; \ |
46 } while(0) | 46 } while(0) |
47 #define STAILQ_REMOVE(q, type, field, elm) \ | 47 #define STAILQ_REMOVE(q, type, field, elm) \ |
48 do { \ | 48 ~ do { \ |
49 if((elm) == (q).head) { \ | 49 if((elm) == (q).head) { \ |
50 (q).head = (elm)->field; \ | 50 (q).head = (elm)->field; \ |
51 if((q).head == NULL) \ | 51 if((q).head == NULL) \ |
52 (q).tail = NULL; \ | 52 (q).tail = NULL; \ |
53 } else { \ | 53 } else { \ |
66 | 66 |
67 #define O_ALLOC(type) ((type *)malloc(sizeof(type))) | 67 #define O_ALLOC(type) ((type *)malloc(sizeof(type))) |
68 | 68 |
69 #define OFFSET(type, mem) (((void *)&((type *)NULL)->mem) - NULL) | 69 #define OFFSET(type, mem) (((void *)&((type *)NULL)->mem) - NULL) |
70 #define MEM2OBJ(var, type, mem) ((type *)((void *)var - OFFSET(type, mem))) | 70 #define MEM2OBJ(var, type, mem) ((type *)((void *)var - OFFSET(type, mem))) |
71 #define OFF2TYPE(obj, off, type) (*(type *)((void *)(obj) + (off))) | |
71 | 72 |
72 #endif /* __TOOLS_H_ */ | 73 #endif /* __TOOLS_H_ */ |