1 | #ifndef _CDEFS_H_ |
---|
2 | #define _CDEFS_H_ |
---|
3 | |
---|
4 | #include <stddef.h> |
---|
5 | |
---|
6 | /* |
---|
7 | * Taken from FreeBSD 9. |
---|
8 | */ |
---|
9 | |
---|
10 | #if defined(__cplusplus) |
---|
11 | #define __BEGIN_DECLS extern "C" { |
---|
12 | #define __END_DECLS } |
---|
13 | #else |
---|
14 | #define __BEGIN_DECLS |
---|
15 | #define __END_DECLS |
---|
16 | #endif |
---|
17 | |
---|
18 | /* |
---|
19 | * Macro to test if we're using a specific version of gcc or later. |
---|
20 | */ |
---|
21 | #if defined(__GNUC__) && !defined(__INTEL_COMPILER) |
---|
22 | #define __GNUC_PREREQ__(ma, mi) \ |
---|
23 | (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) |
---|
24 | #else |
---|
25 | #define __GNUC_PREREQ__(ma, mi) 0 |
---|
26 | #endif |
---|
27 | |
---|
28 | /* |
---|
29 | * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h> |
---|
30 | * require it. |
---|
31 | */ |
---|
32 | #if __GNUC_PREREQ__(4, 1) |
---|
33 | #define __offsetof(type, field) __builtin_offsetof(type, field) |
---|
34 | #else |
---|
35 | #ifndef __cplusplus |
---|
36 | #define __offsetof(type, field) ((size_t)(&((type *)0)->field)) |
---|
37 | #else |
---|
38 | #define __offsetof(type, field) \ |
---|
39 | (__offsetof__ (reinterpret_cast <size_t> \ |
---|
40 | (&reinterpret_cast <const volatile char &> \ |
---|
41 | (static_cast<type *> (0)->field)))) |
---|
42 | #endif |
---|
43 | #endif |
---|
44 | #define __rangeof(type, start, end) \ |
---|
45 | (__offsetof(type, end) - __offsetof(type, start)) |
---|
46 | |
---|
47 | /* |
---|
48 | * Hack. Have to put this somewhere. |
---|
49 | */ |
---|
50 | typedef int gid_t; |
---|
51 | typedef int uid_t; |
---|
52 | |
---|
53 | /* Macros for counting and rounding. */ |
---|
54 | #ifndef howmany |
---|
55 | #define howmany(x, y) (((x)+((y)-1))/(y)) |
---|
56 | #endif |
---|
57 | #define rounddown(x, y) (((x)/(y))*(y)) |
---|
58 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */ |
---|
59 | #define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */ |
---|
60 | #define powerof2(x) ((((x)-1)&(x))==0) |
---|
61 | |
---|
62 | #define S_ISSOCK(_m) (0) |
---|
63 | |
---|
64 | #endif |
---|