2 * transsip - the telephony network
3 * By Daniel Borkmann <daniel@transsip.org>
4 * Copyright 2011 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
13 # define likely(x) __builtin_expect(!!(x), 1)
16 # define unlikely(x) __builtin_expect(!!(x), 0)
19 # define __deprecated /* unimplemented */
22 # define unreachable() do { } while (1)
25 # define barrier() __sync_synchronize()
28 # define bug() __builtin_trap()
30 #ifndef mark_unreachable
31 # define mark_unreachable() __builtin_unreachable()
34 # define is_type(x, type) __builtin_types_compatible_p(typeof(x), (type))
37 # define same_type(x, y) __builtin_types_compatible_p(typeof(x), typeof(y))
40 # define __read_mostly __attribute__((__section__(".data.read_mostly")))
43 # define __must_check /* unimplemented */
46 # define __used /* unimplemented */
48 #ifndef __maybe_unused
49 # define __maybe_unused /* unimplemented */
51 #ifndef __always_unused
52 # define __always_unused /* unimplemented */
55 # define noinline __attribute__((noinline))
57 #ifndef __always_inline
58 # define __always_inline inline
61 * Protected visibility is like default visibility except that it indicates
62 * that references within the defining module will bind to the definition
63 * in that module. That is, the declared entity cannot be overridden by
67 # define __protected __attribute__((visibility("protected")))
70 * Hidden visibility indicates that the entity declared will have a new form
71 * of linkage, which we'll call "hidden linkage". Two declarations of an
72 * object with hidden linkage refer to the same object if they are in the
76 # define __hidden __attribute__((visibility("hidden")))
79 * Internal visibility is like hidden visibility, but with additional
80 * processor specific semantics. Unless otherwise specified by the psABI,
81 * GCC defines internal visibility to mean that a function is never called
82 * from another module. Compare this with hidden functions which, while they
83 * cannot be referenced directly by other modules, can be referenced
84 * indirectly via function pointers. By indicating that a function cannot be
85 * called from outside the module, GCC may for instance omit the load of a
86 * PIC register since it is known that the calling function loaded the
90 # define __internal __attribute__((visibility("internal")))
95 typeof (a) _a = (a); \
96 typeof (b) _b = (b); \
103 typeof (a) _a = (a); \
104 typeof (b) _b = (b); \
109 # define offsetof(type, member) ((size_t) &((type *) 0)->member)
112 * Casts a member of a structure out to the containing structure.
115 # define container_of(ptr, type, member) \
117 const typeof(((type *) 0)->member) * __mptr = (ptr); \
118 (type *) ((char *) __mptr - offsetof(type, member)); \
122 #endif /* COMPILER_H */