1 /*
2 Copyright (c) 1991, 1993
3 The Regents of the University of California.  All rights reserved.
4 c) UNIX System Laboratories, Inc.
5 All or some portions of this file are derived from material licensed
6 to the University of California by American Telephone and Telegraph
7 Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 the permission of UNIX System Laboratories, 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. Neither the name of the University nor the names of its contributors
19 may be used to endorse or promote products derived from this software
20 without specific prior written permission.
21 
22 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 SUCH DAMAGE.
33  */
34 /* Provide support for both ANSI and non-ANSI environments.  */
35 
36 /* To get a strict ANSI C environment, define macro __STRICT_ANSI__.  This will
37    "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header
38    files aren't affected).  */
39 
40 #ifndef	_ANSIDECL_H_
41 #define	_ANSIDECL_H_
42 
43 #include <newlib.h>
44 #include <sys/config.h>
45 
46 /*  ISO C++.  */
47 
48 #ifdef __cplusplus
49 #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C))
50 #ifdef _HAVE_STD_CXX
51 #define _BEGIN_STD_C namespace std { extern "C" {
52 #define _END_STD_C  } }
53 #else
54 #define _BEGIN_STD_C extern "C" {
55 #define _END_STD_C  }
56 #endif
57 #if __GNUC_PREREQ (3, 3)
58 #define _NOTHROW __attribute__ ((__nothrow__))
59 #else
60 #define _NOTHROW throw()
61 #endif
62 #endif
63 #else
64 #define _BEGIN_STD_C
65 #define _END_STD_C
66 #if __GNUC_PREREQ (3, 3)
67 #define _NOTHROW __attribute__ ((__nothrow__))
68 #else
69 #define _NOTHROW
70 #endif
71 #endif
72 
73 #ifndef _LONG_DOUBLE
74 #define _LONG_DOUBLE long double
75 #endif
76 
77 /* Support gcc's __attribute__ facility.  */
78 
79 #ifdef __GNUC__
80 #define _ATTRIBUTE(attrs) __attribute__ (attrs)
81 #else
82 #define _ATTRIBUTE(attrs)
83 #endif
84 
85 /*  The traditional meaning of 'extern inline' for GCC is not
86   to emit the function body unless the address is explicitly
87   taken.  However this behaviour is changing to match the C99
88   standard, which uses 'extern inline' to indicate that the
89   function body *must* be emitted.  Likewise, a function declared
90   without either 'extern' or 'static' defaults to extern linkage
91   (C99 6.2.2p5), and the compiler may choose whether to use the
92   inline version or call the extern linkage version (6.7.4p6).
93   If we are using GCC, but do not have the new behaviour, we need
94   to use extern inline; if we are using a new GCC with the
95   C99-compatible behaviour, or a non-GCC compiler (which we will
96   have to hope is C99, since there is no other way to achieve the
97   effect of omitting the function if it isn't referenced) we use
98   'static inline', which c99 defines to mean more-or-less the same
99   as the Gnu C 'extern inline'.  */
100 #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__)
101 /* We're using GCC, but without the new C99-compatible behaviour.  */
102 #define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__))
103 #else
104 /* We're using GCC in C99 mode, or an unknown compiler which
105   we just have to hope obeys the C99 semantics of inline.  */
106 #define _ELIDABLE_INLINE static __inline__
107 #endif
108 
109 #if __GNUC_PREREQ (3, 1)
110 #define _NOINLINE		__attribute__ ((__noinline__))
111 #define _NOINLINE_STATIC	_NOINLINE static
112 #else
113 /* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be
114    trusted not to inline if it is static. */
115 #define _NOINLINE
116 #define _NOINLINE_STATIC
117 #endif
118 
119 #endif /* _ANSIDECL_H_ */
120