21#ifndef LELY_UTIL_UTIL_H_
22#define LELY_UTIL_UTIL_H_
30#define ABS(a) ((a) < 0 ? -(a) : (a))
40#if defined(__clang__) || defined(__GNUC__)
41#define ALIGN(x, a) ALIGN_MASK((x), (__typeof__(x))(a)-1)
43#define ALIGN(x, a) ALIGN_MASK((x), (a)-1)
48#define ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask))
57#define MIN(a, b) ((a) < (b) ? (a) : (b))
65#define MAX(a, b) ((a) < (b) ? (b) : (a))
70#define countof(a) (sizeof(a) / sizeof(0 [a]))
78#define powerof2(x) (!((x) & ((x)-1)))
92#if defined(__clang__) || defined(__GNUC__)
93#define structof(ptr, type, member) \
95 const __typeof__(((type *)NULL)->member) *_tmp_ = (ptr); \
96 ((type *)((char *)(_tmp_) - offsetof(type, member))); \
99#define structof(ptr, type, member) \
100 ((type *)((char *)(ptr) - offsetof(type, member)))
This header file is part of the Lely libraries; it contains the compiler feature definitions.
This header file is part of the C11 and POSIX compatibility library; it includes <stddef....