1 /* $NetBSD: cdefs.h,v 1.18 1997/06/18 19:09:50 christos Exp $ */
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Berkeley Software Design, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * @(#)cdefs.h 8.7 (Berkeley) 1/21/94
43 #if defined(NEED_HOST_CDEFS_H)
45 * make sure we don't come past here again.
47 #undef NEED_HOST_CDEFS_H
49 * Some systems - notably linux, have sys/cdefs.h
50 * which is not really compatible with our's.
53 # include_next <sys/cdefs.h>
56 * It sucks that we have to hard code a path like this.
57 * But systems that have a sys/cdefs.h that don't use gcc
60 # include "/usr/include/sys/cdefs.h"
63 * We are about to [re]define these
72 #include <machine/cdefs.h>
75 #if defined(__cplusplus)
76 # ifndef __BEGIN_DECLS
77 # define __BEGIN_DECLS extern "C" {
80 # define __END_DECLS };
83 # ifndef __BEGIN_DECLS
84 # define __BEGIN_DECLS
92 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
93 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
94 * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
95 * in between its arguments. __CONCAT can also concatenate double-quoted
96 * strings produced by the __STRING macro, but this only works with ANSI C.
98 #if defined(__STDC__) || defined(__cplusplus)
99 #define __P(protos) protos /* full-blown ANSI C */
101 #define __CONCAT(x,y) x ## y
103 #define __STRING(x) #x
105 #define __const const /* define reserved names to standard */
106 #define __signed signed
107 #define __volatile volatile
108 #if defined(__cplusplus)
109 #define __inline inline /* convert to C++ keyword */
112 #define __inline /* delete GCC keyword */
113 #endif /* !__GNUC__ */
114 #endif /* !__cplusplus */
116 #else /* !(__STDC__ || __cplusplus) */
117 #define __P(protos) () /* traditional C preprocessor */
118 #define __CONCAT(x,y) x/**/y
119 #define __STRING(x) "x"
122 #define __const /* delete pseudo-ANSI C keywords */
126 #endif /* !__GNUC__ */
129 * In non-ANSI C environments, new programs will want ANSI-only C keywords
130 * deleted from the program and old programs will want them left alone.
131 * Programs using the ANSI C keywords const, inline etc. as normal
132 * identifiers should define -DNO_ANSI_KEYWORDS.
134 #ifndef NO_ANSI_KEYWORDS
135 #define const __const /* convert ANSI C keywords */
136 #define inline __inline
137 #define signed __signed
138 #define volatile __volatile
139 #endif /* !NO_ANSI_KEYWORDS */
140 #endif /* !(__STDC__ || __cplusplus) */
143 * GCC1 and some versions of GCC2 declare dead (non-returning) and
144 * pure (no side effects) functions using "volatile" and "const";
145 * unfortunately, these then cause warnings under "-ansi -pedantic".
146 * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
147 * these work for GNU C++ (modulo a slight glitch in the C++ grammar
148 * in the distribution version of 2.5.5).
150 #if !defined(__GNUC__) || __GNUC__ < 2 || \
151 (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
152 #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
153 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
154 #define __dead __volatile
155 #define __pure __const
160 # define __attribute__(x)
163 #ifdef __KPRINTF_ATTRIBUTE__
164 #define __kprintf_attribute__(a) __attribute__(a)
166 #define __kprintf_attribute__(a)
169 /* Delete pseudo-keywords wherever they are not available or needed. */
175 #define __IDSTRING(name,string) \
176 static const char name[] __attribute__((__unused__)) = string
179 #define __RCSID(s) __IDSTRING(rcsid,s)
183 #define __COPYRIGHT(s) __IDSTRING(copyright,s)
186 #endif /* !_SYS_CDEFS_H_ */