blob: 0fd32fb7864205733af9a50225bd90de2a985b93 [file] [log] [blame]
Bjorn Reese45029602001-08-21 09:23:53 +00001/*************************************************************************
2 *
3 * $Id$
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
Bjorn Reese026d29f2002-01-19 15:40:18 +000018#ifndef TRIO_TRIODEF_H
19#define TRIO_TRIODEF_H
Bjorn Reese45029602001-08-21 09:23:53 +000020
21/*************************************************************************
22 * Platform and compiler support detection
23 */
24#if defined(__GNUC__)
25# define TRIO_COMPILER_GCC
26#elif defined(__SUNPRO_C)
27# define TRIO_COMPILER_SUNPRO
28#elif defined(__SUNPRO_CC)
29# define TRIO_COMPILER_SUNPRO
30# define __SUNPRO_C __SUNPRO_CC
31#elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
32# define TRIO_COMPILER_XLC
33#elif defined(_AIX) && !defined(__GNUC__)
34# define TRIO_COMPILER_XLC /* Workaround for old xlc */
35#elif defined(__DECC) || defined(__DECCXX)
36# define TRIO_COMPILER_DECC
Daniel Veillardb7c29c32002-09-25 22:44:43 +000037#elif defined(__osf__) && defined(__LANGUAGE_C__)
38# define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */
Bjorn Reese45029602001-08-21 09:23:53 +000039#elif defined(_MSC_VER)
40# define TRIO_COMPILER_MSVC
Daniel Veillardb7c29c32002-09-25 22:44:43 +000041#elif defined(__BORLANDC__)
42# define TRIO_COMPILER_BCB
Bjorn Reese45029602001-08-21 09:23:53 +000043#endif
44
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000045#if defined(VMS) || defined(__VMS)
46/*
47 * VMS is placed first to avoid identifying the platform as Unix
48 * based on the DECC compiler later on.
49 */
50# define TRIO_PLATFORM_VMS
51#elif defined(unix) || defined(__unix) || defined(__unix__)
Bjorn Reese45029602001-08-21 09:23:53 +000052# define TRIO_PLATFORM_UNIX
53#elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
54# define TRIO_PLATFORM_UNIX
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000055#elif defined(TRIO_COMPILER_DECC) || defined(__osf___)
Bjorn Reese45029602001-08-21 09:23:53 +000056# define TRIO_PLATFORM_UNIX
57#elif defined(__NetBSD__)
58# define TRIO_PLATFORM_UNIX
59#elif defined(__QNX__)
60# define TRIO_PLATFORM_UNIX
Bjorn Reese026d29f2002-01-19 15:40:18 +000061# define TRIO_PLATFORM_QNX
Daniel Veillard3c5ed912002-01-08 10:36:16 +000062#elif defined(__CYGWIN__)
63# define TRIO_PLATFORM_UNIX
Bjorn Reese45029602001-08-21 09:23:53 +000064#elif defined(AMIGA) && defined(TRIO_COMPILER_GCC)
65# define TRIO_PLATFORM_UNIX
66#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
67# define TRIO_PLATFORM_WIN32
Bjorn Reese026d29f2002-01-19 15:40:18 +000068#elif defined(mpeix) || defined(__mpexl)
69# define TRIO_PLATFORM_MPEIX
Bjorn Reese45029602001-08-21 09:23:53 +000070#endif
71
Daniel Veillarda48ed3d2003-04-03 15:28:28 +000072#if defined(_AIX)
73# define TRIO_PLATFORM_AIX
74#elif defined(__hpux)
75# define TRIO_PLATFORM_HPUX
76#elif defined(sun) || defined(__sun__)
77# if defined(__SVR4) || defined(__svr4__)
78# define TRIO_PLATFORM_SOLARIS
79# else
80# define TRIO_PLATFORM_SUNOS
81# endif
82#endif
83
84#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
Daniel Veillardb7c29c32002-09-25 22:44:43 +000085# define TRIO_COMPILER_SUPPORTS_C89
Bjorn Reese45029602001-08-21 09:23:53 +000086# if defined(__STDC_VERSION__)
Daniel Veillardb7c29c32002-09-25 22:44:43 +000087# define TRIO_COMPILER_SUPPORTS_C90
Bjorn Reese45029602001-08-21 09:23:53 +000088# if (__STDC_VERSION__ >= 199409L)
89# define TRIO_COMPILER_SUPPORTS_C94
90# endif
91# if (__STDC_VERSION__ >= 199901L)
92# define TRIO_COMPILER_SUPPORTS_C99
93# endif
94# elif defined(TRIO_COMPILER_SUNPRO)
95# if (__SUNPRO_C >= 0x420)
96# define TRIO_COMPILER_SUPPORTS_C94
97# endif
98# endif
99#endif
100
101#if defined(_XOPEN_SOURCE)
102# if defined(_XOPEN_SOURCE_EXTENDED)
103# define TRIO_COMPILER_SUPPORTS_UNIX95
104# endif
105# if (_XOPEN_VERSION >= 500)
106# define TRIO_COMPILER_SUPPORTS_UNIX98
107# endif
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000108# if (_XOPEN_VERSION >= 600)
109# define TRIO_COMPILER_SUPPORTS_UNIX01
110# endif
Bjorn Reese45029602001-08-21 09:23:53 +0000111#endif
112
Bjorn Reese026d29f2002-01-19 15:40:18 +0000113/*************************************************************************
114 * Generic defines
115 */
116
117#if !defined(TRIO_PUBLIC)
118# define TRIO_PUBLIC
119#endif
120#if !defined(TRIO_PRIVATE)
121# define TRIO_PRIVATE static
122#endif
123
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000124#if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus))
125# define TRIO_COMPILER_ANCIENT
126#endif
127
128#if defined(TRIO_COMPILER_ANCIENT)
Bjorn Reese026d29f2002-01-19 15:40:18 +0000129# define TRIO_CONST
130# define TRIO_VOLATILE
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000131# define TRIO_SIGNED
132typedef double trio_long_double_t;
133typedef char * trio_pointer_t;
134# define TRIO_SUFFIX_LONG(x) x
Bjorn Reese026d29f2002-01-19 15:40:18 +0000135# define TRIO_PROTO(x) ()
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000136# define TRIO_NOARGS
137# define TRIO_ARGS1(list,a1) list a1;
138# define TRIO_ARGS2(list,a1,a2) list a1; a2;
139# define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3;
140# define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4;
141# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5;
142# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6;
143# define TRIO_VARGS2(list,a1,a2) list a1; a2
144# define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
145# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
146# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
147# define TRIO_VA_DECL va_dcl
Daniel Veillarda48ed3d2003-04-03 15:28:28 +0000148# define TRIO_VA_START(x,y) va_start(x)
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000149# define TRIO_VA_END(x) va_end(x)
150#else /* ANSI C */
151# define TRIO_CONST const
152# define TRIO_VOLATILE volatile
153# define TRIO_SIGNED signed
154typedef long double trio_long_double_t;
155typedef void * trio_pointer_t;
156# define TRIO_SUFFIX_LONG(x) x ## L
157# define TRIO_PROTO(x) x
158# define TRIO_NOARGS void
159# define TRIO_ARGS1(list,a1) (a1)
160# define TRIO_ARGS2(list,a1,a2) (a1,a2)
161# define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
162# define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
163# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
164# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
165# define TRIO_VARGS2 TRIO_ARGS2
166# define TRIO_VARGS3 TRIO_ARGS3
167# define TRIO_VARGS4 TRIO_ARGS4
168# define TRIO_VARGS5 TRIO_ARGS5
169# define TRIO_VA_DECL ...
Daniel Veillarda48ed3d2003-04-03 15:28:28 +0000170# define TRIO_VA_START(x,y) va_start(x,y)
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000171# define TRIO_VA_END(x) va_end(x)
Bjorn Reese026d29f2002-01-19 15:40:18 +0000172#endif
173
174#if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus)
175# define TRIO_INLINE inline
176#elif defined(TRIO_COMPILER_GCC)
177# define TRIO_INLINE __inline__
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000178#elif defined(TRIO_COMPILER_MSVC)
179# define TRIO_INLINE _inline
180#elif defined(TRIO_COMPILER_BCB)
181# define TRIO_INLINE __inline
Bjorn Reese026d29f2002-01-19 15:40:18 +0000182#else
183# define TRIO_INLINE
184#endif
185
Daniel Veillarda48ed3d2003-04-03 15:28:28 +0000186/*************************************************************************
187 * Workarounds
188 */
189
190#if defined(TRIO_PLATFORM_VMS)
191/*
192 * Computations done with constants at compile time can trigger these
193 * even when compiling with IEEE enabled.
194 */
195# pragma message disable (UNDERFLOW, FLOATOVERFL)
196
Daniel Veillard1c960272003-04-25 23:12:22 +0000197# if (__CRTL_VER < 80000000)
Daniel Veillarda48ed3d2003-04-03 15:28:28 +0000198/*
199 * Although the compiler supports C99 language constructs, the C
200 * run-time library does not contain all C99 functions.
201 *
202 * This was the case for 70300022. Update the 80000000 value when
203 * it has been accurately determined what version of the library
204 * supports C99.
205 */
206# if defined(TRIO_COMPILER_SUPPORTS_C99)
207# undef TRIO_COMPILER_SUPPORTS_C99
208# endif
209# endif
210#endif
211
212/*
213 * Not all preprocessors supports the LL token.
214 */
215#if defined(TRIO_COMPILER_BCB)
216#else
217# define TRIO_COMPILER_SUPPORTS_LL
218#endif
219
Bjorn Reese026d29f2002-01-19 15:40:18 +0000220#endif /* TRIO_TRIODEF_H */