blob: dd31151c50a1288a62923a7e73ed85e075e8d0fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#ifndef UTIL_H_
#define UTIL_H_
#include <stddef.h>
#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_ */
|