3 * By Daniel Borkmann <daniel@netyack.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
12 # define likely(x) __builtin_expect(!!(x), 1)
15 # define unlikely(x) __builtin_expect(!!(x), 0)
18 # define __deprecated /* unimplemented */
21 # define unreachable() do { } while (1)
24 # define barrier() __sync_synchronize()
27 # define bug() __builtin_trap()
29 #ifndef mark_unreachable
30 # define mark_unreachable() __builtin_unreachable()
33 # define is_type(x, type) __builtin_types_compatible_p(typeof(x), (type))
36 # define same_type(x, y) __builtin_types_compatible_p(typeof(x), typeof(y))
39 # define __read_mostly __attribute__((__section__(".data.read_mostly")))
42 # define __must_check /* unimplemented */
45 # define __used /* unimplemented */
47 #ifndef __maybe_unused
48 # define __maybe_unused /* unimplemented */
50 #ifndef __always_unused
51 # define __always_unused /* unimplemented */
54 # define noinline __attribute__((noinline))
56 #ifndef __always_inline
57 # define __always_inline inline
60 * Protected visibility is like default visibility except that it indicates
61 * that references within the defining module will bind to the definition
62 * in that module. That is, the declared entity cannot be overridden by
66 # define __protected __attribute__((visibility("protected")))
69 * Hidden visibility indicates that the entity declared will have a new form
70 * of linkage, which we'll call "hidden linkage". Two declarations of an
71 * object with hidden linkage refer to the same object if they are in the
75 # define __hidden __attribute__((visibility("hidden")))
78 * Internal visibility is like hidden visibility, but with additional
79 * processor specific semantics. Unless otherwise specified by the psABI,
80 * GCC defines internal visibility to mean that a function is never called
81 * from another module. Compare this with hidden functions which, while they
82 * cannot be referenced directly by other modules, can be referenced
83 * indirectly via function pointers. By indicating that a function cannot be
84 * called from outside the module, GCC may for instance omit the load of a
85 * PIC register since it is known that the calling function loaded the
89 # define __internal __attribute__((visibility("internal")))
94 typeof (a) _a = (a); \
95 typeof (b) _b = (b); \
102 typeof (a) _a = (a); \
103 typeof (b) _b = (b); \
108 # define offsetof(type, member) ((size_t) &((type *) 0)->member)
111 * Casts a member of a structure out to the containing structure.
114 # define container_of(ptr, type, member) \
116 const typeof(((type *) 0)->member) * __mptr = (ptr); \
117 (type *) ((char *) __mptr - offsetof(type, member)); \
121 #endif /* COMPILER_H */