1 | /* Copyright (C) 1992-2001, 2002 Free Software Foundation, Inc.
|
---|
2 | This file is part of the GNU C Library.
|
---|
3 |
|
---|
4 | The GNU C Library is free software; you can redistribute it and/or
|
---|
5 | modify it under the terms of the GNU Lesser General Public
|
---|
6 | License as published by the Free Software Foundation; either
|
---|
7 | version 2.1 of the License, or (at your option) any later version.
|
---|
8 |
|
---|
9 | The GNU C Library is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
12 | Lesser General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU Lesser General Public
|
---|
15 | License along with the GNU C Library; if not, write to the Free
|
---|
16 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
17 | 02111-1307 USA. */
|
---|
18 |
|
---|
19 | #ifndef _SYS_CDEFS_H
|
---|
20 | #define _SYS_CDEFS_H 1
|
---|
21 |
|
---|
22 | /* We are almost always included from features.h. */
|
---|
23 | #ifndef _FEATURES_H
|
---|
24 | # include <features.h>
|
---|
25 | #endif
|
---|
26 |
|
---|
27 | /* The GNU libc does not support any K&R compilers or the traditional mode
|
---|
28 | of ISO C compilers anymore. Check for some of the combinations not
|
---|
29 | anymore supported. */
|
---|
30 | #if defined __GNUC__ && !defined __STDC__
|
---|
31 | # error "You need a ISO C conforming compiler to use the glibc headers"
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | /* Some user header file might have defined this before. */
|
---|
35 | #undef __P
|
---|
36 | #undef __PMT
|
---|
37 |
|
---|
38 | #ifdef __GNUC__
|
---|
39 |
|
---|
40 | /* GCC can always grok prototypes. For C++ programs we add throw()
|
---|
41 | to help it optimize the function calls. But this works only with
|
---|
42 | gcc 2.8.x and egcs. */
|
---|
43 | # if defined __cplusplus && __GNUC_PREREQ (2,8)
|
---|
44 | # define __THROW throw ()
|
---|
45 | # else
|
---|
46 | # define __THROW
|
---|
47 | # endif
|
---|
48 | # define __P(args) args __THROW
|
---|
49 | /* This macro will be used for functions which might take C++ callback
|
---|
50 | functions. */
|
---|
51 | # define __PMT(args) args
|
---|
52 |
|
---|
53 | #else /* Not GCC. */
|
---|
54 |
|
---|
55 | # define __inline /* No inline functions. */
|
---|
56 |
|
---|
57 | # define __THROW
|
---|
58 | # define __P(args) args
|
---|
59 | # define __PMT(args) args
|
---|
60 |
|
---|
61 | # define __const const
|
---|
62 | # define __signed signed
|
---|
63 | # define __volatile volatile
|
---|
64 |
|
---|
65 | #endif /* GCC. */
|
---|
66 |
|
---|
67 | /* For these things, GCC behaves the ANSI way normally,
|
---|
68 | and the non-ANSI way under -traditional. */
|
---|
69 |
|
---|
70 | #define __CONCAT(x,y) x ## y
|
---|
71 | #define __STRING(x) #x
|
---|
72 |
|
---|
73 | /* This is not a typedef so `const __ptr_t' does the right thing. */
|
---|
74 | #define __ptr_t void *
|
---|
75 | #define __long_double_t long double
|
---|
76 |
|
---|
77 |
|
---|
78 | /* C++ needs to know that types and declarations are C, not C++. */
|
---|
79 | #ifdef __cplusplus
|
---|
80 | # define __BEGIN_DECLS extern "C" {
|
---|
81 | # define __END_DECLS }
|
---|
82 | #else
|
---|
83 | # define __BEGIN_DECLS
|
---|
84 | # define __END_DECLS
|
---|
85 | #endif
|
---|
86 |
|
---|
87 |
|
---|
88 | /* The standard library needs the functions from the ISO C90 standard
|
---|
89 | in the std namespace. At the same time we want to be safe for
|
---|
90 | future changes and we include the ISO C99 code in the non-standard
|
---|
91 | namespace __c99. The C++ wrapper header take case of adding the
|
---|
92 | definitions to the global namespace. */
|
---|
93 | #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
|
---|
94 | # define __BEGIN_NAMESPACE_STD namespace std {
|
---|
95 | # define __END_NAMESPACE_STD }
|
---|
96 | # define __USING_NAMESPACE_STD(name) using std::name;
|
---|
97 | # define __BEGIN_NAMESPACE_C99 namespace __c99 {
|
---|
98 | # define __END_NAMESPACE_C99 }
|
---|
99 | # define __USING_NAMESPACE_C99(name) using __c99::name;
|
---|
100 | #else
|
---|
101 | /* For compatibility we do not add the declarations into any
|
---|
102 | namespace. They will end up in the global namespace which is what
|
---|
103 | old code expects. */
|
---|
104 | # define __BEGIN_NAMESPACE_STD
|
---|
105 | # define __END_NAMESPACE_STD
|
---|
106 | # define __USING_NAMESPACE_STD(name)
|
---|
107 | # define __BEGIN_NAMESPACE_C99
|
---|
108 | # define __END_NAMESPACE_C99
|
---|
109 | # define __USING_NAMESPACE_C99(name)
|
---|
110 | #endif
|
---|
111 |
|
---|
112 |
|
---|
113 | /* Support for bounded pointers. */
|
---|
114 | #ifndef __BOUNDED_POINTERS__
|
---|
115 | # define __bounded /* nothing */
|
---|
116 | # define __unbounded /* nothing */
|
---|
117 | # define __ptrvalue /* nothing */
|
---|
118 | #endif
|
---|
119 |
|
---|
120 |
|
---|
121 | /* Support for flexible arrays. */
|
---|
122 | #if __GNUC_PREREQ (2,97)
|
---|
123 | /* GCC 2.97 supports C99 flexible array members. */
|
---|
124 | # define __flexarr []
|
---|
125 | #else
|
---|
126 | # ifdef __GNUC__
|
---|
127 | # define __flexarr [0]
|
---|
128 | # else
|
---|
129 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
---|
130 | # define __flexarr []
|
---|
131 | # else
|
---|
132 | /* Some other non-C99 compiler. Approximate with [1]. */
|
---|
133 | # define __flexarr [1]
|
---|
134 | # endif
|
---|
135 | # endif
|
---|
136 | #endif
|
---|
137 |
|
---|
138 |
|
---|
139 | /* __asm__ ("xyz") is used throughout the headers to rename functions
|
---|
140 | at the assembly language level. This is wrapped by the __REDIRECT
|
---|
141 | macro, in order to support compilers that can do this some other
|
---|
142 | way. When compilers don't support asm-names at all, we have to do
|
---|
143 | preprocessor tricks instead (which don't have exactly the right
|
---|
144 | semantics, but it's the best we can do).
|
---|
145 |
|
---|
146 | Example:
|
---|
147 | int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
|
---|
148 |
|
---|
149 | #if defined __GNUC__ && __GNUC__ >= 2
|
---|
150 |
|
---|
151 | # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
|
---|
152 | # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
|
---|
153 | # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
|
---|
154 |
|
---|
155 | /*
|
---|
156 | #elif __SOME_OTHER_COMPILER__
|
---|
157 |
|
---|
158 | # define __REDIRECT(name, proto, alias) name proto; \
|
---|
159 | _Pragma("let " #name " = " #alias)
|
---|
160 | */
|
---|
161 | #endif
|
---|
162 |
|
---|
163 | /* GCC has various useful declarations that can be made with the
|
---|
164 | `__attribute__' syntax. All of the ways we use this do fine if
|
---|
165 | they are omitted for compilers that don't understand it. */
|
---|
166 | #if !defined __GNUC__ || __GNUC__ < 2
|
---|
167 | # define __attribute__(xyz) /* Ignore */
|
---|
168 | #endif
|
---|
169 |
|
---|
170 | /* At some point during the gcc 2.96 development the `malloc' attribute
|
---|
171 | for functions was introduced. We don't want to use it unconditionally
|
---|
172 | (although this would be possible) since it generates warnings. */
|
---|
173 | #if __GNUC_PREREQ (2,96)
|
---|
174 | # define __attribute_malloc__ __attribute__ ((__malloc__))
|
---|
175 | #else
|
---|
176 | # define __attribute_malloc__ /* Ignore */
|
---|
177 | #endif
|
---|
178 |
|
---|
179 | /* At some point during the gcc 2.96 development the `pure' attribute
|
---|
180 | for functions was introduced. We don't want to use it unconditionally
|
---|
181 | (although this would be possible) since it generates warnings. */
|
---|
182 | #if __GNUC_PREREQ (2,96)
|
---|
183 | # define __attribute_pure__ __attribute__ ((__pure__))
|
---|
184 | #else
|
---|
185 | # define __attribute_pure__ /* Ignore */
|
---|
186 | #endif
|
---|
187 |
|
---|
188 | /* At some point during the gcc 3.1 development the `used' attribute
|
---|
189 | for functions was introduced. We don't want to use it unconditionally
|
---|
190 | (although this would be possible) since it generates warnings. */
|
---|
191 | #if __GNUC_PREREQ (3,1)
|
---|
192 | # define __attribute_used__ __attribute__ ((__used__))
|
---|
193 | # define __attribute_noinline__ __attribute__ ((__noinline__))
|
---|
194 | #else
|
---|
195 | # define __attribute_used__ __attribute__ ((__unused__))
|
---|
196 | # define __attribute_noinline__ /* Ignore */
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | /* gcc allows marking deprecated functions. */
|
---|
200 | #if __GNUC_PREREQ (3,2)
|
---|
201 | # define __attribute_deprecated__ __attribute__ ((__deprecated__))
|
---|
202 | #else
|
---|
203 | # define __attribute_deprecated__ /* Ignore */
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | /* At some point during the gcc 2.8 development the `format_arg' attribute
|
---|
207 | for functions was introduced. We don't want to use it unconditionally
|
---|
208 | (although this would be possible) since it generates warnings.
|
---|
209 | If several `format_arg' attributes are given for the same function, in
|
---|
210 | gcc-3.0 and older, all but the last one are ignored. In newer gccs,
|
---|
211 | all designated arguments are considered. */
|
---|
212 | #if __GNUC_PREREQ (2,8)
|
---|
213 | # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
|
---|
214 | #else
|
---|
215 | # define __attribute_format_arg__(x) /* Ignore */
|
---|
216 | #endif
|
---|
217 |
|
---|
218 | /* At some point during the gcc 2.97 development the `strfmon' format
|
---|
219 | attribute for functions was introduced. We don't want to use it
|
---|
220 | unconditionally (although this would be possible) since it
|
---|
221 | generates warnings. */
|
---|
222 | #if __GNUC_PREREQ (2,97)
|
---|
223 | # define __attribute_format_strfmon__(a,b) \
|
---|
224 | __attribute__ ((__format__ (__strfmon__, a, b)))
|
---|
225 | #else
|
---|
226 | # define __attribute_format_strfmon__(a,b) /* Ignore */
|
---|
227 | #endif
|
---|
228 |
|
---|
229 | /* It is possible to compile containing GCC extensions even if GCC is
|
---|
230 | run in pedantic mode if the uses are carefully marked using the
|
---|
231 | `__extension__' keyword. But this is not generally available before
|
---|
232 | version 2.8. */
|
---|
233 | #if !__GNUC_PREREQ (2,8)
|
---|
234 | # define __extension__ /* Ignore */
|
---|
235 | #endif
|
---|
236 |
|
---|
237 | /* __restrict is known in EGCS 1.2 and above. */
|
---|
238 | #if !__GNUC_PREREQ (2,92)
|
---|
239 | # define __restrict /* Ignore */
|
---|
240 | #endif
|
---|
241 |
|
---|
242 | /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
|
---|
243 | array_name[restrict]
|
---|
244 | GCC 3.1 supports this. */
|
---|
245 | #if __GNUC_PREREQ (3,1) && !defined __GNUG__
|
---|
246 | # define __restrict_arr __restrict
|
---|
247 | #else
|
---|
248 | # ifdef __GNUC__
|
---|
249 | # define __restrict_arr /* Not supported in old GCC. */
|
---|
250 | # else
|
---|
251 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
---|
252 | # define __restrict_arr restrict
|
---|
253 | # else
|
---|
254 | /* Some other non-C99 compiler. */
|
---|
255 | # define __restrict_arr /* Not supported. */
|
---|
256 | # endif
|
---|
257 | # endif
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | #endif /* sys/cdefs.h */
|
---|