cdefs.h revision 1.20
1/*	$NetBSD: cdefs.h,v 1.20 1997/10/22 05:20:32 thorpej 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#define	_SYS_CDEFS_H_
43
44#include <machine/cdefs.h>
45
46#if defined(__cplusplus)
47#define	__BEGIN_DECLS	extern "C" {
48#define	__END_DECLS	};
49#else
50#define	__BEGIN_DECLS
51#define	__END_DECLS
52#endif
53
54/*
55 * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
56 * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
57 * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
58 * in between its arguments.  __CONCAT can also concatenate double-quoted
59 * strings produced by the __STRING macro, but this only works with ANSI C.
60 */
61#if defined(__STDC__) || defined(__cplusplus)
62#define	__P(protos)	protos		/* full-blown ANSI C */
63#define	__CONCAT(x,y)	x ## y
64#define	__STRING(x)	#x
65
66#define	__const		const		/* define reserved names to standard */
67#define	__signed	signed
68#define	__volatile	volatile
69#if defined(__cplusplus)
70#define	__inline	inline		/* convert to C++ keyword */
71#else
72#ifndef __GNUC__
73#define	__inline			/* delete GCC keyword */
74#endif /* !__GNUC__ */
75#endif /* !__cplusplus */
76
77#else	/* !(__STDC__ || __cplusplus) */
78#define	__P(protos)	()		/* traditional C preprocessor */
79#define	__CONCAT(x,y)	x/**/y
80#define	__STRING(x)	"x"
81
82#ifndef __GNUC__
83#define	__const				/* delete pseudo-ANSI C keywords */
84#define	__inline
85#define	__signed
86#define	__volatile
87#endif	/* !__GNUC__ */
88
89/*
90 * In non-ANSI C environments, new programs will want ANSI-only C keywords
91 * deleted from the program and old programs will want them left alone.
92 * Programs using the ANSI C keywords const, inline etc. as normal
93 * identifiers should define -DNO_ANSI_KEYWORDS.
94 */
95#ifndef	NO_ANSI_KEYWORDS
96#define	const		__const		/* convert ANSI C keywords */
97#define	inline		__inline
98#define	signed		__signed
99#define	volatile	__volatile
100#endif /* !NO_ANSI_KEYWORDS */
101#endif	/* !(__STDC__ || __cplusplus) */
102
103/*
104 * GCC1 and some versions of GCC2 declare dead (non-returning) and
105 * pure (no side effects) functions using "volatile" and "const";
106 * unfortunately, these then cause warnings under "-ansi -pedantic".
107 * GCC2 uses a new, peculiar __attribute__((attrs)) style.  All of
108 * these work for GNU C++ (modulo a slight glitch in the C++ grammar
109 * in the distribution version of 2.5.5).
110 */
111#if !defined(__GNUC__) || __GNUC__ < 2 || \
112	(__GNUC__ == 2 && __GNUC_MINOR__ < 5)
113#define	__attribute__(x)	/* delete __attribute__ if non-gcc or gcc1 */
114#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
115#define	__dead		__volatile
116#define	__pure		__const
117#endif
118#endif
119
120#ifdef __KPRINTF_ATTRIBUTE__
121#define __kprintf_attribute__(a) __attribute__(a)
122#else
123#define __kprintf_attribute__(a)
124#endif
125
126/* Delete pseudo-keywords wherever they are not available or needed. */
127#ifndef __dead
128#define	__dead
129#define	__pure
130#endif
131
132#define __IDSTRING(name,string) \
133	static const char name[] __attribute__((__unused__)) = string
134
135#ifndef __RCSID
136#define __RCSID(s) __IDSTRING(rcsid,s)
137#endif
138
139#ifndef __COPYRIGHT
140#define __COPYRIGHT(s) __IDSTRING(copyright,s)
141#endif
142
143/* This is defined in <machine/cdefs.h> */
144#ifndef __RENAME
145#error "No function renaming possible"
146#endif
147
148#endif /* !_SYS_CDEFS_H_ */
149