|
1 /************************************************************************* |
|
2 * |
|
3 * |
|
4 * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net> |
|
5 * |
|
6 * Permission to use, copy, modify, and distribute this software for any |
|
7 * purpose with or without fee is hereby granted, provided that the above |
|
8 * copyright notice and this permission notice appear in all copies. |
|
9 * |
|
10 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED |
|
11 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
|
12 * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND |
|
13 * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER. |
|
14 * |
|
15 ************************************************************************/ |
|
16 |
|
17 #ifndef TRIO_TRIODEF_H |
|
18 #define TRIO_TRIODEF_H |
|
19 |
|
20 /************************************************************************* |
|
21 * Platform and compiler support detection |
|
22 */ |
|
23 #if defined(__GNUC__) |
|
24 # define TRIO_COMPILER_GCC |
|
25 #elif defined(__SUNPRO_C) |
|
26 # define TRIO_COMPILER_SUNPRO |
|
27 #elif defined(__SUNPRO_CC) |
|
28 # define TRIO_COMPILER_SUNPRO |
|
29 # define __SUNPRO_C __SUNPRO_CC |
|
30 #elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) |
|
31 # define TRIO_COMPILER_XLC |
|
32 #elif defined(_AIX) && !defined(__GNUC__) |
|
33 # define TRIO_COMPILER_XLC /* Workaround for old xlc */ |
|
34 #elif defined(__DECC) || defined(__DECCXX) |
|
35 # define TRIO_COMPILER_DECC |
|
36 #elif defined(__osf__) && defined(__LANGUAGE_C__) |
|
37 # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ |
|
38 #elif defined(_MSC_VER) |
|
39 //# define TRIO_COMPILER_MSVC |
|
40 #elif defined(__BORLANDC__) |
|
41 # define TRIO_COMPILER_BCB |
|
42 #endif |
|
43 |
|
44 #if defined(VMS) || defined(__VMS) |
|
45 /* |
|
46 * VMS is placed first to avoid identifying the platform as Unix |
|
47 * based on the DECC compiler later on. |
|
48 */ |
|
49 # define TRIO_PLATFORM_VMS |
|
50 #elif defined(unix) || defined(__unix) || defined(__unix__) |
|
51 # define TRIO_PLATFORM_UNIX |
|
52 #elif defined(TRIO_COMPILER_XLC) || defined(_AIX) |
|
53 # define TRIO_PLATFORM_UNIX |
|
54 #elif defined(TRIO_COMPILER_DECC) || defined(__osf___) |
|
55 # define TRIO_PLATFORM_UNIX |
|
56 #elif defined(__NetBSD__) |
|
57 # define TRIO_PLATFORM_UNIX |
|
58 #elif defined(__QNX__) |
|
59 # define TRIO_PLATFORM_UNIX |
|
60 # define TRIO_PLATFORM_QNX |
|
61 #elif defined(__CYGWIN__) |
|
62 # define TRIO_PLATFORM_UNIX |
|
63 #elif defined(AMIGA) && defined(TRIO_COMPILER_GCC) |
|
64 # define TRIO_PLATFORM_UNIX |
|
65 #elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) |
|
66 # define TRIO_PLATFORM_WIN32 |
|
67 #elif defined(mpeix) || defined(__mpexl) |
|
68 # define TRIO_PLATFORM_MPEIX |
|
69 #endif |
|
70 |
|
71 #if defined(_AIX) |
|
72 # define TRIO_PLATFORM_AIX |
|
73 #elif defined(__hpux) |
|
74 # define TRIO_PLATFORM_HPUX |
|
75 #elif defined(sun) || defined(__sun__) |
|
76 # if defined(__SVR4) || defined(__svr4__) |
|
77 # define TRIO_PLATFORM_SOLARIS |
|
78 # else |
|
79 # define TRIO_PLATFORM_SUNOS |
|
80 # endif |
|
81 #endif |
|
82 |
|
83 #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) |
|
84 # define TRIO_COMPILER_SUPPORTS_C89 |
|
85 # if defined(__STDC_VERSION__) |
|
86 # define TRIO_COMPILER_SUPPORTS_C90 |
|
87 # if (__STDC_VERSION__ >= 199409L) |
|
88 # define TRIO_COMPILER_SUPPORTS_C94 |
|
89 # endif |
|
90 # if (__STDC_VERSION__ >= 199901L) |
|
91 # define TRIO_COMPILER_SUPPORTS_C99 |
|
92 # endif |
|
93 # elif defined(TRIO_COMPILER_SUNPRO) |
|
94 # if (__SUNPRO_C >= 0x420) |
|
95 # define TRIO_COMPILER_SUPPORTS_C94 |
|
96 # endif |
|
97 # endif |
|
98 #endif |
|
99 |
|
100 #if defined(_XOPEN_SOURCE) |
|
101 # if defined(_XOPEN_SOURCE_EXTENDED) |
|
102 # define TRIO_COMPILER_SUPPORTS_UNIX95 |
|
103 # endif |
|
104 # if (_XOPEN_VERSION >= 500) |
|
105 # define TRIO_COMPILER_SUPPORTS_UNIX98 |
|
106 # endif |
|
107 # if (_XOPEN_VERSION >= 600) |
|
108 # define TRIO_COMPILER_SUPPORTS_UNIX01 |
|
109 # endif |
|
110 #endif |
|
111 |
|
112 /************************************************************************* |
|
113 * Generic defines |
|
114 */ |
|
115 |
|
116 #if !defined(TRIO_PUBLIC) |
|
117 # define TRIO_PUBLIC XMLPUBFUN |
|
118 #endif |
|
119 #if !defined(TRIO_PRIVATE) |
|
120 # define TRIO_PRIVATE static |
|
121 #endif |
|
122 |
|
123 #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) |
|
124 # define TRIO_COMPILER_ANCIENT |
|
125 #endif |
|
126 |
|
127 #if defined(TRIO_COMPILER_ANCIENT) |
|
128 # define TRIO_CONST |
|
129 # define TRIO_VOLATILE |
|
130 # define TRIO_SIGNED |
|
131 typedef double trio_long_double_t; |
|
132 typedef char * trio_pointer_t; |
|
133 # define TRIO_SUFFIX_LONG(x) x |
|
134 # define TRIO_PROTO(x) () |
|
135 # define TRIO_NOARGS |
|
136 # define TRIO_ARGS1(list,a1) list a1; |
|
137 # define TRIO_ARGS2(list,a1,a2) list a1; a2; |
|
138 # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; |
|
139 # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; |
|
140 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; |
|
141 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; |
|
142 # define TRIO_VARGS2(list,a1,a2) list a1; a2 |
|
143 # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 |
|
144 # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 |
|
145 # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 |
|
146 # define TRIO_VA_DECL va_dcl |
|
147 # define TRIO_VA_START(x,y) va_start(x) |
|
148 # define TRIO_VA_END(x) va_end(x) |
|
149 #else /* ANSI C */ |
|
150 # define TRIO_CONST const |
|
151 # define TRIO_VOLATILE volatile |
|
152 # define TRIO_SIGNED signed |
|
153 typedef long double trio_long_double_t; |
|
154 typedef void * trio_pointer_t; |
|
155 # define TRIO_SUFFIX_LONG(x) x ## L |
|
156 # define TRIO_PROTO(x) x |
|
157 # define TRIO_NOARGS void |
|
158 # define TRIO_ARGS1(list,a1) (a1) |
|
159 # define TRIO_ARGS2(list,a1,a2) (a1,a2) |
|
160 # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) |
|
161 # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) |
|
162 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) |
|
163 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) |
|
164 # define TRIO_VARGS2 TRIO_ARGS2 |
|
165 # define TRIO_VARGS3 TRIO_ARGS3 |
|
166 # define TRIO_VARGS4 TRIO_ARGS4 |
|
167 # define TRIO_VARGS5 TRIO_ARGS5 |
|
168 # define TRIO_VA_DECL ... |
|
169 # define TRIO_VA_START(x,y) va_start(x,y) |
|
170 # define TRIO_VA_END(x) va_end(x) |
|
171 #endif |
|
172 |
|
173 #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) |
|
174 # define TRIO_INLINE inline |
|
175 #elif defined(TRIO_COMPILER_GCC) |
|
176 # define TRIO_INLINE __inline__ |
|
177 #elif defined(TRIO_COMPILER_MSVC) |
|
178 # define TRIO_INLINE _inline |
|
179 #elif defined(TRIO_COMPILER_BCB) |
|
180 # define TRIO_INLINE __inline |
|
181 #else |
|
182 # define TRIO_INLINE |
|
183 #endif |
|
184 |
|
185 /************************************************************************* |
|
186 * Workarounds |
|
187 */ |
|
188 |
|
189 #if defined(TRIO_PLATFORM_VMS) |
|
190 /* |
|
191 * Computations done with constants at compile time can trigger these |
|
192 * even when compiling with IEEE enabled. |
|
193 */ |
|
194 # pragma message disable (UNDERFLOW, FLOATOVERFL) |
|
195 |
|
196 # if (__CRTL_VER < 80000000) |
|
197 /* |
|
198 * Although the compiler supports C99 language constructs, the C |
|
199 * run-time library does not contain all C99 functions. |
|
200 * |
|
201 * This was the case for 70300022. Update the 80000000 value when |
|
202 * it has been accurately determined what version of the library |
|
203 * supports C99. |
|
204 */ |
|
205 # if defined(TRIO_COMPILER_SUPPORTS_C99) |
|
206 # undef TRIO_COMPILER_SUPPORTS_C99 |
|
207 # endif |
|
208 # endif |
|
209 #endif |
|
210 |
|
211 /* |
|
212 * Not all preprocessors supports the LL token. |
|
213 */ |
|
214 #if defined(TRIO_COMPILER_BCB) |
|
215 #else |
|
216 # define TRIO_COMPILER_SUPPORTS_LL |
|
217 #endif |
|
218 |
|
219 #endif /* TRIO_TRIODEF_H */ |
|
220 |