xref: /original-bsd/sys/sys/cdefs.h (revision 95ecee29)
1 /*
2  * Copyright (c) 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)cdefs.h	8.2 (Berkeley) 10/04/93
8  */
9 
10 #ifndef	_CDEFS_H_
11 #define	_CDEFS_H_
12 
13 #if defined(__cplusplus)
14 #define	__BEGIN_DECLS	extern "C" {
15 #define	__END_DECLS	};
16 #else
17 #define	__BEGIN_DECLS
18 #define	__END_DECLS
19 #endif
20 
21 /*
22  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
23  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
24  * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
25  * in between its arguments.  __CONCAT can also concatenate double-quoted
26  * strings produced by the __STRING macro, but this only works with ANSI C.
27  */
28 #if defined(__STDC__) || defined(__cplusplus)
29 #define	__P(protos)	protos		/* full-blown ANSI C */
30 #define	__CONCAT(x,y)	x ## y
31 #define	__STRING(x)	#x
32 
33 #if !defined(__GNUC__) && !defined(__cplusplus)
34 #define	inline
35 #endif
36 
37 #else	/* !(__STDC__ || __cplusplus) */
38 #define	__P(protos)	()		/* traditional C preprocessor */
39 #define	__CONCAT(x,y)	x/**/y
40 #define	__STRING(x)	"x"
41 
42 #ifdef __GNUC__
43 #define	const		__const		/* GCC: ANSI C with -traditional */
44 #define	inline		__inline
45 #define	signed		__signed
46 #define	volatile	__volatile
47 
48 #else	/* !__GNUC__ */
49 #define	const				/* delete ANSI C keywords */
50 #define	inline
51 #define	signed
52 #define	volatile
53 #endif	/* !__GNUC__ */
54 #endif	/* !(__STDC__ || __cplusplus) */
55 
56 /*
57  * GCC has extensions for declaring functions as `pure' (always returns
58  * the same value given the same inputs, i.e., has no external state and
59  * no side effects) and `dead' (nonreturning).  These mainly affect
60  * optimization and warnings.  Unfortunately, GCC complains if these are
61  * used under strict ANSI mode (`gcc -ansi -pedantic'), hence we need to
62  * define them only if compiling without this.
63  */
64 #if defined(__GNUC__) && !defined(__STRICT_ANSI__)
65 #define __dead __volatile
66 #define __pure __const
67 #else
68 #define __dead
69 #define __pure
70 #endif
71 
72 #endif /* !_CDEFS_H_ */
73