]>
git.ipfire.org Git - thirdparty/systemd.git/blob - macro.h
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
9 #define __printf_attr(a,b) __attribute__ ((format (printf, a, b)))
10 #define __sentinel __attribute__ ((sentinel))
11 #define __noreturn __attribute__((noreturn))
12 #define __unused __attribute__ ((unused))
13 #define __destructor __attribute__ ((destructor))
14 #define __pure __attribute__ ((pure))
15 #define __const __attribute__ ((const))
16 #define __deprecated __attribute__ ((deprecated))
17 #define __packed __attribute__ ((packed))
18 #define __malloc __attribute__ ((malloc))
21 static inline size_t ALIGN(size_t l
) {
22 return ((l
+ sizeof(void*) - 1) & ~(sizeof(void*) - 1));
25 #define ELEMENTSOF(x) (sizeof(x)/sizeof((x)[0]))
41 #define CLAMP(x, low, high) \
44 typeof(low) _low = (low); \
45 typeof(high) _high = (high); \
46 ((_x > _high) ? _high : ((_x < _low) ? _low : _x)); \
51 #define assert_not_reached(t) assert(!(t))
53 #define assert_se(x) assert(x)
55 #define assert_cc(expr) \
64 #define PTR_TO_UINT(p) ((unsigned int) ((uintptr_t) (p)))
65 #define UINT_TO_PTR(u) ((void*) ((uintptr_t) (u)))
67 #define PTR_TO_UINT32(p) ((uint32_t) ((uintptr_t) (p)))
68 #define UINT32_TO_PTR(u) ((void*) ((uintptr_t) (u)))
70 #define PTR_TO_INT(p) ((int) ((intptr_t) (p)))
71 #define INT_TO_PTR(u) ((void*) ((intptr_t) (u)))
73 #define TO_INT32(p) ((int32_t) ((intptr_t) (p)))
74 #define INT32_TO_PTR(u) ((void*) ((intptr_t) (u)))
76 #define memzero(x,l) (memset((x), 0, (l)))
77 #define zero(x) (memzero(&(x), sizeof(x)))
79 #define char_array_0(x) x[sizeof(x)-1] = 0;