]> Pileus Git - wmpus/blob - util.h
Initial code for win32
[wmpus] / util.h
1 #define MAX(a,b) ((a) > (b) ? (a) : (b))
2 #define MIN(a,b) ((a) < (b) ? (a) : (b))
3
4 #define new0(type) (calloc(1, sizeof(type)))
5
6 #define countof(x) (sizeof(x)/sizeof((x)[0]))
7
8 #define map_getg(map, test) ({ \
9         int i; \
10         for (i = 0; i < countof(map) && !(test); i++); \
11         i < countof(map) ? &map[i] : NULL ; \
12 })
13
14 #define map_get(m,k)    map_getg(m,k==*((typeof(k)*)&m[i]))
15 #define map_getr(m,k)   map_getg(m,k==*(((typeof(k)*)&m[i+1])-1))
16 #define map_getk(m,k,a) map_getg(m,k==m[i].a)
17