Contents of /trunk/mkinitrd-magellan/klibc/usr/include/klibc/compiler.h
Parent Directory | Revision Log
Revision 1297 -
(show annotations)
(download)
Fri May 27 15:12:11 2011 UTC (12 years, 11 months ago) by niro
File MIME type: text/plain
File size: 4221 byte(s)
Fri May 27 15:12:11 2011 UTC (12 years, 11 months ago) by niro
File MIME type: text/plain
File size: 4221 byte(s)
-updated to klibc-1.5.22 with mntproc definitions patch included
1 | /* |
2 | * klibc/compiler.h |
3 | * |
4 | * Various compiler features |
5 | */ |
6 | |
7 | #ifndef _KLIBC_COMPILER_H |
8 | #define _KLIBC_COMPILER_H |
9 | |
10 | /* Specific calling conventions */ |
11 | /* __cdecl is used when we want varadic and non-varadic functions to have |
12 | the same binary calling convention. */ |
13 | #ifdef __i386__ |
14 | # ifdef __GNUC__ |
15 | # define __cdecl __attribute__((cdecl,regparm(0))) |
16 | # else |
17 | /* Most other C compilers have __cdecl as a keyword */ |
18 | # endif |
19 | #else |
20 | # define __cdecl /* Meaningless on non-i386 */ |
21 | #endif |
22 | |
23 | /* |
24 | * How to declare a function which should be inlined or instantiated locally |
25 | */ |
26 | #ifdef __GNUC__ |
27 | # ifdef __GNUC_STDC_INLINE__ |
28 | # define __static_inline static __inline__ __attribute__((__gnu_inline__)) |
29 | # else |
30 | # define __static_inline static __inline__ |
31 | # endif |
32 | #else |
33 | # define __static_inline inline /* Just hope this works... */ |
34 | #endif |
35 | |
36 | /* |
37 | * How to declare a function which should be inlined or have a call to |
38 | * an external module |
39 | */ |
40 | #ifdef __GNUC__ |
41 | # ifdef __GNUC_STDC_INLINE__ |
42 | # define __extern_inline extern __inline__ __attribute__((__gnu_inline__)) |
43 | # else |
44 | # define __extern_inline extern __inline__ |
45 | # endif |
46 | #else |
47 | # define __extern_inline inline /* Just hope this works... */ |
48 | #endif |
49 | |
50 | /* How to declare a function that *must* be inlined */ |
51 | /* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */ |
52 | #ifdef __GNUC__ |
53 | # if __GNUC__ >= 3 |
54 | # define __must_inline __extern_inline __attribute__((__always_inline__)) |
55 | # else |
56 | # define __must_inline extern __inline__ |
57 | # endif |
58 | #else |
59 | # define __must_inline inline /* Just hope this works... */ |
60 | #endif |
61 | |
62 | /* How to declare a function that does not return */ |
63 | #ifdef __GNUC__ |
64 | # define __noreturn void __attribute__((noreturn)) |
65 | #else |
66 | # define __noreturn void |
67 | #endif |
68 | |
69 | /* "const" function: |
70 | |
71 | Many functions do not examine any values except their arguments, |
72 | and have no effects except the return value. Basically this is |
73 | just slightly more strict class than the `pure' attribute above, |
74 | since function is not allowed to read global memory. |
75 | |
76 | Note that a function that has pointer arguments and examines the |
77 | data pointed to must _not_ be declared `const'. Likewise, a |
78 | function that calls a non-`const' function usually must not be |
79 | `const'. It does not make sense for a `const' function to return |
80 | `void'. |
81 | */ |
82 | #ifdef __GNUC__ |
83 | # define __constfunc __attribute__((const)) |
84 | #else |
85 | # define __constfunc |
86 | #endif |
87 | #undef __attribute_const__ |
88 | #define __attribute_const__ __constfunc |
89 | |
90 | /* "pure" function: |
91 | |
92 | Many functions have no effects except the return value and their |
93 | return value depends only on the parameters and/or global |
94 | variables. Such a function can be subject to common subexpression |
95 | elimination and loop optimization just as an arithmetic operator |
96 | would be. These functions should be declared with the attribute |
97 | `pure'. |
98 | */ |
99 | #ifdef __GNUC__ |
100 | # define __purefunc __attribute__((pure)) |
101 | #else |
102 | # define __purefunc |
103 | #endif |
104 | #undef __attribute_pure__ |
105 | #define __attribute_pure__ __purefunc |
106 | |
107 | /* Format attribute */ |
108 | #ifdef __GNUC__ |
109 | # define __formatfunc(t,f,a) __attribute__((format(t,f,a))) |
110 | #else |
111 | # define __formatfunc(t,f,a) |
112 | #endif |
113 | |
114 | /* malloc() function (returns unaliased pointer) */ |
115 | #if defined(__GNUC__) && (__GNUC__ >= 3) |
116 | # define __mallocfunc __attribute__((malloc)) |
117 | #else |
118 | # define __mallocfunc |
119 | #endif |
120 | |
121 | /* likely/unlikely */ |
122 | #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) |
123 | # define __likely(x) __builtin_expect(!!(x), 1) |
124 | # define __unlikely(x) __builtin_expect(!!(x), 0) |
125 | #else |
126 | # define __likely(x) (!!(x)) |
127 | # define __unlikely(x) (!!(x)) |
128 | #endif |
129 | |
130 | /* Possibly unused function */ |
131 | #ifdef __GNUC__ |
132 | # define __unusedfunc __attribute__((unused)) |
133 | #else |
134 | # define __unusedfunc |
135 | #endif |
136 | |
137 | /* It's all user space... */ |
138 | #define __user |
139 | |
140 | /* The bitwise attribute: disallow arithmetric operations */ |
141 | #ifdef __CHECKER__ /* sparse only */ |
142 | # define __bitwise __attribute__((bitwise)) |
143 | #else |
144 | # define __bitwise |
145 | #endif |
146 | |
147 | /* Shut up unused warnings */ |
148 | #ifdef __GNUC__ |
149 | # define __attribute_used__ __attribute__((used)) |
150 | #else |
151 | # define __attribute_used__ |
152 | #endif |
153 | |
154 | /* Compiler pragma to make an alias symbol */ |
155 | #define __ALIAS(__t, __f, __p, __a) \ |
156 | __t __f __p __attribute__((weak, alias(#__a))); |
157 | |
158 | #endif |