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

Last change on this file since 1705 was 1705, checked in by bird, 21 years ago

wide-char and other locale stuff.

  • Property cvs2svn:cvs-rev set to 1.11
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 16.7 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 * 4. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)cdefs.h 8.8 (Berkeley) 1/9/95
33 * $FreeBSD: src/sys/sys/cdefs.h,v 1.84 2004/08/13 00:53:40 julian Exp $
34 */
35
36/** @file
37 * FreeBSD 5.2
38 *
39 * @changed bird: Toolkit compatibility (_CDEFS_H_ and __TCPROTO()).
40 * @changed zap: _System definition for older GCC compilers.
41 * @changed bird: Check if stuff is defined before accessing it in #if. Stops -Wundef
42 * from bitching.
43 */
44
45
46#ifndef _SYS_CDEFS_H_
47#define _SYS_CDEFS_H_
48#define _CDEFS_H_ /* bird: compatability */
49
50#if defined(__cplusplus)
51#define __BEGIN_DECLS extern "C" {
52#define __END_DECLS }
53#else
54#define __BEGIN_DECLS
55#define __END_DECLS
56#endif
57
58/*
59 * Macro to test if we're using a specific version of gcc or later.
60 */
61#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
62#define __GNUC_PREREQ__(ma, mi) \
63 (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
64#else
65#define __GNUC_PREREQ__(ma, mi) 0
66#endif
67
68/*
69 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
70 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
71 * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI
72 * mode -- there must be no spaces between its arguments, and for nested
73 * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also
74 * concatenate double-quoted strings produced by the __STRING macro, but
75 * this only works with ANSI C.
76 *
77 * __XSTRING is like __STRING, but it expands any macros in its argument
78 * first. It is only available with ANSI C.
79 */
80#if defined(__STDC__) || defined(__cplusplus)
81#define __P(protos) protos /* full-blown ANSI C */
82#define __CONCAT1(x,y) x ## y
83#define __CONCAT(x,y) __CONCAT1(x,y)
84#define __STRING(x) #x /* stringify without expanding x */
85#define __XSTRING(x) __STRING(x) /* expand x, then stringify */
86
87#define __const const /* define reserved names to standard */
88#define __signed signed
89#define __volatile volatile
90#if defined(__cplusplus)
91#define __inline inline /* convert to C++ keyword */
92#else
93#if !(defined(__GNUC__) || defined(__INTEL_COMPILER))
94#define __inline /* delete GCC keyword */
95#endif /* !(__GNUC__ || __INTEL_COMPILER) */
96#endif /* !__cplusplus */
97
98#else /* !(__STDC__ || __cplusplus) */
99#define __P(protos) () /* traditional C preprocessor */
100#define __CONCAT(x,y) x/**/y
101#define __STRING(x) "x"
102
103#if !(defined(__GNUC__) || defined(__INTEL_COMPILER))
104#define __const /* delete pseudo-ANSI C keywords */
105#define __inline
106#define __signed
107#define __volatile
108/*
109 * In non-ANSI C environments, new programs will want ANSI-only C keywords
110 * deleted from the program and old programs will want them left alone.
111 * When using a compiler other than gcc, programs using the ANSI C keywords
112 * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
113 * When using "gcc -traditional", we assume that this is the intent; if
114 * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
115 */
116#ifndef NO_ANSI_KEYWORDS
117#define const /* delete ANSI C keywords */
118#define inline
119#define signed
120#define volatile
121#endif /* !NO_ANSI_KEYWORDS */
122#endif /* !(__GNUC__ || __INTEL_COMPILER) */
123#endif /* !(__STDC__ || __cplusplus) */
124
125/*
126 * Compiler-dependent macros to help declare dead (non-returning) and
127 * pure (no side effects) functions, and unused variables. They are
128 * null except for versions of gcc that are known to support the features
129 * properly (old versions of gcc-2 supported the dead and pure features
130 * in a different (wrong) way). If we do not provide an implementation
131 * for a given compiler, let the compile fail if it is told to use
132 * a feature that we cannot live without.
133 */
134#ifdef lint
135#define __dead2
136#define __pure2
137#define __unused
138#define __packed
139#define __aligned(x)
140#define __section(x)
141#else
142#if !__GNUC_PREREQ__(2, 5) && !defined(__INTEL_COMPILER)
143#define __dead2
144#define __pure2
145#define __unused
146#endif
147#if __GNUC__ == 2 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 7 && !defined(__INTEL_COMPILER)
148#define __dead2 __attribute__((__noreturn__))
149#define __pure2 __attribute__((__const__))
150#define __unused
151/* XXX Find out what to do for __packed, __aligned and __section */
152#endif
153#if __GNUC_PREREQ__(2, 7)
154#define __dead2 __attribute__((__noreturn__))
155#define __pure2 __attribute__((__const__))
156#define __unused __attribute__((__unused__))
157#define __used __attribute__((__used__))
158#define __packed __attribute__((__packed__))
159#define __aligned(x) __attribute__((__aligned__(x)))
160#define __section(x) __attribute__((__section__(x)))
161#endif
162#if defined(__INTEL_COMPILER)
163#define __dead2 __attribute__((__noreturn__))
164#define __pure2 __attribute__((__const__))
165#define __unused __attribute__((__unused__))
166#define __used __attribute__((__used__))
167#define __packed __attribute__((__packed__))
168#define __aligned(x) __attribute__((__aligned__(x)))
169#define __section(x) __attribute__((__section__(x)))
170#endif
171#endif
172
173#if __GNUC_PREREQ__(2, 96)
174#define __pure __attribute__((__pure__))
175#else
176#define __pure
177#endif
178
179#if __GNUC_PREREQ__(3, 1) || (defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 800)
180#define __always_inline __attribute__((__always_inline__))
181#else
182#define __always_inline
183#endif
184
185#if __GNUC_PREREQ__(3, 3)
186#define __nonnull(x) __attribute__((__nonnull__(x)))
187#else
188#define __nonnull(x)
189#endif
190
191/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
192#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
193#define __func__ NULL
194#endif
195
196#if (defined(__INTEL_COMPILER) || (defined(__GNUC__) && __GNUC__ >= 2)) && !defined(__STRICT_ANSI__) || __STDC_VERSION__ >= 199901
197#define __LONG_LONG_SUPPORTED
198#endif
199
200/*
201 * GCC 2.95 provides `__restrict' as an extension to C90 to support the
202 * C99-specific `restrict' type qualifier. We happen to use `__restrict' as
203 * a way to define the `restrict' type qualifier without disturbing older
204 * software that is unaware of C99 keywords.
205 */
206#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95)
207#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901
208#define __restrict
209#else
210#define __restrict restrict
211#endif
212#endif
213
214/*
215 * GNU C version 2.96 adds explicit branch prediction so that
216 * the CPU back-end can hint the processor and also so that
217 * code blocks can be reordered such that the predicted path
218 * sees a more linear flow, thus improving cache behavior, etc.
219 *
220 * The following two macros provide us with a way to utilize this
221 * compiler feature. Use __predict_true() if you expect the expression
222 * to evaluate to true, and __predict_false() if you expect the
223 * expression to evaluate to false.
224 *
225 * A few notes about usage:
226 *
227 * * Generally, __predict_false() error condition checks (unless
228 * you have some _strong_ reason to do otherwise, in which case
229 * document it), and/or __predict_true() `no-error' condition
230 * checks, assuming you want to optimize for the no-error case.
231 *
232 * * Other than that, if you don't know the likelihood of a test
233 * succeeding from empirical or other `hard' evidence, don't
234 * make predictions.
235 *
236 * * These are meant to be used in places that are run `a lot'.
237 * It is wasteful to make predictions in code that is run
238 * seldomly (e.g. at subsystem initialization time) as the
239 * basic block reordering that this affects can often generate
240 * larger code.
241 */
242#if __GNUC_PREREQ__(2, 96)
243#define __predict_true(exp) __builtin_expect((exp), 1)
244#define __predict_false(exp) __builtin_expect((exp), 0)
245#else
246#define __predict_true(exp) (exp)
247#define __predict_false(exp) (exp)
248#endif
249
250/*
251 * We define this here since <stddef.h>, <sys/queue.h>, and <sys/types.h>
252 * require it.
253 */
254#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
255#define __rangeof(type, start, end) \
256 (__offsetof(type, end) - __offsetof(type, start))
257
258/*
259 * Compiler-dependent macros to declare that functions take printf-like
260 * or scanf-like arguments. They are null except for versions of gcc
261 * that are known to support the features properly (old versions of gcc-2
262 * didn't permit keeping the keywords out of the application namespace).
263 */
264#if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
265#define __printflike(fmtarg, firstvararg)
266#define __scanflike(fmtarg, firstvararg)
267#else
268#define __printflike(fmtarg, firstvararg) \
269 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
270#define __scanflike(fmtarg, firstvararg) \
271 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
272#endif
273
274/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
275#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && defined(__GNUC__) && !defined(__INTEL_COMPILER) /* bird: check if defined to avoid -Wundef messages */
276#define __printf0like(fmtarg, firstvararg) \
277 __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
278#else
279#define __printf0like(fmtarg, firstvararg)
280#endif
281
282#if 0 /* defined(__GNUC__) || defined(__INTEL_COMPILER) - bird: ELF specific, so skip everything */
283#ifndef __INTEL_COMPILER
284#define __strong_reference(sym,aliassym) \
285 extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)));
286#endif
287#ifdef __STDC__
288#define __weak_reference(sym,alias) \
289 __asm__(".weak " #alias); \
290 __asm__(".equ " #alias ", " #sym)
291#define __warn_references(sym,msg) \
292 __asm__(".section .gnu.warning." #sym); \
293 __asm__(".asciz \"" msg "\""); \
294 __asm__(".previous")
295#else
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\""); \
302 __asm__(".previous")
303#endif /* __STDC__ */
304#endif /* __GNUC__ || __INTEL_COMPILER */
305
306#if 0 /* defined(__GNUC__) || defined(__INTEL_COMPILER) - ELF specific. */
307#define __IDSTRING(name,string) __asm__(".ident\t\"" string "\"")
308#else
309/*
310 * The following definition might not work well if used in header files,
311 * but it should be better than nothing. If you want a "do nothing"
312 * version, then it should generate some harmless declaration, such as:
313 * #define __IDSTRING(name,string) struct __hack
314 */
315#define __IDSTRING(name,string) static const char name[] __unused = string
316#endif
317
318/*
319 * Embed the rcs id of a source file in the resulting library. Note that in
320 * more recent ELF binutils, we use .ident allowing the ID to be stripped.
321 * Usage:
322 * __FBSDID("$FreeBSD: src/sys/sys/cdefs.h,v 1.84 2004/08/13 00:53:40 julian Exp $");
323 */
324#ifndef __FBSDID
325#if !defined(lint) && !defined(STRIP_FBSDID)
326#define __FBSDID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
327#else
328#define __FBSDID(s) struct __hack
329#endif
330#endif
331
332#ifndef __RCSID
333#ifndef NO__RCSID
334#define __RCSID(s) __IDSTRING(__CONCAT(__rcsid_,__LINE__),s)
335#else
336#define __RCSID(s) struct __hack
337#endif
338#endif
339
340#ifndef __RCSID_SOURCE
341#ifndef NO__RCSID_SOURCE
342#define __RCSID_SOURCE(s) __IDSTRING(__CONCAT(__rcsid_source_,__LINE__),s)
343#else
344#define __RCSID_SOURCE(s) struct __hack
345#endif
346#endif
347
348#ifndef __SCCSID
349#ifndef NO__SCCSID
350#define __SCCSID(s) __IDSTRING(__CONCAT(__sccsid_,__LINE__),s)
351#else
352#define __SCCSID(s) struct __hack
353#endif
354#endif
355
356#ifndef __COPYRIGHT
357#ifndef NO__COPYRIGHT
358#define __COPYRIGHT(s) __IDSTRING(__CONCAT(__copyright_,__LINE__),s)
359#else
360#define __COPYRIGHT(s) struct __hack
361#endif
362#endif
363
364#ifndef __DECONST
365#define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
366#endif
367
368#ifndef __DEVOLATILE
369#define __DEVOLATILE(type, var) ((type)(uintptr_t)(volatile void *)(var))
370#endif
371
372#ifndef __DEQUALIFY
373#define __DEQUALIFY(type, var) ((type)(uintptr_t)(const volatile void *)(var))
374#endif
375
376/*-
377 * The following definitions are an extension of the behavior originally
378 * implemented in <sys/_posix.h>, but with a different level of granularity.
379 * POSIX.1 requires that the macros we test be defined before any standard
380 * header file is included.
381 *
382 * Here's a quick run-down of the versions:
383 * defined(_POSIX_SOURCE) 1003.1-1988
384 * _POSIX_C_SOURCE == 1 1003.1-1990
385 * _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
386 * _POSIX_C_SOURCE == 199309 1003.1b-1993
387 * _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
388 * and the omnibus ISO/IEC 9945-1: 1996
389 * _POSIX_C_SOURCE == 200112 1003.1-2001
390 *
391 * In addition, the X/Open Portability Guide, which is now the Single UNIX
392 * Specification, defines a feature-test macro which indicates the version of
393 * that specification, and which subsumes _POSIX_C_SOURCE.
394 *
395 * Our macros begin with two underscores to avoid namespace screwage.
396 */
397
398/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
399#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
400#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
401#define _POSIX_C_SOURCE 199009
402#endif
403
404/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
405#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
406#undef _POSIX_C_SOURCE
407#define _POSIX_C_SOURCE 199209
408#endif
409
410/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
411#ifdef _XOPEN_SOURCE
412#if _XOPEN_SOURCE - 0 >= 600
413#define __XSI_VISIBLE 600
414#undef _POSIX_C_SOURCE
415#define _POSIX_C_SOURCE 200112
416#elif _XOPEN_SOURCE - 0 >= 500
417#define __XSI_VISIBLE 500
418#undef _POSIX_C_SOURCE
419#define _POSIX_C_SOURCE 199506
420#endif
421#endif
422
423/*
424 * Deal with all versions of POSIX. The ordering relative to the tests above is
425 * important.
426 */
427#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
428#define _POSIX_C_SOURCE 198808
429#endif
430#ifdef _POSIX_C_SOURCE
431#if _POSIX_C_SOURCE >= 200112
432#define __POSIX_VISIBLE 200112
433#define __ISO_C_VISIBLE 1999
434#elif _POSIX_C_SOURCE >= 199506
435#define __POSIX_VISIBLE 199506
436#define __ISO_C_VISIBLE 1990
437#elif _POSIX_C_SOURCE >= 199309
438#define __POSIX_VISIBLE 199309
439#define __ISO_C_VISIBLE 1990
440#elif _POSIX_C_SOURCE >= 199209
441#define __POSIX_VISIBLE 199209
442#define __ISO_C_VISIBLE 1990
443#elif _POSIX_C_SOURCE >= 199009
444#define __POSIX_VISIBLE 199009
445#define __ISO_C_VISIBLE 1990
446#else
447#define __POSIX_VISIBLE 198808
448#define __ISO_C_VISIBLE 0
449#endif /* _POSIX_C_SOURCE */
450#else
451/*-
452 * Deal with _ANSI_SOURCE:
453 * If it is defined, and no other compilation environment is explicitly
454 * requested, then define our internal feature-test macros to zero. This
455 * makes no difference to the preprocessor (undefined symbols in preprocessing
456 * expressions are defined to have value zero), but makes it more convenient for
457 * a test program to print out the values.
458 *
459 * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
460 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
461 * environment (and in fact we will never get here).
462 */
463#if defined(_ANSI_SOURCE) /* Hide almost everything. */
464#define __POSIX_VISIBLE 0
465#define __XSI_VISIBLE 0
466#define __BSD_VISIBLE 0
467#define __ISO_C_VISIBLE 1990
468#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
469#define __POSIX_VISIBLE 0
470#define __XSI_VISIBLE 0
471#define __BSD_VISIBLE 0
472#define __ISO_C_VISIBLE 1999
473#else /* Default environment: show everything. */
474#define __POSIX_VISIBLE 200112
475#define __XSI_VISIBLE 600
476#define __BSD_VISIBLE 1
477#define __ISO_C_VISIBLE 1999
478#endif
479#endif
480
481/* bird: toolkit pollution */
482#define __TCPPROTO(args) __P(args)
483#define TCPCALL _System
484
485/* zap: For backward compatibility with GCC/EMX */
486#ifndef _System
487#define _System
488#endif
489
490/* bird: include the GNU sys/cdefs.h (which fortunately have another
491 blocker, _SYS_CDEFS_H). */
492#include <sys/gnu/cdefs.h>
493
494#endif /* !_SYS_CDEFS_H_ */
Note: See TracBrowser for help on using the repository browser.