1 | /* Provide support for both ANSI and non-ANSI environments. */ |
---|
2 | |
---|
3 | /* To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will |
---|
4 | "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header |
---|
5 | files aren't affected). */ |
---|
6 | |
---|
7 | #ifndef _ANSIDECL_H_ |
---|
8 | #define _ANSIDECL_H_ |
---|
9 | |
---|
10 | #include <newlib.h> |
---|
11 | #include <sys/config.h> |
---|
12 | |
---|
13 | /* ISO C++. */ |
---|
14 | |
---|
15 | #ifdef __cplusplus |
---|
16 | #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) |
---|
17 | #ifdef _HAVE_STD_CXX |
---|
18 | #define _BEGIN_STD_C namespace std { extern "C" { |
---|
19 | #define _END_STD_C } } |
---|
20 | #else |
---|
21 | #define _BEGIN_STD_C extern "C" { |
---|
22 | #define _END_STD_C } |
---|
23 | #endif |
---|
24 | #if __GNUC_PREREQ (3, 3) |
---|
25 | #define _NOTHROW __attribute__ ((__nothrow__)) |
---|
26 | #else |
---|
27 | #define _NOTHROW throw() |
---|
28 | #endif |
---|
29 | #endif |
---|
30 | #else |
---|
31 | #define _BEGIN_STD_C |
---|
32 | #define _END_STD_C |
---|
33 | #define _NOTHROW |
---|
34 | #endif |
---|
35 | |
---|
36 | #ifndef _LONG_DOUBLE |
---|
37 | #define _LONG_DOUBLE long double |
---|
38 | #endif |
---|
39 | |
---|
40 | /* Support gcc's __attribute__ facility. */ |
---|
41 | |
---|
42 | #ifdef __GNUC__ |
---|
43 | #define _ATTRIBUTE(attrs) __attribute__ (attrs) |
---|
44 | #else |
---|
45 | #define _ATTRIBUTE(attrs) |
---|
46 | #endif |
---|
47 | |
---|
48 | /* The traditional meaning of 'extern inline' for GCC is not |
---|
49 | to emit the function body unless the address is explicitly |
---|
50 | taken. However this behaviour is changing to match the C99 |
---|
51 | standard, which uses 'extern inline' to indicate that the |
---|
52 | function body *must* be emitted. Likewise, a function declared |
---|
53 | without either 'extern' or 'static' defaults to extern linkage |
---|
54 | (C99 6.2.2p5), and the compiler may choose whether to use the |
---|
55 | inline version or call the extern linkage version (6.7.4p6). |
---|
56 | If we are using GCC, but do not have the new behaviour, we need |
---|
57 | to use extern inline; if we are using a new GCC with the |
---|
58 | C99-compatible behaviour, or a non-GCC compiler (which we will |
---|
59 | have to hope is C99, since there is no other way to achieve the |
---|
60 | effect of omitting the function if it isn't referenced) we use |
---|
61 | 'static inline', which c99 defines to mean more-or-less the same |
---|
62 | as the Gnu C 'extern inline'. */ |
---|
63 | #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) |
---|
64 | /* We're using GCC, but without the new C99-compatible behaviour. */ |
---|
65 | #define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__)) |
---|
66 | #else |
---|
67 | /* We're using GCC in C99 mode, or an unknown compiler which |
---|
68 | we just have to hope obeys the C99 semantics of inline. */ |
---|
69 | #define _ELIDABLE_INLINE static __inline__ |
---|
70 | #endif |
---|
71 | |
---|
72 | #if __GNUC_PREREQ (3, 1) |
---|
73 | #define _NOINLINE __attribute__ ((__noinline__)) |
---|
74 | #define _NOINLINE_STATIC _NOINLINE static |
---|
75 | #else |
---|
76 | /* On non-GNU compilers and GCC prior to version 3.1 the compiler can't be |
---|
77 | trusted not to inline if it is static. */ |
---|
78 | #define _NOINLINE |
---|
79 | #define _NOINLINE_STATIC |
---|
80 | #endif |
---|
81 | |
---|
82 | #endif /* _ANSIDECL_H_ */ |
---|