1 /*************************************************************************
2  *
3  * $Id: triodef.h,v 1.32 2007/04/17 19:23:05 breese Exp $
4  *
5  * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
12  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
13  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE AUTHORS AND
14  * CONTRIBUTORS ACCEPT NO RESPONSIBILITY IN ANY CONCEIVABLE MANNER.
15  *
16  ************************************************************************/
17 
18 #ifndef TRIO_TRIODEF_H
19 #define TRIO_TRIODEF_H
20 
21 /*************************************************************************
22  * Compiler support detection
23  */
24 
25 #if defined(__GNUC__)
26 # define TRIO_COMPILER_GCC
27 #endif
28 
29 #if defined(__SUNPRO_CC)
30 # define TRIO_COMPILER_SUNPRO __SUNPRO_CC
31 #else
32 # if defined(__SUNPRO_C)
33 #  define TRIO_COMPILER_SUNPRO __SUNPRO_C
34 # endif
35 #endif
36 
37 #if defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
38 # define TRIO_COMPILER_XLC
39 #else
40 # if defined(_AIX) && !defined(__GNUC__)
41 #  define TRIO_COMPILER_XLC /* Workaround for old xlc */
42 # endif
43 #endif
44 
45 #if defined(__DECC) || defined(__DECCXX)
46 # define TRIO_COMPILER_DECC
47 #else
48 # if defined(__osf__) && defined(__LANGUAGE_C__) && !defined(__GNUC__)
49 #  define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */
50 # endif
51 #endif
52 
53 #if defined(__HP_aCC) || defined(__HP_cc)
54 # define TRIO_COMPILER_HP
55 #endif
56 
57 #if defined(sgi) || defined(__sgi)
58 # define TRIO_COMPILER_MIPSPRO
59 #endif
60 
61 #if defined(_MSC_VER)
62 # define TRIO_COMPILER_MSVC
63 #endif
64 
65 #if defined(__BORLANDC__)
66 # define TRIO_COMPILER_BCB
67 #endif
68 
69 /*************************************************************************
70  * Platform support detection
71  */
72 
73 #if defined(VMS) || defined(__VMS)
74 # define TRIO_PLATFORM_VMS
75 #endif
76 
77 #if defined(unix) || defined(__unix) || defined(__unix__)
78 # define TRIO_PLATFORM_UNIX
79 #endif
80 
81 #if defined(TRIO_COMPILER_XLC) || defined(_AIX)
82 # define TRIO_PLATFORM_UNIX
83 #endif
84 
85 #if defined(TRIO_COMPILER_DECC) || defined(__osf___)
86 # if !defined(TRIO_PLATFORM_VMS)
87 #  define TRIO_PLATFORM_UNIX
88 # endif
89 #endif
90 
91 #if defined(__NetBSD__)
92 # define TRIO_PLATFORM_UNIX
93 #endif
94 
95 #if defined(__Lynx__)
96 # define TRIO_PLATFORM_UNIX
97 # define TRIO_PLATFORM_LYNX
98 #endif
99 
100 #if defined(__APPLE__) && defined(__MACH__)
101 # define TRIO_PLATFORM_UNIX
102 #endif
103 
104 #if defined(__QNX__)
105 # define TRIO_PLATFORM_UNIX
106 # define TRIO_PLATFORM_QNX
107 #endif
108 
109 #if defined(__CYGWIN__)
110 # define TRIO_PLATFORM_UNIX
111 #endif
112 
113 #if defined(AMIGA) && defined(TRIO_COMPILER_GCC)
114 # define TRIO_PLATFORM_UNIX
115 #endif
116 
117 #if defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
118 # define TRIO_PLATFORM_WIN32
119 #endif
120 
121 #if defined(_WIN32_WCE)
122 # define TRIO_PLATFORM_WINCE
123 #endif
124 
125 #if defined(mpeix) || defined(__mpexl)
126 # define TRIO_PLATFORM_MPEIX
127 #endif
128 
129 #if defined(_AIX)
130 # define TRIO_PLATFORM_AIX
131 #endif
132 
133 #if defined(__hpux)
134 # define TRIO_PLATFORM_HPUX
135 #endif
136 
137 #if defined(sun) || defined(__sun__)
138 # if defined(__SVR4) || defined(__svr4__)
139 #  define TRIO_PLATFORM_SOLARIS
140 # else
141 #  define TRIO_PLATFORM_SUNOS
142 # endif
143 #endif
144 
145 /*************************************************************************
146  * Standards support detection
147  */
148 
149 #if defined(__STDC__) \
150  || defined(_MSC_EXTENSIONS) \
151  || defined(TRIO_COMPILER_BORLAND)
152 # define PREDEF_STANDARD_C89
153 #endif
154 #if defined(__STDC_VERSION__)
155 # define PREDEF_STANDARD_C90
156 #endif
157 #if (__STDC_VERSION__ - 0 >= 199409L)
158 # define PREDEF_STANDARD_C94
159 #endif
160 #if (__STDC_VERSION__ - 0 >= 199901L)
161 # define PREDEF_STANDARD_C99
162 #endif
163 #if defined(TRIO_COMPILER_SUNPRO) && (TRIO_COMPILER_SUNPRO >= 0x420)
164 # if !defined(PREDEF_STANDARD_C94)
165 #  define PREDEF_STANDARD_C94
166 # endif
167 #endif
168 
169 #if defined(__cplusplus)
170 # define PREDEF_STANDARD_CXX
171 #endif
172 #if __cplusplus - 0 >= 199711L
173 # define PREDEF_STANDARD_CXX89
174 #endif
175 
176 #if defined(TRIO_PLATFORM_UNIX)
177 # include <unistd.h>
178 #endif
179 
180 #if defined(_POSIX_VERSION)
181 # define PREDEF_STANDARD_POSIX _POSIX_VERSION
182 # if (_POSIX_VERSION >= 199506L)
183 #  define PREDEF_STANDARD_POSIX_1996
184 # endif
185 #endif
186 
187 #if (_XOPEN_VERSION - 0 >= 3) || defined(_XOPEN_XPG3)
188 # define PREDEF_STANDARD_XPG3
189 #endif
190 #if (_XOPEN_VERSION - 0 >= 4) || defined(_XOPEN_XPG4)
191 # define PREDEF_STANDARD_XPG4
192 #endif
193 #if (_XOPEN_VERSION - 0 > 4) \
194  || (defined(_XOPEN_UNIX) && (_XOPEN_VERSION - 0 == 4))
195 # define PREDEF_STANDARD_UNIX95
196 #endif
197 #if (_XOPEN_VERSION - 0 >= 500)
198 # define PREDEF_STANDARD_UNIX98
199 #endif
200 #if (_XOPEN_VERSION - 0 >= 600)
201 # define PREDEF_STANDARD_UNIX03
202 #endif
203 
204 /*************************************************************************
205  * Generic defines
206  */
207 
208 #if !defined(TRIO_PUBLIC)
209 # define TRIO_PUBLIC
210 #endif
211 #if !defined(TRIO_PRIVATE)
212 # define TRIO_PRIVATE static
213 #endif
214 
215 #if !(defined(PREDEF_STANDARD_C89) || defined(PREDEF_STANDARD_CXX))
216 # define TRIO_COMPILER_ANCIENT
217 #endif
218 
219 #if defined(TRIO_COMPILER_ANCIENT)
220 # define TRIO_CONST
221 # define TRIO_VOLATILE
222 # define TRIO_SIGNED
223 typedef double trio_long_double_t;
224 typedef char * trio_pointer_t;
225 # define TRIO_SUFFIX_LONG(x) x
226 # define TRIO_PROTO(x) ()
227 # define TRIO_NOARGS
228 # define TRIO_ARGS1(list,a1) list a1;
229 # define TRIO_ARGS2(list,a1,a2) list a1; a2;
230 # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3;
231 # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4;
232 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5;
233 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6;
234 # define TRIO_VARGS2(list,a1,a2) list a1; a2
235 # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
236 # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
237 # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
238 # define TRIO_VA_DECL va_dcl
239 # define TRIO_VA_START(x,y) va_start(x)
240 # define TRIO_VA_END(x) va_end(x)
241 #else /* ANSI C */
242 # define TRIO_CONST const
243 # define TRIO_VOLATILE volatile
244 # define TRIO_SIGNED signed
245 typedef long double trio_long_double_t;
246 typedef void * trio_pointer_t;
247 # define TRIO_SUFFIX_LONG(x) x ## L
248 # define TRIO_PROTO(x) x
249 # define TRIO_NOARGS void
250 # define TRIO_ARGS1(list,a1) (a1)
251 # define TRIO_ARGS2(list,a1,a2) (a1,a2)
252 # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
253 # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
254 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
255 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
256 # define TRIO_VARGS2 TRIO_ARGS2
257 # define TRIO_VARGS3 TRIO_ARGS3
258 # define TRIO_VARGS4 TRIO_ARGS4
259 # define TRIO_VARGS5 TRIO_ARGS5
260 # define TRIO_VA_DECL ...
261 # define TRIO_VA_START(x,y) va_start(x,y)
262 # define TRIO_VA_END(x) va_end(x)
263 #endif
264 
265 #if defined(PREDEF_STANDARD_C99) || defined(PREDEF_STANDARD_CXX)
266 # define TRIO_INLINE inline
267 #else
268 # if defined(TRIO_COMPILER_GCC)
269 #  define TRIO_INLINE __inline__
270 # endif
271 # if defined(TRIO_COMPILER_MSVC)
272 #  define TRIO_INLINE _inline
273 # endif
274 # if defined(TRIO_COMPILER_BCB)
275 #  define TRIO_INLINE __inline
276 # endif
277 #endif
278 #if !defined(TRIO_INLINE)
279 # define TRIO_INLINE
280 #endif
281 
282 /*************************************************************************
283  * Workarounds
284  */
285 
286 #if defined(TRIO_PLATFORM_VMS)
287 /*
288  * Computations done with constants at compile time can trigger these
289  * even when compiling with IEEE enabled.
290  */
291 # pragma message disable (UNDERFLOW, FLOATOVERFL)
292 
293 # if (__CRTL_VER < 80210001)
294 /*
295  * Although the compiler supports C99 language constructs, the C
296  * run-time library does not contain all C99 functions.
297  */
298 #  if defined(PREDEF_STANDARD_C99)
299 #   undef PREDEF_STANDARD_C99
300 #  endif
301 # endif
302 #endif
303 
304 /*
305  * Not all preprocessors supports the LL token.
306  */
307 #if defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
308 #else
309 # define TRIO_COMPILER_SUPPORTS_LL
310 #endif
311 
312 #endif /* TRIO_TRIODEF_H */
313