aboutsummaryrefslogtreecommitdiffstats
path: root/util.h
blob: 93fd2959ee0042ff6fdb3aca9c210a3701232a2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
void err(const char *msg);

#define NEW(x) ((x) = xalloc(sizeof(*(x))))
void *xalloc(size_t sz);
void *xcalloc(size_t a, size_t b);

#ifdef __GNUC__
#define barrier() asm volatile("" ::: "memory")
#else
#define barrier() do {} while(0)
#endif