1 | /* Provide support for both ANSI and non-ANSI environments. */ |
---|
2 | |
---|
3 | /* Some ANSI environments are "broken" in the sense that __STDC__ cannot be |
---|
4 | relied upon to have it's intended meaning. Therefore we must use our own |
---|
5 | concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib |
---|
6 | sources! |
---|
7 | |
---|
8 | To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will |
---|
9 | "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header |
---|
10 | files aren't affected). */ |
---|
11 | |
---|
12 | #ifndef _ANSIDECL_H_ |
---|
13 | #define _ANSIDECL_H_ |
---|
14 | |
---|
15 | /* #include <newlib.h> */ |
---|
16 | /* #include <sys/config.h> */ |
---|
17 | |
---|
18 | /* First try to figure out whether we really are in an ANSI C environment. */ |
---|
19 | /* FIXME: This probably needs some work. Perhaps sys/config.h can be |
---|
20 | prevailed upon to give us a clue. */ |
---|
21 | |
---|
22 | #ifdef __STDC__ |
---|
23 | #define _HAVE_STDC |
---|
24 | #endif |
---|
25 | |
---|
26 | #ifdef _HAVE_STDC |
---|
27 | #define _PTR void * |
---|
28 | #define _AND , |
---|
29 | #define _NOARGS void |
---|
30 | #define _CONST const |
---|
31 | #define _VOLATILE volatile |
---|
32 | #define _SIGNED signed |
---|
33 | #define _DOTS , ... |
---|
34 | #define _VOID void |
---|
35 | #ifdef __CYGWIN__ |
---|
36 | #define _EXFUN(name, proto) __cdecl name proto |
---|
37 | #define _EXPARM(name, proto) (* __cdecl name) proto |
---|
38 | #else |
---|
39 | #define _EXFUN(name, proto) name proto |
---|
40 | #define _EXPARM(name, proto) (* name) proto |
---|
41 | #endif |
---|
42 | #define _DEFUN(name, arglist, args) name(args) |
---|
43 | #define _DEFUN_VOID(name) name(_NOARGS) |
---|
44 | #define _CAST_VOID (void) |
---|
45 | #ifndef _LONG_DOUBLE |
---|
46 | #define _LONG_DOUBLE long double |
---|
47 | #endif |
---|
48 | #ifndef _LONG_LONG |
---|
49 | #define _LONG_LONG long long |
---|
50 | #endif |
---|
51 | #ifndef _PARAMS |
---|
52 | #define _PARAMS(paramlist) paramlist |
---|
53 | #endif |
---|
54 | #else |
---|
55 | #define _PTR char * |
---|
56 | #define _AND ; |
---|
57 | #define _NOARGS |
---|
58 | #define _CONST |
---|
59 | #define _VOLATILE |
---|
60 | #define _SIGNED |
---|
61 | #define _DOTS |
---|
62 | #define _VOID void |
---|
63 | #define _EXFUN(name, proto) name() |
---|
64 | #define _DEFUN(name, arglist, args) name arglist args; |
---|
65 | #define _DEFUN_VOID(name) name() |
---|
66 | #define _CAST_VOID |
---|
67 | #define _LONG_DOUBLE double |
---|
68 | #define _LONG_LONG long |
---|
69 | #ifndef _PARAMS |
---|
70 | #define _PARAMS(paramlist) () |
---|
71 | #endif |
---|
72 | #endif |
---|
73 | |
---|
74 | /* Support gcc's __attribute__ facility. */ |
---|
75 | |
---|
76 | #ifdef __GNUC__ |
---|
77 | #define _ATTRIBUTE(attrs) __attribute__ (attrs) |
---|
78 | #else |
---|
79 | #define _ATTRIBUTE(attrs) |
---|
80 | #endif |
---|
81 | |
---|
82 | /* ISO C++. */ |
---|
83 | |
---|
84 | #ifdef __cplusplus |
---|
85 | #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) |
---|
86 | #ifdef _HAVE_STD_CXX |
---|
87 | #define _BEGIN_STD_C namespace std { extern "C" { |
---|
88 | #define _END_STD_C } } |
---|
89 | #else |
---|
90 | #define _BEGIN_STD_C extern "C" { |
---|
91 | #define _END_STD_C } |
---|
92 | #endif |
---|
93 | #endif |
---|
94 | #else |
---|
95 | #define _BEGIN_STD_C |
---|
96 | #define _END_STD_C |
---|
97 | #endif |
---|
98 | |
---|
99 | #endif /* _ANSIDECL_H_ */ |
---|