1/*	$NetBSD: cdefs.h,v 1.18 1997/06/18 19:09:50 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. 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.
25 *
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
36 * SUCH DAMAGE.
37 *
38 *	@(#)cdefs.h	8.7 (Berkeley) 1/21/94
39 */
40
41#ifndef	_SYS_CDEFS_H_
42
43#if defined(NEED_HOST_CDEFS_H)
44/*
45 * make sure we don't come past here again.
46 */
47#undef NEED_HOST_CDEFS_H
48/*
49 * Some systems - notably linux, have sys/cdefs.h
50 * which is not really compatible with our's.
51 */
52#ifdef __GNUC__
53# include_next <sys/cdefs.h>
54#else
55/*
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
58 * should be few.
59 */
60# include "/usr/include/sys/cdefs.h"
61#endif
62/*
63 * We are about to [re]define these
64 */
65#undef __P
66#undef _SYS_CDEFS_H_
67#endif
68
69#define	_SYS_CDEFS_H_
70
71#ifdef NetBSD
72#include <machine/cdefs.h>
73#endif
74
75#if defined(__cplusplus)
76#  ifndef __BEGIN_DECLS
77#  define __BEGIN_DECLS	extern "C" {
78#  endif
79#  ifndef __END_DECLS
80#  define __END_DECLS	};
81#  endif
82#else
83#  ifndef __BEGIN_DECLS
84#  define __BEGIN_DECLS
85#  endif
86#  ifndef __END_DECLS
87#  define __END_DECLS
88#  endif
89#endif
90
91/*
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.
97 */
98#if defined(__STDC__) || defined(__cplusplus)
99#define	__P(protos)	protos		/* full-blown ANSI C */
100#ifndef __CONCAT
101#define	__CONCAT(x,y)	x ## y
102#endif
103#define	__STRING(x)	#x
104
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 */
110#else
111#ifndef __GNUC__
112#define	__inline			/* delete GCC keyword */
113#endif /* !__GNUC__ */
114#endif /* !__cplusplus */
115
116#else	/* !(__STDC__ || __cplusplus) */
117#define	__P(protos)	()		/* traditional C preprocessor */
118#define	__CONCAT(x,y)	x/**/y
119#define	__STRING(x)	"x"
120
121#ifndef __GNUC__
122#define	__const				/* delete pseudo-ANSI C keywords */
123#define	__inline
124#define	__signed
125#define	__volatile
126#endif	/* !__GNUC__ */
127
128/*
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.
133 */
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) */
141
142/*
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).
149 */
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
156#endif
157#endif
158
159#ifdef sun386
160# define __attribute__(x)
161#endif
162
163#ifdef __KPRINTF_ATTRIBUTE__
164#define __kprintf_attribute__(a) __attribute__(a)
165#else
166#define __kprintf_attribute__(a)
167#endif
168
169/* Delete pseudo-keywords wherever they are not available or needed. */
170#ifndef __dead
171#define	__dead
172#define	__pure
173#endif
174
175#define __IDSTRING(name,string) \
176	static const char name[] __attribute__((__unused__)) = string
177
178#ifndef __RCSID
179#define __RCSID(s) __IDSTRING(rcsid,s)
180#endif
181
182#ifndef __COPYRIGHT
183#define __COPYRIGHT(s) __IDSTRING(copyright,s)
184#endif
185
186#endif /* !_SYS_CDEFS_H_ */
187