1*b5677b36Schristos /*	$NetBSD: cdefs.h,v 1.1.1.1 2009/04/12 15:33:55 christos Exp $	*/
2*b5677b36Schristos 
3*b5677b36Schristos /*
4*b5677b36Schristos  * Copyright (c) 1991, 1993
5*b5677b36Schristos  *	The Regents of the University of California.  All rights reserved.
6*b5677b36Schristos  *
7*b5677b36Schristos  * This code is derived from software contributed to Berkeley by
8*b5677b36Schristos  * Berkeley Software Design, Inc.
9*b5677b36Schristos  *
10*b5677b36Schristos  * Redistribution and use in source and binary forms, with or without
11*b5677b36Schristos  * modification, are permitted provided that the following conditions
12*b5677b36Schristos  * are met:
13*b5677b36Schristos  * 1. Redistributions of source code must retain the above copyright
14*b5677b36Schristos  *    notice, this list of conditions and the following disclaimer.
15*b5677b36Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16*b5677b36Schristos  *    notice, this list of conditions and the following disclaimer in the
17*b5677b36Schristos  *    documentation and/or other materials provided with the distribution.
18*b5677b36Schristos  * 3. All advertising materials mentioning features or use of this software
19*b5677b36Schristos  *    must display the following acknowledgement:
20*b5677b36Schristos  *	This product includes software developed by the University of
21*b5677b36Schristos  *	California, Berkeley and its contributors.
22*b5677b36Schristos  * 4. Neither the name of the University nor the names of its contributors
23*b5677b36Schristos  *    may be used to endorse or promote products derived from this software
24*b5677b36Schristos  *    without specific prior written permission.
25*b5677b36Schristos  *
26*b5677b36Schristos  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27*b5677b36Schristos  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28*b5677b36Schristos  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29*b5677b36Schristos  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30*b5677b36Schristos  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31*b5677b36Schristos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32*b5677b36Schristos  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33*b5677b36Schristos  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34*b5677b36Schristos  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35*b5677b36Schristos  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36*b5677b36Schristos  * SUCH DAMAGE.
37*b5677b36Schristos  *
38*b5677b36Schristos  *	@(#)cdefs.h	8.7 (Berkeley) 1/21/94
39*b5677b36Schristos  */
40*b5677b36Schristos 
41*b5677b36Schristos #ifndef	_CDEFS_H_
42*b5677b36Schristos #define	_CDEFS_H_
43*b5677b36Schristos 
44*b5677b36Schristos /* POSIX.2 feature test macro: enable POSIX.1 and/or more */
45*b5677b36Schristos #if _POSIX_C_SOURCE == 1 || _POSIX_C_SOURCE == 2
46*b5677b36Schristos #define	_POSIX_SOURCE
47*b5677b36Schristos #endif
48*b5677b36Schristos 
49*b5677b36Schristos #if defined(_POSIX_SOURCE) || defined(__STRICT_ANSI__)
50*b5677b36Schristos #define	_ANSI_SOURCE
51*b5677b36Schristos #endif
52*b5677b36Schristos 
53*b5677b36Schristos #if defined(__cplusplus)
54*b5677b36Schristos #define	__BEGIN_DECLS	extern "C" {
55*b5677b36Schristos #define	__END_DECLS	};
56*b5677b36Schristos #else
57*b5677b36Schristos #define	__BEGIN_DECLS
58*b5677b36Schristos #define	__END_DECLS
59*b5677b36Schristos #endif
60*b5677b36Schristos 
61*b5677b36Schristos /*
62*b5677b36Schristos  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
63*b5677b36Schristos  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
64*b5677b36Schristos  * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
65*b5677b36Schristos  * in between its arguments.  __CONCAT can also concatenate double-quoted
66*b5677b36Schristos  * strings produced by the __STRING macro, but this only works with ANSI C.
67*b5677b36Schristos  */
68*b5677b36Schristos #if defined(__STDC__) || defined(__cplusplus)
69*b5677b36Schristos #define	__P(protos)	protos		/* full-blown ANSI C */
70*b5677b36Schristos #define	__CONCAT(x,y)	x ## y
71*b5677b36Schristos #define	__STRING(x)	#x
72*b5677b36Schristos 
73*b5677b36Schristos #define	__const		const		/* define reserved names to standard */
74*b5677b36Schristos #define	__signed	signed
75*b5677b36Schristos #define	__volatile	volatile
76*b5677b36Schristos #if defined(__cplusplus)
77*b5677b36Schristos #define	__inline	inline		/* convert to C++ keyword */
78*b5677b36Schristos #else
79*b5677b36Schristos #ifndef __GNUC__
80*b5677b36Schristos #define	__inline			/* delete GCC keyword */
81*b5677b36Schristos #endif /* !__GNUC__ */
82*b5677b36Schristos #endif /* !__cplusplus */
83*b5677b36Schristos 
84*b5677b36Schristos #else	/* !(__STDC__ || __cplusplus) */
85*b5677b36Schristos #define	__P(protos)	()		/* traditional C preprocessor */
86*b5677b36Schristos #define	__CONCAT(x,y)	x/**/y
87*b5677b36Schristos #define	__STRING(x)	"x"
88*b5677b36Schristos 
89*b5677b36Schristos #ifndef __GNUC__
90*b5677b36Schristos #define	__const				/* delete pseudo-ANSI C keywords */
91*b5677b36Schristos #define	__inline
92*b5677b36Schristos #define	__signed
93*b5677b36Schristos #define	__volatile
94*b5677b36Schristos /*
95*b5677b36Schristos  * In non-ANSI C environments, new programs will want ANSI-only C keywords
96*b5677b36Schristos  * deleted from the program and old programs will want them left alone.
97*b5677b36Schristos  * When using a compiler other than gcc, programs using the ANSI C keywords
98*b5677b36Schristos  * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
99*b5677b36Schristos  * When using "gcc -traditional", we assume that this is the intent; if
100*b5677b36Schristos  * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
101*b5677b36Schristos  */
102*b5677b36Schristos #ifndef	NO_ANSI_KEYWORDS
103*b5677b36Schristos #define	const				/* delete ANSI C keywords */
104*b5677b36Schristos #define	inline
105*b5677b36Schristos #define	signed
106*b5677b36Schristos #define	volatile
107*b5677b36Schristos #endif
108*b5677b36Schristos #endif	/* !__GNUC__ */
109*b5677b36Schristos #endif	/* !(__STDC__ || __cplusplus) */
110*b5677b36Schristos 
111*b5677b36Schristos /*
112*b5677b36Schristos  * GCC1 and some versions of GCC2 declare dead (non-returning) and
113*b5677b36Schristos  * pure (no side effects) functions using "volatile" and "const";
114*b5677b36Schristos  * unfortunately, these then cause warnings under "-ansi -pedantic".
115*b5677b36Schristos  * GCC2 uses a new, peculiar __attribute__((attrs)) style.  All of
116*b5677b36Schristos  * these work for GNU C++ (modulo a slight glitch in the C++ grammar
117*b5677b36Schristos  * in the distribution version of 2.5.5).
118*b5677b36Schristos  */
119*b5677b36Schristos #if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
120*b5677b36Schristos #define	__attribute__(x)	/* delete __attribute__ if non-gcc or gcc1 */
121*b5677b36Schristos #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
122*b5677b36Schristos #define	__dead		__volatile
123*b5677b36Schristos #define	__pure		__const
124*b5677b36Schristos #endif
125*b5677b36Schristos #endif
126*b5677b36Schristos /* The following lines were added for newer versions of GNU C
127*b5677b36Schristos  *   Ed Lewis - Sept 1996 lewis@tis.com
128*b5677b36Schristos  */
129*b5677b36Schristos #if __GNUC__ == 2 &&  __GNUC_MINOR__ >= 5 || __GNUC__ >= 3
130*b5677b36Schristos #define __dead
131*b5677b36Schristos #define __dead2     __attribute__((noreturn))
132*b5677b36Schristos #define __pure
133*b5677b36Schristos #define __pure2     __attribute__((const))
134*b5677b36Schristos #endif
135*b5677b36Schristos 
136*b5677b36Schristos 
137*b5677b36Schristos /* Delete pseudo-keywords wherever they are not available or needed. */
138*b5677b36Schristos #ifndef __dead
139*b5677b36Schristos #define	__dead
140*b5677b36Schristos #define	__pure
141*b5677b36Schristos #endif
142*b5677b36Schristos 
143*b5677b36Schristos #endif /* !_CDEFS_H_ */
144