]> git.saurik.com Git - apple/libc.git/blame_incremental - fbsdcompat/sys/cdefs.h
Libc-320.tar.gz
[apple/libc.git] / fbsdcompat / sys / cdefs.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Berkeley Software Design, Inc.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
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.
23 *
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
34 * SUCH DAMAGE.
35 *
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 $
38 */
39
40#ifndef _SYS_CDEFS_H_
41#define _SYS_CDEFS_H_
42//------------------------- Begin Added ----------------------------------
43/*
44 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
45 *
46 * @APPLE_LICENSE_HEADER_START@
47 *
48 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
49 *
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
55 * file.
56 *
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.
64 *
65 * @APPLE_LICENSE_HEADER_END@
66 */
67/* Copyright 1995 NeXT Computer, Inc. All rights reserved. */
68/*
69 * Copyright (c) 1991, 1993
70 * The Regents of the University of California. All rights reserved.
71 *
72 * This code is derived from software contributed to Berkeley by
73 * Berkeley Software Design, Inc.
74 *
75 * Redistribution and use in source and binary forms, with or without
76 * modification, are permitted provided that the following conditions
77 * are met:
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.
90 *
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
101 * SUCH DAMAGE.
102 *
103 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
104 */
105
106#ifdef __APPLE__
107/*
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).
114 */
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
123#endif
124#endif
125
126/* Delete pseudo-keywords wherever they are not available or needed. */
127#ifndef __dead
128#define __dead
129#define __pure
130#endif
131#endif // __APPLE__
132//-------------------------- End Added -----------------------------------
133
134#if defined(__cplusplus)
135#define __BEGIN_DECLS extern "C" {
136#define __END_DECLS }
137#else
138#define __BEGIN_DECLS
139#define __END_DECLS
140#endif
141
142/*
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.
150 *
151 * __XSTRING is like __STRING, but it expands any macros in its argument
152 * first. It is only available with ANSI C.
153 */
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 */
160
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 */
166#else
167#ifndef __GNUC__
168#define __inline /* delete GCC keyword */
169#endif /* !__GNUC__ */
170#endif /* !__cplusplus */
171
172#else /* !(__STDC__ || __cplusplus) */
173#define __P(protos) () /* traditional C preprocessor */
174#define __CONCAT(x,y) x/**/y
175#define __STRING(x) "x"
176
177#ifndef __GNUC__
178#define __const /* delete pseudo-ANSI C keywords */
179#define __inline
180#define __signed
181#define __volatile
182/*
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.
189 */
190#ifndef NO_ANSI_KEYWORDS
191#define const /* delete ANSI C keywords */
192#define inline
193#define signed
194#define volatile
195#endif /* !NO_ANSI_KEYWORDS */
196#endif /* !__GNUC__ */
197#endif /* !(__STDC__ || __cplusplus) */
198
199/*
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.
207 */
208#ifdef lint
209#define __dead2
210#define __pure2
211#define __unused
212#define __packed
213#define __aligned(x)
214#define __section(x)
215#else
216#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5
217#define __dead2
218#define __pure2
219#define __unused
220#endif
221#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
222#define __dead2 __attribute__((__noreturn__))
223#define __pure2 __attribute__((__const__))
224#define __unused
225/* XXX Find out what to do for __packed, __aligned and __section */
226#endif
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)))
234#endif
235#endif
236
237/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
238#if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
239#define __func__ NULL
240#endif
241
242#if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
243#define __LONG_LONG_SUPPORTED
244#endif
245
246/*
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.
251 */
252#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
253#if __STDC_VERSION__ < 199901
254#define __restrict
255#else
256#define __restrict restrict
257#endif
258#endif
259
260/*
261 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
262 * require it.
263 */
264#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
265
266/*
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).
271 */
272#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
273#define __printflike(fmtarg, firstvararg)
274#define __scanflike(fmtarg, firstvararg)
275#else
276#define __printflike(fmtarg, firstvararg) \
277 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
278#define __scanflike(fmtarg, firstvararg) \
279 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
280#endif
281
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)))
286#else
287#define __printf0like(fmtarg, firstvararg)
288#endif
289
290#ifdef __GNUC__
291#define __strong_reference(sym,aliassym) \
292 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
293#ifdef __APPLE__
294#define __weak_reference(sym,alias)
295#define __warn_references(sym,msg)
296#else // ! __APPLE__
297#ifdef __STDC__
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 "\""); \
304 __asm__(".previous")
305#else
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\""); \
312 __asm__(".previous")
313#endif /* __STDC__ */
314#endif // __APPLE__
315#endif /* __GNUC__ */
316
317#ifdef __APPLE__
318#define __IDSTRING(name,string) \
319 static const char name[] __attribute__((__unused__)) = string
320#else // ! __APPLE__
321#ifdef __GNUC__
322#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
323#else
324/*
325 * This doesn't work in header files. But it may be better than nothing.
326 * The alternative is: #define __IDSTRING(name,string) [nothing]
327 */
328#define __IDSTRING(name,string) static const char name[] __unused = string
329#endif
330#endif // __APPLE__
331
332/*
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.
335 * Usage:
336 * __FBSDID("$FreeBSD: /repoman/r/ncvs/src/sys/sys/cdefs.h,v 1.68 2002/10/21 20:50:30 mike Exp $");
337 */
338#ifndef __FBSDID
339#if !defined(lint) && !defined(STRIP_FBSDID)
340#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
341#else
342#define __FBSDID(s) struct __hack
343#endif
344#endif
345
346#ifndef __RCSID
347#ifndef NO__RCSID
348#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
349#else
350#define __RCSID(s)
351#endif
352#endif
353
354#ifndef __RCSID_SOURCE
355#ifndef NO__RCSID_SOURCE
356#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
357#else
358#define __RCSID_SOURCE(s)
359#endif
360#endif
361
362#ifndef __SCCSID
363#ifndef NO__SCCSID
364#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
365#else
366#define __SCCSID(s)
367#endif
368#endif
369
370#ifndef __COPYRIGHT
371#ifndef NO__COPYRIGHT
372#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
373#else
374#define __COPYRIGHT(s)
375#endif
376#endif
377
378#ifndef __DECONST
379#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
380#endif
381
382#ifndef __DEVOLATILE
383#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
384#endif
385
386#ifndef __DEQUALIFY
387#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
388#endif
389
390/*-
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.
395 *
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
404 *
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.
408 *
409 * Our macros begin with two underscores to avoid namespace screwage.
410 */
411
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
416#endif
417
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
422#endif
423
424/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
425#ifdef _XOPEN_SOURCE
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
434#endif
435#endif
436
437/*
438 * Deal with all versions of POSIX. The ordering relative to the tests above is
439 * important.
440 */
441#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
442#define _POSIX_C_SOURCE 198808
443#endif
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
460#else
461#define __POSIX_VISIBLE 198808
462#define __ISO_C_VISIBLE 0
463#endif /* _POSIX_C_SOURCE */
464#else
465/*-
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.
472 *
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).
476 */
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
492#endif
493#endif
494
495#endif /* !_SYS_CDEFS_H_ */