]>
git.saurik.com Git - apple/libc.git/blob - fbsdcompat/sys/cdefs.h
d0237a2c3f488a1073fb05f1a75b520de2bb1d02
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Berkeley Software Design, Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
37 * $FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $
42 //------------------------- Begin Added ----------------------------------
44 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
46 * @APPLE_LICENSE_HEADER_START@
48 * This file contains Original Code and/or Modifications of Original Code
49 * as defined in and that are subject to the Apple Public Source License
50 * Version 2.0 (the 'License'). You may not use this file except in
51 * compliance with the License. Please obtain a copy of the License at
52 * http://www.opensource.apple.com/apsl/ and read it before using this
55 * The Original Code and all software distributed under the License are
56 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
57 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
58 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
59 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
60 * Please see the License for the specific language governing rights and
61 * limitations under the License.
63 * @APPLE_LICENSE_HEADER_END@
65 /* Copyright 1995 NeXT Computer, Inc. All rights reserved. */
67 * Copyright (c) 1991, 1993
68 * The Regents of the University of California. All rights reserved.
70 * This code is derived from software contributed to Berkeley by
71 * Berkeley Software Design, Inc.
73 * Redistribution and use in source and binary forms, with or without
74 * modification, are permitted provided that the following conditions
76 * 1. Redistributions of source code must retain the above copyright
77 * notice, this list of conditions and the following disclaimer.
78 * 2. Redistributions in binary form must reproduce the above copyright
79 * notice, this list of conditions and the following disclaimer in the
80 * documentation and/or other materials provided with the distribution.
81 * 3. All advertising materials mentioning features or use of this software
82 * must display the following acknowledgement:
83 * This product includes software developed by the University of
84 * California, Berkeley and its contributors.
85 * 4. Neither the name of the University nor the names of its contributors
86 * may be used to endorse or promote products derived from this software
87 * without specific prior written permission.
89 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
90 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
91 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
92 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
93 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
94 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
95 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
96 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
97 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
98 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
101 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
106 * GCC1 and some versions of GCC2 declare dead (non-returning) and
107 * pure (no side effects) functions using "volatile" and "const";
108 * unfortunately, these then cause warnings under "-ansi -pedantic".
109 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
110 * these work for GNU C++ (modulo a slight glitch in the C++ grammar
111 * in the distribution version of 2.5.5).
113 #if defined(__MWERKS__) && (__MWERKS__ > 0x2400)
114 /* newer Metrowerks compilers support __attribute__() */
115 #elif !defined(__GNUC__) || __GNUC__ < 2 || \
116 (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
117 #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
118 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
119 #define __dead __volatile
120 #define __pure __const
124 /* Delete pseudo-keywords wherever they are not available or needed. */
130 //-------------------------- End Added -----------------------------------
132 #if defined(__cplusplus)
133 #define __BEGIN_DECLS extern "C" {
134 #define __END_DECLS }
136 #define __BEGIN_DECLS
141 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
142 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
143 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
144 * mode -- there must be no spaces between its arguments, and for nested
145 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
146 * concatenate double-quoted strings produced by the __STRING macro, but
147 * this only works with ANSI C.
149 * __XSTRING is like __STRING, but it expands any macros in its argument
150 * first. It is only available with ANSI C.
152 #if defined(__STDC__) || defined(__cplusplus)
153 #define __P(protos) protos /* full-blown ANSI C */
154 #define __CONCAT1(x,y) x ## y
155 #define __CONCAT(x,y) __CONCAT1(x,y)
156 #define __STRING(x) #x /* stringify without expanding x */
157 #define __XSTRING(x) __STRING(x) /* expand x, then stringify */
159 #define __const const /* define reserved names to standard */
160 #define __signed signed
161 #define __volatile volatile
162 #if defined(__cplusplus)
163 #define __inline inline /* convert to C++ keyword */
166 #define __inline /* delete GCC keyword */
167 #endif /* !__GNUC__ */
168 #endif /* !__cplusplus */
170 #else /* !(__STDC__ || __cplusplus) */
171 #define __P(protos) () /* traditional C preprocessor */
172 #define __CONCAT(x,y) x/**/y
173 #define __STRING(x) "x"
176 #define __const /* delete pseudo-ANSI C keywords */
181 * In non-ANSI C environments, new programs will want ANSI-only C keywords
182 * deleted from the program and old programs will want them left alone.
183 * When using a compiler other than gcc, programs using the ANSI C keywords
184 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
185 * When using "gcc -traditional", we assume that this is the intent; if
186 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
188 #ifndef NO_ANSI_KEYWORDS
189 #define const /* delete ANSI C keywords */
193 #endif /* !NO_ANSI_KEYWORDS */
194 #endif /* !__GNUC__ */
195 #endif /* !(__STDC__ || __cplusplus) */
198 * Compiler-dependent macros to help declare dead (non-returning) and
199 * pure (no side effects) functions, and unused variables. They are
200 * null except for versions of gcc that are known to support the features
201 * properly (old versions of gcc-2 supported the dead and pure features
202 * in a different (wrong) way). If we do not provide an implementation
203 * for a given compiler, let the compile fail if it is told to use
204 * a feature that we cannot live without.
214 #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5
219 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
220 #define __dead2 __attribute__((__noreturn__))
221 #define __pure2 __attribute__((__const__))
223 /* XXX Find out what to do for __packed, __aligned and __section */
225 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3
226 #define __dead2 __attribute__((__noreturn__))
227 #define __pure2 __attribute__((__const__))
228 #define __unused __attribute__((__unused__))
229 #define __packed __attribute__((__packed__))
230 #define __aligned(x) __attribute__((__aligned__(x)))
231 #define __section(x) __attribute__((__section__(x)))
235 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
236 #if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
237 #define __func__ NULL
240 #if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
241 #define __LONG_LONG_SUPPORTED
245 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
246 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
247 * a way to define the `restrict' type qualifier without disturbing older
248 * software that is unaware of C99 keywords.
250 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
251 #if __STDC_VERSION__ < 199901
254 #define __restrict restrict
259 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
262 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
265 * Compiler-dependent macros to declare that functions take printf-like
266 * or scanf-like arguments. They are null except for versions of gcc
267 * that are known to support the features properly (old versions of gcc-2
268 * didn't permit keeping the keywords out of the application namespace).
270 #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
271 #define __printflike(fmtarg, firstvararg)
272 #define __scanflike(fmtarg, firstvararg)
274 #define __printflike(fmtarg, firstvararg) \
275 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
276 #define __scanflike(fmtarg, firstvararg) \
277 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
280 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
281 #if __FreeBSD_cc_version >= 300001 && __FreeBSD_cc_version < 500003
282 #define __printf0like(fmtarg, firstvararg) \
283 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
285 #define __printf0like(fmtarg, firstvararg)
289 #define __strong_reference(sym,aliassym) \
290 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
292 #define __weak_reference(sym,alias)
293 #define __warn_references(sym,msg)
296 #define __weak_reference(sym,alias) \
297 __asm__(".weak " #alias); \
298 __asm__(".equ " #alias ", " #sym)
299 #define __warn_references(sym,msg) \
300 __asm__(".section .gnu.warning." #sym); \
301 __asm__(".asciz \"" msg "\""); \
304 #define __weak_reference(sym,alias) \
305 __asm__(".weak alias"); \
306 __asm__(".equ alias, sym")
307 #define __warn_references(sym,msg) \
308 __asm__(".section .gnu.warning.sym"); \
309 __asm__(".asciz \"msg\""); \
311 #endif /* __STDC__ */
313 #endif /* __GNUC__ */
316 #define __IDSTRING(name,string) \
317 static const char name[] __attribute__((__unused__)) = string
320 #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
323 * This doesn't work in header files. But it may be better than nothing.
324 * The alternative is: #define __IDSTRING(name,string) [nothing]
326 #define __IDSTRING(name,string) static const char name[] __unused = string
331 * Embed the rcs id of a source file in the resulting library. Note that in
332 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
334 * __FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $");
337 #if !defined(lint) && !defined(STRIP_FBSDID)
338 #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
340 #define __FBSDID(s) struct __hack
346 #define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
352 #ifndef __RCSID_SOURCE
353 #ifndef NO__RCSID_SOURCE
354 #define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
356 #define __RCSID_SOURCE(s)
362 #define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
369 #ifndef NO__COPYRIGHT
370 #define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
372 #define __COPYRIGHT(s)
377 #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
381 #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
385 #define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
389 * The following definitions are an extension of the behavior originally
390 * implemented in <sys/_posix.h>, but with a different level of granularity.
391 * POSIX.1 requires that the macros we test be defined before any standard
392 * header file is included.
394 * Here's a quick run-down of the versions:
395 * defined(_POSIX_SOURCE) 1003.1-1988
396 * _POSIX_C_SOURCE == 1 1003.1-1990
397 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
398 * _POSIX_C_SOURCE == 199309 1003.1b-1993
399 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
400 * and the omnibus ISO/IEC 9945-1: 1996
401 * _POSIX_C_SOURCE == 200112 1003.1-2001
403 * In addition, the X/Open Portability Guide, which is now the Single UNIX
404 * Specification, defines a feature-test macro which indicates the version of
405 * that specification, and which subsumes _POSIX_C_SOURCE.
407 * Our macros begin with two underscores to avoid namespace screwage.
410 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
411 #if _POSIX_C_SOURCE == 1
412 #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
413 #define _POSIX_C_SOURCE 199009
416 /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
417 #if _POSIX_C_SOURCE == 2
418 #undef _POSIX_C_SOURCE
419 #define _POSIX_C_SOURCE 199209
422 /* Deal with various X/Open Portability Guides and Single UNIX Spec. */
424 #if _XOPEN_SOURCE - 0 >= 600
425 #define __XSI_VISIBLE 600
426 #undef _POSIX_C_SOURCE
427 #define _POSIX_C_SOURCE 200112
428 #elif _XOPEN_SOURCE - 0 >= 500
429 #define __XSI_VISIBLE 500
430 #undef _POSIX_C_SOURCE
431 #define _POSIX_C_SOURCE 199506
436 * Deal with all versions of POSIX. The ordering relative to the tests above is
439 #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
440 #define _POSIX_C_SOURCE 198808
442 #ifdef _POSIX_C_SOURCE
443 #if _POSIX_C_SOURCE >= 200112
444 #define __POSIX_VISIBLE 200112
445 #define __ISO_C_VISIBLE 1999
446 #elif _POSIX_C_SOURCE >= 199506
447 #define __POSIX_VISIBLE 199506
448 #define __ISO_C_VISIBLE 1990
449 #elif _POSIX_C_SOURCE >= 199309
450 #define __POSIX_VISIBLE 199309
451 #define __ISO_C_VISIBLE 1990
452 #elif _POSIX_C_SOURCE >= 199209
453 #define __POSIX_VISIBLE 199209
454 #define __ISO_C_VISIBLE 1990
455 #elif _POSIX_C_SOURCE >= 199009
456 #define __POSIX_VISIBLE 199009
457 #define __ISO_C_VISIBLE 1990
459 #define __POSIX_VISIBLE 198808
460 #define __ISO_C_VISIBLE 0
461 #endif /* _POSIX_C_SOURCE */
464 * Deal with _ANSI_SOURCE:
465 * If it is defined, and no other compilation environment is explicitly
466 * requested, then define our internal feature-test macros to zero. This
467 * makes no difference to the preprocessor (undefined symbols in preprocessing
468 * expressions are defined to have value zero), but makes it more convenient for
469 * a test program to print out the values.
471 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
472 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
473 * environment (and in fact we will never get here).
475 #if defined(_ANSI_SOURCE) /* Hide almost everything. */
476 #define __POSIX_VISIBLE 0
477 #define __XSI_VISIBLE 0
478 #define __BSD_VISIBLE 0
479 #define __ISO_C_VISIBLE 1990
480 #elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
481 #define __POSIX_VISIBLE 0
482 #define __XSI_VISIBLE 0
483 #define __BSD_VISIBLE 0
484 #define __ISO_C_VISIBLE 1999
485 #else /* Default environment: show everything. */
486 #define __POSIX_VISIBLE 200112
487 #define __XSI_VISIBLE 600
488 #define __BSD_VISIBLE 1
489 #define __ISO_C_VISIBLE 1999
493 #endif /* !_SYS_CDEFS_H_ */