]>
git.saurik.com Git - apple/libc.git/blob - fbsdcompat/sys/cdefs.h
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 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
50 * This file contains Original Code and/or Modifications of Original Code
51 * as defined in and that are subject to the Apple Public Source License
52 * Version 2.0 (the 'License'). You may not use this file except in
53 * compliance with the License. Please obtain a copy of the License at
54 * http://www.opensource.apple.com/apsl/ and read it before using this
57 * The Original Code and all software distributed under the License are
58 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
59 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
60 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
61 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
62 * Please see the License for the specific language governing rights and
63 * limitations under the License.
65 * @APPLE_LICENSE_HEADER_END@
67 /* Copyright 1995 NeXT Computer, Inc. All rights reserved. */
69 * Copyright (c) 1991, 1993
70 * The Regents of the University of California. All rights reserved.
72 * This code is derived from software contributed to Berkeley by
73 * Berkeley Software Design, Inc.
75 * Redistribution and use in source and binary forms, with or without
76 * modification, are permitted provided that the following conditions
78 * 1. Redistributions of source code must retain the above copyright
79 * notice, this list of conditions and the following disclaimer.
80 * 2. Redistributions in binary form must reproduce the above copyright
81 * notice, this list of conditions and the following disclaimer in the
82 * documentation and/or other materials provided with the distribution.
83 * 3. All advertising materials mentioning features or use of this software
84 * must display the following acknowledgement:
85 * This product includes software developed by the University of
86 * California, Berkeley and its contributors.
87 * 4. Neither the name of the University nor the names of its contributors
88 * may be used to endorse or promote products derived from this software
89 * without specific prior written permission.
91 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
92 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
93 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
94 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
95 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
96 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
97 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
98 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
99 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
100 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
103 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
108 * GCC1 and some versions of GCC2 declare dead (non-returning) and
109 * pure (no side effects) functions using "volatile" and "const";
110 * unfortunately, these then cause warnings under "-ansi -pedantic".
111 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
112 * these work for GNU C++ (modulo a slight glitch in the C++ grammar
113 * in the distribution version of 2.5.5).
115 #if defined(__MWERKS__) && (__MWERKS__ > 0x2400)
116 /* newer Metrowerks compilers support __attribute__() */
117 #elif !defined(__GNUC__) || __GNUC__ < 2 || \
118 (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
119 #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
120 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
121 #define __dead __volatile
122 #define __pure __const
126 /* Delete pseudo-keywords wherever they are not available or needed. */
132 //-------------------------- End Added -----------------------------------
134 #if defined(__cplusplus)
135 #define __BEGIN_DECLS extern "C" {
136 #define __END_DECLS }
138 #define __BEGIN_DECLS
143 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
144 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
145 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
146 * mode -- there must be no spaces between its arguments, and for nested
147 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
148 * concatenate double-quoted strings produced by the __STRING macro, but
149 * this only works with ANSI C.
151 * __XSTRING is like __STRING, but it expands any macros in its argument
152 * first. It is only available with ANSI C.
154 #if defined(__STDC__) || defined(__cplusplus)
155 #define __P(protos) protos /* full-blown ANSI C */
156 #define __CONCAT1(x,y) x ## y
157 #define __CONCAT(x,y) __CONCAT1(x,y)
158 #define __STRING(x) #x /* stringify without expanding x */
159 #define __XSTRING(x) __STRING(x) /* expand x, then stringify */
161 #define __const const /* define reserved names to standard */
162 #define __signed signed
163 #define __volatile volatile
164 #if defined(__cplusplus)
165 #define __inline inline /* convert to C++ keyword */
168 #define __inline /* delete GCC keyword */
169 #endif /* !__GNUC__ */
170 #endif /* !__cplusplus */
172 #else /* !(__STDC__ || __cplusplus) */
173 #define __P(protos) () /* traditional C preprocessor */
174 #define __CONCAT(x,y) x/**/y
175 #define __STRING(x) "x"
178 #define __const /* delete pseudo-ANSI C keywords */
183 * In non-ANSI C environments, new programs will want ANSI-only C keywords
184 * deleted from the program and old programs will want them left alone.
185 * When using a compiler other than gcc, programs using the ANSI C keywords
186 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
187 * When using "gcc -traditional", we assume that this is the intent; if
188 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
190 #ifndef NO_ANSI_KEYWORDS
191 #define const /* delete ANSI C keywords */
195 #endif /* !NO_ANSI_KEYWORDS */
196 #endif /* !__GNUC__ */
197 #endif /* !(__STDC__ || __cplusplus) */
200 * Compiler-dependent macros to help declare dead (non-returning) and
201 * pure (no side effects) functions, and unused variables. They are
202 * null except for versions of gcc that are known to support the features
203 * properly (old versions of gcc-2 supported the dead and pure features
204 * in a different (wrong) way). If we do not provide an implementation
205 * for a given compiler, let the compile fail if it is told to use
206 * a feature that we cannot live without.
216 #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5
221 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
222 #define __dead2 __attribute__((__noreturn__))
223 #define __pure2 __attribute__((__const__))
225 /* XXX Find out what to do for __packed, __aligned and __section */
227 #if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3
228 #define __dead2 __attribute__((__noreturn__))
229 #define __pure2 __attribute__((__const__))
230 #define __unused __attribute__((__unused__))
231 #define __packed __attribute__((__packed__))
232 #define __aligned(x) __attribute__((__aligned__(x)))
233 #define __section(x) __attribute__((__section__(x)))
237 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
238 #if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
239 #define __func__ NULL
242 #if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
243 #define __LONG_LONG_SUPPORTED
247 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
248 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
249 * a way to define the `restrict' type qualifier without disturbing older
250 * software that is unaware of C99 keywords.
252 #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
253 #if __STDC_VERSION__ < 199901
256 #define __restrict restrict
261 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
264 #define __offsetof(type, field) ((size_t)(&((type *)0)->field))
267 * Compiler-dependent macros to declare that functions take printf-like
268 * or scanf-like arguments. They are null except for versions of gcc
269 * that are known to support the features properly (old versions of gcc-2
270 * didn't permit keeping the keywords out of the application namespace).
272 #if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
273 #define __printflike(fmtarg, firstvararg)
274 #define __scanflike(fmtarg, firstvararg)
276 #define __printflike(fmtarg, firstvararg) \
277 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
278 #define __scanflike(fmtarg, firstvararg) \
279 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
282 /* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
283 #if __FreeBSD_cc_version >= 300001 && __FreeBSD_cc_version < 500003
284 #define __printf0like(fmtarg, firstvararg) \
285 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
287 #define __printf0like(fmtarg, firstvararg)
291 #define __strong_reference(sym,aliassym) \
292 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
294 #define __weak_reference(sym,alias)
295 #define __warn_references(sym,msg)
298 #define __weak_reference(sym,alias) \
299 __asm__(".weak " #alias); \
300 __asm__(".equ " #alias ", " #sym)
301 #define __warn_references(sym,msg) \
302 __asm__(".section .gnu.warning." #sym); \
303 __asm__(".asciz \"" msg "\""); \
306 #define __weak_reference(sym,alias) \
307 __asm__(".weak alias"); \
308 __asm__(".equ alias, sym")
309 #define __warn_references(sym,msg) \
310 __asm__(".section .gnu.warning.sym"); \
311 __asm__(".asciz \"msg\""); \
313 #endif /* __STDC__ */
315 #endif /* __GNUC__ */
318 #define __IDSTRING(name,string) \
319 static const char name[] __attribute__((__unused__)) = string
322 #define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
325 * This doesn't work in header files. But it may be better than nothing.
326 * The alternative is: #define __IDSTRING(name,string) [nothing]
328 #define __IDSTRING(name,string) static const char name[] __unused = string
333 * Embed the rcs id of a source file in the resulting library. Note that in
334 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
336 * __FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $");
339 #if !defined(lint) && !defined(STRIP_FBSDID)
340 #define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
342 #define __FBSDID(s) struct __hack
348 #define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
354 #ifndef __RCSID_SOURCE
355 #ifndef NO__RCSID_SOURCE
356 #define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
358 #define __RCSID_SOURCE(s)
364 #define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
371 #ifndef NO__COPYRIGHT
372 #define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
374 #define __COPYRIGHT(s)
379 #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
383 #define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
387 #define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
391 * The following definitions are an extension of the behavior originally
392 * implemented in <sys/_posix.h>, but with a different level of granularity.
393 * POSIX.1 requires that the macros we test be defined before any standard
394 * header file is included.
396 * Here's a quick run-down of the versions:
397 * defined(_POSIX_SOURCE) 1003.1-1988
398 * _POSIX_C_SOURCE == 1 1003.1-1990
399 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
400 * _POSIX_C_SOURCE == 199309 1003.1b-1993
401 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
402 * and the omnibus ISO/IEC 9945-1: 1996
403 * _POSIX_C_SOURCE == 200112 1003.1-2001
405 * In addition, the X/Open Portability Guide, which is now the Single UNIX
406 * Specification, defines a feature-test macro which indicates the version of
407 * that specification, and which subsumes _POSIX_C_SOURCE.
409 * Our macros begin with two underscores to avoid namespace screwage.
412 /* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
413 #if _POSIX_C_SOURCE == 1
414 #undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
415 #define _POSIX_C_SOURCE 199009
418 /* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
419 #if _POSIX_C_SOURCE == 2
420 #undef _POSIX_C_SOURCE
421 #define _POSIX_C_SOURCE 199209
424 /* Deal with various X/Open Portability Guides and Single UNIX Spec. */
426 #if _XOPEN_SOURCE - 0 >= 600
427 #define __XSI_VISIBLE 600
428 #undef _POSIX_C_SOURCE
429 #define _POSIX_C_SOURCE 200112
430 #elif _XOPEN_SOURCE - 0 >= 500
431 #define __XSI_VISIBLE 500
432 #undef _POSIX_C_SOURCE
433 #define _POSIX_C_SOURCE 199506
438 * Deal with all versions of POSIX. The ordering relative to the tests above is
441 #if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
442 #define _POSIX_C_SOURCE 198808
444 #ifdef _POSIX_C_SOURCE
445 #if _POSIX_C_SOURCE >= 200112
446 #define __POSIX_VISIBLE 200112
447 #define __ISO_C_VISIBLE 1999
448 #elif _POSIX_C_SOURCE >= 199506
449 #define __POSIX_VISIBLE 199506
450 #define __ISO_C_VISIBLE 1990
451 #elif _POSIX_C_SOURCE >= 199309
452 #define __POSIX_VISIBLE 199309
453 #define __ISO_C_VISIBLE 1990
454 #elif _POSIX_C_SOURCE >= 199209
455 #define __POSIX_VISIBLE 199209
456 #define __ISO_C_VISIBLE 1990
457 #elif _POSIX_C_SOURCE >= 199009
458 #define __POSIX_VISIBLE 199009
459 #define __ISO_C_VISIBLE 1990
461 #define __POSIX_VISIBLE 198808
462 #define __ISO_C_VISIBLE 0
463 #endif /* _POSIX_C_SOURCE */
466 * Deal with _ANSI_SOURCE:
467 * If it is defined, and no other compilation environment is explicitly
468 * requested, then define our internal feature-test macros to zero. This
469 * makes no difference to the preprocessor (undefined symbols in preprocessing
470 * expressions are defined to have value zero), but makes it more convenient for
471 * a test program to print out the values.
473 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
474 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
475 * environment (and in fact we will never get here).
477 #if defined(_ANSI_SOURCE) /* Hide almost everything. */
478 #define __POSIX_VISIBLE 0
479 #define __XSI_VISIBLE 0
480 #define __BSD_VISIBLE 0
481 #define __ISO_C_VISIBLE 1990
482 #elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
483 #define __POSIX_VISIBLE 0
484 #define __XSI_VISIBLE 0
485 #define __BSD_VISIBLE 0
486 #define __ISO_C_VISIBLE 1999
487 #else /* Default environment: show everything. */
488 #define __POSIX_VISIBLE 200112
489 #define __XSI_VISIBLE 600
490 #define __BSD_VISIBLE 1
491 #define __ISO_C_VISIBLE 1999
495 #endif /* !_SYS_CDEFS_H_ */