Annotation of /trunk/mkinitrd-magellan/klibc/usr/include/klibc/compiler.h
Parent Directory | Revision Log
Revision 815 -
(hide annotations)
(download)
Fri Apr 24 18:32:46 2009 UTC (15 years ago) by niro
File MIME type: text/plain
File size: 3523 byte(s)
Fri Apr 24 18:32:46 2009 UTC (15 years ago) by niro
File MIME type: text/plain
File size: 3523 byte(s)
-updated to klibc-1.5.15
1 | niro | 532 | /* |
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 | /* How to declare a function that *must* be inlined */ | ||
24 | niro | 815 | /* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */ |
25 | niro | 532 | #ifdef __GNUC__ |
26 | # if __GNUC__ >= 3 | ||
27 | niro | 815 | # define __must_inline extern __inline__ __attribute__((always_inline)) |
28 | niro | 532 | # else |
29 | # define __must_inline extern __inline__ | ||
30 | # endif | ||
31 | #else | ||
32 | # define __must_inline inline /* Just hope this works... */ | ||
33 | #endif | ||
34 | |||
35 | /* How to declare a function that does not return */ | ||
36 | #ifdef __GNUC__ | ||
37 | # define __noreturn void __attribute__((noreturn)) | ||
38 | #else | ||
39 | # define __noreturn void | ||
40 | #endif | ||
41 | |||
42 | /* "const" function: | ||
43 | |||
44 | Many functions do not examine any values except their arguments, | ||
45 | and have no effects except the return value. Basically this is | ||
46 | just slightly more strict class than the `pure' attribute above, | ||
47 | since function is not allowed to read global memory. | ||
48 | |||
49 | Note that a function that has pointer arguments and examines the | ||
50 | data pointed to must _not_ be declared `const'. Likewise, a | ||
51 | function that calls a non-`const' function usually must not be | ||
52 | `const'. It does not make sense for a `const' function to return | ||
53 | `void'. | ||
54 | */ | ||
55 | #ifdef __GNUC__ | ||
56 | # define __constfunc __attribute__((const)) | ||
57 | #else | ||
58 | # define __constfunc | ||
59 | #endif | ||
60 | #undef __attribute_const__ | ||
61 | #define __attribute_const__ __constfunc | ||
62 | |||
63 | /* "pure" function: | ||
64 | |||
65 | Many functions have no effects except the return value and their | ||
66 | return value depends only on the parameters and/or global | ||
67 | variables. Such a function can be subject to common subexpression | ||
68 | elimination and loop optimization just as an arithmetic operator | ||
69 | would be. These functions should be declared with the attribute | ||
70 | `pure'. | ||
71 | */ | ||
72 | #ifdef __GNUC__ | ||
73 | # define __purefunc __attribute__((pure)) | ||
74 | #else | ||
75 | # define __purefunc | ||
76 | #endif | ||
77 | #undef __attribute_pure__ | ||
78 | #define __attribute_pure__ __purefunc | ||
79 | |||
80 | /* Format attribute */ | ||
81 | #ifdef __GNUC__ | ||
82 | # define __formatfunc(t,f,a) __attribute__((format(t,f,a))) | ||
83 | #else | ||
84 | # define __formatfunc(t,f,a) | ||
85 | #endif | ||
86 | |||
87 | /* malloc() function (returns unaliased pointer) */ | ||
88 | #if defined(__GNUC__) && (__GNUC__ >= 3) | ||
89 | # define __mallocfunc __attribute__((malloc)) | ||
90 | #else | ||
91 | # define __mallocfunc | ||
92 | #endif | ||
93 | |||
94 | /* likely/unlikely */ | ||
95 | #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) | ||
96 | niro | 815 | # define __likely(x) __builtin_expect(!!(x), 1) |
97 | # define __unlikely(x) __builtin_expect(!!(x), 0) | ||
98 | niro | 532 | #else |
99 | niro | 815 | # define __likely(x) (!!(x)) |
100 | # define __unlikely(x) (!!(x)) | ||
101 | niro | 532 | #endif |
102 | |||
103 | /* Possibly unused function */ | ||
104 | #ifdef __GNUC__ | ||
105 | # define __unusedfunc __attribute__((unused)) | ||
106 | #else | ||
107 | # define __unusedfunc | ||
108 | #endif | ||
109 | |||
110 | /* It's all user space... */ | ||
111 | #define __user | ||
112 | |||
113 | /* The bitwise attribute: disallow arithmetric operations */ | ||
114 | #ifdef __CHECKER__ /* sparse only */ | ||
115 | # define __bitwise __attribute__((bitwise)) | ||
116 | #else | ||
117 | # define __bitwise | ||
118 | #endif | ||
119 | |||
120 | /* Shut up unused warnings */ | ||
121 | #ifdef __GNUC__ | ||
122 | # define __attribute_used__ __attribute__((used)) | ||
123 | #else | ||
124 | # define __attribute_used__ | ||
125 | #endif | ||
126 | |||
127 | /* Compiler pragma to make an alias symbol */ | ||
128 | #define __ALIAS(__t, __f, __p, __a) \ | ||
129 | __t __f __p __attribute__((weak, alias(#__a))); | ||
130 | |||
131 | #endif |