1 /*  $NetBSD: cdefs.h,v 1.58 2004/12/11 05:59:00 christos Exp $  */
2 
3 /*
4  * Copyright (c) 1991, 1993
5  *  The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Berkeley Software Design, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *  @(#)cdefs.h 8.8 (Berkeley) 1/9/95
35  */
36 
37 /*
38  * This is a minimum version of cdefs.h for LK, this might be
39  * modified if necessary
40  */
41 #ifndef _SYS_CDEFS_H_
42 #define _SYS_CDEFS_H_
43 
44 // Pull in a bunch of similar #defines from lk/compiler.h and redefine them here
45 // as the cdefs version.
46 #include <lk/compiler.h>
47 
48 #define __always_inline __ALWAYS_INLINE
49 #define __malloc_like __MALLOC
50 #define __pure __PURE
51 #define __pure2 __CONST
52 #define __unreachable __UNREACHABLE
53 #define __unused __UNUSED
54 #define __used __USED
55 
56 #define __BEGIN_DECLS __BEGIN_CDECLS
57 #define __END_DECLS __END_CDECLS
58 
59 /*-
60  * Deal with _ANSI_SOURCE:
61  * If it is defined, and no other compilation environment is explicitly
62  * requested, then define our internal feature-test macros to zero.  This
63  * makes no difference to the preprocessor (undefined symbols in preprocessing
64  * expressions are defined to have value zero), but makes it more convenient for
65  * a test program to print out the values.
66  *
67  * If a program mistakenly defines _ANSI_SOURCE and some other macro such as
68  * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
69  * environment (and in fact we will never get here).
70  */
71 #if defined(_ANSI_SOURCE)   /* Hide almost everything. */
72 #define __POSIX_VISIBLE     0
73 #define __XSI_VISIBLE       0
74 #define __BSD_VISIBLE       0
75 #define __ISO_C_VISIBLE     1990
76 #elif defined(_C99_SOURCE)  /* Localism to specify strict C99 env. */
77 #define __POSIX_VISIBLE     0
78 #define __XSI_VISIBLE       0
79 #define __BSD_VISIBLE       0
80 #define __ISO_C_VISIBLE     1999
81 #else               /* Default environment: show everything. */
82 #define __POSIX_VISIBLE     200809
83 #define __XSI_VISIBLE       700
84 #define __BSD_VISIBLE       1
85 #define __ISO_C_VISIBLE     1999
86 #endif
87 
88 /*
89  * Default values.
90  */
91 #ifndef __XPG_VISIBLE
92 # define __XPG_VISIBLE          700
93 #endif
94 #ifndef __POSIX_VISIBLE
95 # define __POSIX_VISIBLE        200809
96 #endif
97 #ifndef __ISO_C_VISIBLE
98 # define __ISO_C_VISIBLE        1999
99 #endif
100 #ifndef __BSD_VISIBLE
101 # define __BSD_VISIBLE          1
102 #endif
103 
104 /*
105  * Some of the FreeBSD sources used in Bionic need this.
106  * Originally, this is used to embed the rcs versions of each source file
107  * in the generated binary. We certainly don't want this in Bionic.
108  */
109 #define __FBSDID(s) /* nothing */
110 
111 /*
112  * Macro to test if we're using a GNU C compiler of a specific vintage
113  * or later, for e.g. features that appeared in a particular version
114  * of GNU C.  Usage:
115  *
116  *  #if __GNUC_PREREQ__(major, minor)
117  *  ...cool feature...
118  *  #else
119  *  ...delete feature...
120  *  #endif
121  */
122 #ifdef __GNUC__
123 #define __GNUC_PREREQ__(x, y)                       \
124     ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||          \
125      (__GNUC__ > (x)))
126 #else
127 #define __GNUC_PREREQ__(x, y)   0
128 #endif
129 
130 #if defined(__cplusplus)
131 #define __inline    inline      /* convert to C++ keyword */
132 #else
133 #if !defined(__GNUC__) && !defined(__lint__)
134 #define __inline            /* delete GCC keyword */
135 #endif /* !__GNUC__  && !__lint__ */
136 #endif /* !__cplusplus */
137 
138 #endif /* !_SYS_CDEFS_H_ */
139