source: trunk/src/emx/include/sys/cdefs.h@ 1064

Last change on this file since 1064 was 1064, checked in by bird, 22 years ago

GNU sys/cdefs.h too.

  • Property cvs2svn:cvs-rev set to 1.7
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 13.6 KB
Line 
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: src/sys/sys/cdefs.h,v 1.69 2003/04/18 18:59:34 bde Exp $
38 */
39
40/** @file
41 * FreeBSD 5.1
42 *
43 * @changed bird: Toolkit compatibility (_CDEFS_H_ and __TCPROTO()).
44 * @changed zap: _System definition for older GCC compilers.
45 */
46
47
48#ifndef _SYS_CDEFS_H_
49#define _SYS_CDEFS_H_
50#define _CDEFS_H_ /* bird: compatability */
51
52#if defined(__cplusplus)
53#define __BEGIN_DECLS extern "C" {
54#define __END_DECLS }
55#else
56#define __BEGIN_DECLS
57#define __END_DECLS
58#endif
59
60/*
61 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
62 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
63 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
64 * mode -- there must be no spaces between its arguments, and for nested
65 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
66 * concatenate double-quoted strings produced by the __STRING macro, but
67 * this only works with ANSI C.
68 *
69 * __XSTRING is like __STRING, but it expands any macros in its argument
70 * first. It is only available with ANSI C.
71 */
72#if defined(__STDC__) || defined(__cplusplus)
73#define __P(protos) protos /* full-blown ANSI C */
74#define __CONCAT1(x,y) x ## y
75#define __CONCAT(x,y) __CONCAT1(x,y)
76#define __STRING(x) #x /* stringify without expanding x */
77#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
78
79#define __const const /* define reserved names to standard */
80#define __signed signed
81#define __volatile volatile
82#if defined(__cplusplus)
83#define __inline inline /* convert to C++ keyword */
84#else
85#ifndef __GNUC__
86#define __inline /* delete GCC keyword */
87#endif /* !__GNUC__ */
88#endif /* !__cplusplus */
89
90#else /* !(__STDC__ || __cplusplus) */
91#define __P(protos) () /* traditional C preprocessor */
92#define __CONCAT(x,y) x/**/y
93#define __STRING(x) "x"
94
95#ifndef __GNUC__
96#define __const /* delete pseudo-ANSI C keywords */
97#define __inline
98#define __signed
99#define __volatile
100/*
101 * In non-ANSI C environments, new programs will want ANSI-only C keywords
102 * deleted from the program and old programs will want them left alone.
103 * When using a compiler other than gcc, programs using the ANSI C keywords
104 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
105 * When using "gcc -traditional", we assume that this is the intent; if
106 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
107 */
108#ifndef NO_ANSI_KEYWORDS
109#define const /* delete ANSI C keywords */
110#define inline
111#define signed
112#define volatile
113#endif /* !NO_ANSI_KEYWORDS */
114#endif /* !__GNUC__ */
115#endif /* !(__STDC__ || __cplusplus) */
116
117/*
118 * Compiler-dependent macros to help declare dead (non-returning) and
119 * pure (no side effects) functions, and unused variables. They are
120 * null except for versions of gcc that are known to support the features
121 * properly (old versions of gcc-2 supported the dead and pure features
122 * in a different (wrong) way). If we do not provide an implementation
123 * for a given compiler, let the compile fail if it is told to use
124 * a feature that we cannot live without.
125 */
126#ifdef lint
127#define __dead2
128#define __pure2
129#define __unused
130#define __packed
131#define __aligned(x)
132#define __section(x)
133#else
134#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 5
135#define __dead2
136#define __pure2
137#define __unused
138#endif
139#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7
140#define __dead2 __attribute__((__noreturn__))
141#define __pure2 __attribute__((__const__))
142#define __unused
143/* XXX Find out what to do for __packed, __aligned and __section */
144#endif
145#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3
146#define __dead2 __attribute__((__noreturn__))
147#define __pure2 __attribute__((__const__))
148#define __unused __attribute__((__unused__))
149#define __packed __attribute__((__packed__))
150#define __aligned(x) __attribute__((__aligned__(x)))
151#define __section(x) __attribute__((__section__(x)))
152#endif
153#endif
154
155/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
156#if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
157#define __func__ NULL
158#endif
159
160#if __GNUC__ >= 2 && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
161#define __LONG_LONG_SUPPORTED
162#endif
163
164/*
165 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
166 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
167 * a way to define the `restrict' type qualifier without disturbing older
168 * software that is unaware of C99 keywords.
169 */
170#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
171#if __STDC_VERSION__ < 199901
172#define __restrict
173#else
174#define __restrict restrict
175#endif
176#endif
177
178/*
179 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
180 * require it.
181 */
182#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
183
184/*
185 * Compiler-dependent macros to declare that functions take printf-like
186 * or scanf-like arguments. They are null except for versions of gcc
187 * that are known to support the features properly (old versions of gcc-2
188 * didn't permit keeping the keywords out of the application namespace).
189 */
190#if __GNUC__ < 2 || __GNUC__ == 2 && __GNUC_MINOR__ < 7
191#define __printflike(fmtarg, firstvararg)
192#define __scanflike(fmtarg, firstvararg)
193#else
194#define __printflike(fmtarg, firstvararg) \
195 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
196#define __scanflike(fmtarg, firstvararg) \
197 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
198#endif
199
200/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
201#if __FreeBSD_cc_version >= 300001
202#define __printf0like(fmtarg, firstvararg) \
203 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
204#else
205#define __printf0like(fmtarg, firstvararg)
206#endif
207
208#if 0 /* def __GNUC__ - bird: ELF specific, so skip everything */
209#define __strong_reference(sym,aliassym) \
210 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
211#ifdef __STDC__
212#define __weak_reference(sym,alias) \
213 __asm__(".weak " #alias); \
214 __asm__(".equ " #alias ", " #sym)
215#define __warn_references(sym,msg) \
216 __asm__(".section .gnu.warning." #sym); \
217 __asm__(".asciz \"" msg "\""); \
218 __asm__(".previous")
219#else
220#define __weak_reference(sym,alias) \
221 __asm__(".weak alias"); \
222 __asm__(".equ alias, sym")
223#define __warn_references(sym,msg) \
224 __asm__(".section .gnu.warning.sym"); \
225 __asm__(".asciz \"msg\""); \
226 __asm__(".previous")
227#endif /* __STDC__ */
228#endif /* __GNUC__ */
229
230#if 0 /*def __GNUC__ - ELF specific. */
231#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
232#else
233/*
234 * This doesn't work in header files. But it may be better than nothing.
235 * The alternative is: #define __IDSTRING(name,string) [nothing]
236 */
237#define __IDSTRING(name,string) static const char name[] __unused = string
238#endif
239
240/*
241 * Embed the rcs id of a source file in the resulting library. Note that in
242 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
243 * Usage:
244 * __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.69 2003/04/18 18:59:34 bde Exp $");
245 */
246#ifndef __FBSDID
247#if !defined(lint) && !defined(STRIP_FBSDID)
248#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
249#else
250#define __FBSDID(s) struct __hack
251#endif
252#endif
253
254#ifndef __RCSID
255#ifndef NO__RCSID
256#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
257#else
258#define __RCSID(s)
259#endif
260#endif
261
262#ifndef __RCSID_SOURCE
263#ifndef NO__RCSID_SOURCE
264#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
265#else
266#define __RCSID_SOURCE(s)
267#endif
268#endif
269
270#ifndef __SCCSID
271#ifndef NO__SCCSID
272#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
273#else
274#define __SCCSID(s)
275#endif
276#endif
277
278#ifndef __COPYRIGHT
279#ifndef NO__COPYRIGHT
280#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
281#else
282#define __COPYRIGHT(s)
283#endif
284#endif
285
286#ifndef __DECONST
287#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
288#endif
289
290#ifndef __DEVOLATILE
291#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
292#endif
293
294#ifndef __DEQUALIFY
295#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
296#endif
297
298/*-
299 * The following definitions are an extension of the behavior originally
300 * implemented in <sys/_posix.h>, but with a different level of granularity.
301 * POSIX.1 requires that the macros we test be defined before any standard
302 * header file is included.
303 *
304 * Here's a quick run-down of the versions:
305 * defined(_POSIX_SOURCE) 1003.1-1988
306 * _POSIX_C_SOURCE == 1 1003.1-1990
307 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
308 * _POSIX_C_SOURCE == 199309 1003.1b-1993
309 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
310 * and the omnibus ISO/IEC 9945-1: 1996
311 * _POSIX_C_SOURCE == 200112 1003.1-2001
312 *
313 * In addition, the X/Open Portability Guide, which is now the Single UNIX
314 * Specification, defines a feature-test macro which indicates the version of
315 * that specification, and which subsumes _POSIX_C_SOURCE.
316 *
317 * Our macros begin with two underscores to avoid namespace screwage.
318 */
319
320/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
321#if _POSIX_C_SOURCE == 1
322#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
323#define _POSIX_C_SOURCE 199009
324#endif
325
326/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
327#if _POSIX_C_SOURCE == 2
328#undef _POSIX_C_SOURCE
329#define _POSIX_C_SOURCE 199209
330#endif
331
332/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
333#ifdef _XOPEN_SOURCE
334#if _XOPEN_SOURCE - 0 >= 600
335#define __XSI_VISIBLE 600
336#undef _POSIX_C_SOURCE
337#define _POSIX_C_SOURCE 200112
338#elif _XOPEN_SOURCE - 0 >= 500
339#define __XSI_VISIBLE 500
340#undef _POSIX_C_SOURCE
341#define _POSIX_C_SOURCE 199506
342#endif
343#endif
344
345/*
346 * Deal with all versions of POSIX. The ordering relative to the tests above is
347 * important.
348 */
349#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
350#define _POSIX_C_SOURCE 198808
351#endif
352#ifdef _POSIX_C_SOURCE
353#if _POSIX_C_SOURCE >= 200112
354#define __POSIX_VISIBLE 200112
355#define __ISO_C_VISIBLE 1999
356#elif _POSIX_C_SOURCE >= 199506
357#define __POSIX_VISIBLE 199506
358#define __ISO_C_VISIBLE 1990
359#elif _POSIX_C_SOURCE >= 199309
360#define __POSIX_VISIBLE 199309
361#define __ISO_C_VISIBLE 1990
362#elif _POSIX_C_SOURCE >= 199209
363#define __POSIX_VISIBLE 199209
364#define __ISO_C_VISIBLE 1990
365#elif _POSIX_C_SOURCE >= 199009
366#define __POSIX_VISIBLE 199009
367#define __ISO_C_VISIBLE 1990
368#else
369#define __POSIX_VISIBLE 198808
370#define __ISO_C_VISIBLE 0
371#endif /* _POSIX_C_SOURCE */
372#else
373/*-
374 * Deal with _ANSI_SOURCE:
375 * If it is defined, and no other compilation environment is explicitly
376 * requested, then define our internal feature-test macros to zero. This
377 * makes no difference to the preprocessor (undefined symbols in preprocessing
378 * expressions are defined to have value zero), but makes it more convenient for
379 * a test program to print out the values.
380 *
381 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
382 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
383 * environment (and in fact we will never get here).
384 */
385#if defined(_ANSI_SOURCE) /* Hide almost everything. */
386#define __POSIX_VISIBLE 0
387#define __XSI_VISIBLE 0
388#define __BSD_VISIBLE 0
389#define __ISO_C_VISIBLE 1990
390#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
391#define __POSIX_VISIBLE 0
392#define __XSI_VISIBLE 0
393#define __BSD_VISIBLE 0
394#define __ISO_C_VISIBLE 1999
395#else /* Default environment: show everything. */
396#define __POSIX_VISIBLE 200112
397#define __XSI_VISIBLE 600
398#define __BSD_VISIBLE 1
399#define __ISO_C_VISIBLE 1999
400#endif
401#endif
402
403/* bird: toolkit pollution */
404#define __TCPPROTO(args) __P(args)
405#define TCPCALL _System
406
407/* zap: For backward compatibility with GCC/EMX */
408#ifndef _System
409#define _System
410#endif
411
412/* bird: include the GNU sys/cdefs.h (which fortunately have another
413 blocker, _SYS_CDEFS_H). */
414#include <sys/gnu/cdefs.h>
415
416#endif /* !_SYS_CDEFS_H_ */
Note: See TracBrowser for help on using the repository browser.