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

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

#427: FreeBSD 5.1 level.

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