]> Pileus Git - ~andy/fetchmail/blob - trio/triodef.h
Add new gai.c debug source.
[~andy/fetchmail] / trio / triodef.h
1 /*************************************************************************
2  *
3  * $Id: triodef.h,v 1.35 2009/09/20 11:37:14 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_BCB)
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_ARGS7(list,a1,a2,a3,a4,a5,a6,a7) list a1; a2; a3; a4; a5; a6; a7;
235 # define TRIO_VARGS2(list,a1,a2) list a1; a2
236 # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
237 # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
238 # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
239 # define TRIO_VA_DECL va_dcl
240 # define TRIO_VA_START(x,y) va_start(x)
241 # define TRIO_VA_END(x) va_end(x)
242 #else /* ANSI C */
243 # define TRIO_CONST const
244 # define TRIO_VOLATILE volatile
245 # define TRIO_SIGNED signed
246 typedef long double trio_long_double_t;
247 typedef void * trio_pointer_t;
248 # define TRIO_SUFFIX_LONG(x) x ## L
249 # define TRIO_PROTO(x) x
250 # define TRIO_NOARGS void
251 # define TRIO_ARGS1(list,a1) (a1)
252 # define TRIO_ARGS2(list,a1,a2) (a1,a2)
253 # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
254 # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
255 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
256 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
257 # define TRIO_ARGS7(list,a1,a2,a3,a4,a5,a6,a7) (a1,a2,a3,a4,a5,a6,a7)
258 # define TRIO_VARGS2 TRIO_ARGS2
259 # define TRIO_VARGS3 TRIO_ARGS3
260 # define TRIO_VARGS4 TRIO_ARGS4
261 # define TRIO_VARGS5 TRIO_ARGS5
262 # define TRIO_VA_DECL ...
263 # define TRIO_VA_START(x,y) va_start(x,y)
264 # define TRIO_VA_END(x) va_end(x)
265 #endif
266
267 #if defined(PREDEF_STANDARD_C99) || defined(PREDEF_STANDARD_CXX)
268 # define TRIO_INLINE inline
269 #else
270 # if defined(TRIO_COMPILER_GCC)
271 #  define TRIO_INLINE __inline__
272 # endif
273 # if defined(TRIO_COMPILER_MSVC)
274 #  define TRIO_INLINE _inline
275 # endif
276 # if defined(TRIO_COMPILER_BCB)
277 #  define TRIO_INLINE __inline
278 # endif
279 #endif
280 #if !defined(TRIO_INLINE)
281 # define TRIO_INLINE
282 #endif
283
284 /*************************************************************************
285  * Workarounds
286  */
287
288 #if defined(TRIO_PLATFORM_VMS)
289 /*
290  * Computations done with constants at compile time can trigger these
291  * even when compiling with IEEE enabled.
292  */
293 # pragma message disable (UNDERFLOW, FLOATOVERFL)
294
295 # if (__CRTL_VER < 80210001)
296 /*
297  * Although the compiler supports C99 language constructs, the C
298  * run-time library does not contain all C99 functions.
299  */
300 #  if defined(PREDEF_STANDARD_C99)
301 #   undef PREDEF_STANDARD_C99
302 #  endif
303 # endif
304 #endif
305
306 /*
307  * Not all preprocessors supports the LL token.
308  */
309 #if defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
310 #else
311 # define TRIO_COMPILER_SUPPORTS_LL
312 #endif
313
314 #if defined(__CYGWIN__)
315 /*
316  * Cygwin defines the macros for hosted C99, but does not support certain
317  * long double math functions.
318  */
319 # include <cygwin/version.h>
320 # define TRIO_CYGWIN_VERSION_API CYGWIN_VERSION_API_MAJOR * 1000 + \
321    CYGWIN_VERSION_API_MINOR
322 /*
323  * Please change the version number below when the Cygwin API supports
324  * long double math functions (powl, fmodl, etc.)
325  */
326 # if TRIO_CYGWIN_VERSION_API < 99999999
327 #  define TRIO_NO_FLOORL 1
328 #  define TRIO_NO_CEILL 1
329 #  define TRIO_NO_POWL 1
330 #  define TRIO_NO_FMODL 1
331 #  define TRIO_NO_LOG10L 1
332 # endif
333 #endif
334
335 #endif /* TRIO_TRIODEF_H */