xref: /relibc/openlibm/src/bsd_cdefs.h (revision 81053b7fcbbbf8fa13ae45959c112e2d6a0f92c8)
1 /*-
2  * Copyright (c) 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Berkeley Software Design, Inc.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 4. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
33  * $FreeBSD: src/sys/sys/cdefs.h,v 1.114 2011/02/18 21:44:53 nwhitehorn Exp $
34  */
35 
36 /* Do not redefine macros if the system provides them in sys/cdefs.h.
37  * The two macros correspond to different platforms. */
38 #ifndef _BSD_CDEFS_H_
39 #define _BSD_CDEFS_H_
40 
41 /*
42  * This code has been put in place to help reduce the addition of
43  * compiler specific defines in FreeBSD code.  It helps to aid in
44  * having a compiler-agnostic source tree.
45  */
46 
47 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
48 
49 #if __GNUC__ >= 3 || defined(__INTEL_COMPILER)
50 #define __GNUCLIKE_ASM 3
51 #else
52 #define __GNUCLIKE_ASM 2
53 #endif
54 
55 #define __CC_SUPPORTS___INLINE__ 1
56 
57 #endif /* __GNUC__ || __INTEL_COMPILER */
58 
59 #if defined(__STDC__) || defined(__cplusplus)
60 
61 #define	__volatile	volatile
62 #if defined(__cplusplus)
63 #define	__inline	inline		/* convert to C++ keyword */
64 #else
65 #if !defined(__CC_SUPPORTS___INLINE)
66 #define	__inline			/* delete GCC keyword */
67 #endif /* ! __CC_SUPPORTS___INLINE */
68 #endif /* !__cplusplus */
69 
70 #else	/* !(__STDC__ || __cplusplus) */
71 
72 #if !defined(__CC_SUPPORTS___INLINE)
73 #define	__inline
74 #define	__volatile
75 #endif	/* !__CC_SUPPORTS___INLINE */
76 #endif	/* !(__STDC__ || __cplusplus) */
77 
78 /*
79  * Macro to test if we're using a specific version of gcc or later.
80  */
81 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
82 #define	__GNUC_PREREQ__(ma, mi)	\
83 	(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
84 #else
85 #define	__GNUC_PREREQ__(ma, mi)	0
86 #endif
87 
88 /*
89  * Compiler-dependent macro to help declare pure (no side effects) functions.
90  * It is null except for versions of gcc that are known to support the features
91  * properly (old versions of gcc-2 supported the dead and pure features
92  * in a different (wrong) way), and for icc.  If we do not provide an implementation
93  * for a given compiler, let the compile fail if it is told to use
94  * a feature that we cannot live without.
95  */
96 #if !defined(__pure2) && (__GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER))
97 #define	__pure2		__attribute__((__const__))
98 #endif
99 
100 #endif /* !_BSD_CDEFS_H_ */
101