#ifndef UTIL_H_ #define UTIL_H_ #include #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define min(x, y) ({ \ typeof(x) _x = (x); \ typeof(y) _y = (y); \ _x < _y ? _x : _y; \ }) #define max(x, y) ({ \ typeof(x) _x = (x); \ typeof(y) _y = (y); \ _x > _y ? _x : _y; \ }) #undef container_of #define container_of(p, type, member) ({ \ const typeof(((type *)0)->member) *__m = (p); \ (type *)((char *)__m - offsetof(type, member)); }) typedef _Bool bool; #endif /* UTIL_H_ */