blob: 73d64311a79b574df07c4b46806085f7517ee917 [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
45#if defined(unix) || defined(__unix) || defined(__unix__)
46# define TRIO_PLATFORM_UNIX
47#elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
48# define TRIO_PLATFORM_UNIX
Daniel Veillarde645e8c2002-10-22 17:35:37 +000049#elif ( defined(TRIO_COMPILER_DECC) && !defined(__VMS) ) || defined(__osf__)
Bjorn Reese45029602001-08-21 09:23:53 +000050# define TRIO_PLATFORM_UNIX
51#elif defined(__NetBSD__)
52# define TRIO_PLATFORM_UNIX
53#elif defined(__QNX__)
54# define TRIO_PLATFORM_UNIX
Bjorn Reese026d29f2002-01-19 15:40:18 +000055# define TRIO_PLATFORM_QNX
Daniel Veillard3c5ed912002-01-08 10:36:16 +000056#elif defined(__CYGWIN__)
57# define TRIO_PLATFORM_UNIX
Bjorn Reese45029602001-08-21 09:23:53 +000058#elif defined(AMIGA) && defined(TRIO_COMPILER_GCC)
59# define TRIO_PLATFORM_UNIX
60#elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
61# define TRIO_PLATFORM_WIN32
Bjorn Reese026d29f2002-01-19 15:40:18 +000062#elif defined(VMS) || defined(__VMS)
63# define TRIO_PLATFORM_VMS
64#elif defined(mpeix) || defined(__mpexl)
65# define TRIO_PLATFORM_MPEIX
Bjorn Reese45029602001-08-21 09:23:53 +000066#endif
67
Daniel Veillardb7c29c32002-09-25 22:44:43 +000068#if defined(__STDC__) || defined(TRIO_COMPILER_MSVC)
69# define TRIO_COMPILER_SUPPORTS_C89
Bjorn Reese45029602001-08-21 09:23:53 +000070# if defined(__STDC_VERSION__)
Daniel Veillardb7c29c32002-09-25 22:44:43 +000071# define TRIO_COMPILER_SUPPORTS_C90
Bjorn Reese45029602001-08-21 09:23:53 +000072# if (__STDC_VERSION__ >= 199409L)
73# define TRIO_COMPILER_SUPPORTS_C94
74# endif
75# if (__STDC_VERSION__ >= 199901L)
76# define TRIO_COMPILER_SUPPORTS_C99
77# endif
78# elif defined(TRIO_COMPILER_SUNPRO)
79# if (__SUNPRO_C >= 0x420)
80# define TRIO_COMPILER_SUPPORTS_C94
81# endif
82# endif
83#endif
84
Daniel Veillarde645e8c2002-10-22 17:35:37 +000085#if defined(TRIO_PLATFORM_VMS)
86 /* The compiler does support C99 but the library still does not have things
87 * the standard requires (like nan() and strtof()) as of __CRTL_VER 70300022.
88 */
89# undef TRIO_COMPILER_SUPPORTS_C99
90
91 /* Computations done with constants at compile time can trigger these
92 * even when compiling with IEEE enabled.
93 */
94# pragma message disable (UNDERFLOW,FLOATOVERFL)
95#endif /* TRIO_PLATFORM_VMS */
96
Bjorn Reese45029602001-08-21 09:23:53 +000097#if defined(_XOPEN_SOURCE)
98# if defined(_XOPEN_SOURCE_EXTENDED)
99# define TRIO_COMPILER_SUPPORTS_UNIX95
100# endif
101# if (_XOPEN_VERSION >= 500)
102# define TRIO_COMPILER_SUPPORTS_UNIX98
103# endif
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000104# if (_XOPEN_VERSION >= 600)
105# define TRIO_COMPILER_SUPPORTS_UNIX01
106# endif
Bjorn Reese45029602001-08-21 09:23:53 +0000107#endif
108
Bjorn Reese026d29f2002-01-19 15:40:18 +0000109/*************************************************************************
110 * Generic defines
111 */
112
113#if !defined(TRIO_PUBLIC)
114# define TRIO_PUBLIC
115#endif
116#if !defined(TRIO_PRIVATE)
117# define TRIO_PRIVATE static
118#endif
119
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000120#if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus))
121# define TRIO_COMPILER_ANCIENT
122#endif
123
124#if defined(TRIO_COMPILER_ANCIENT)
Bjorn Reese026d29f2002-01-19 15:40:18 +0000125# define TRIO_CONST
126# define TRIO_VOLATILE
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000127# define TRIO_SIGNED
128typedef double trio_long_double_t;
129typedef char * trio_pointer_t;
130# define TRIO_SUFFIX_LONG(x) x
Bjorn Reese026d29f2002-01-19 15:40:18 +0000131# define TRIO_PROTO(x) ()
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000132# define TRIO_NOARGS
133# define TRIO_ARGS1(list,a1) list a1;
134# define TRIO_ARGS2(list,a1,a2) list a1; a2;
135# define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3;
136# define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4;
137# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5;
138# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6;
139# define TRIO_VARGS2(list,a1,a2) list a1; a2
140# define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
141# define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
142# define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
143# define TRIO_VA_DECL va_dcl
144# define TRIO_VA_START(x,y) va_start((x))
145# define TRIO_VA_END(x) va_end(x)
146#else /* ANSI C */
147# define TRIO_CONST const
148# define TRIO_VOLATILE volatile
149# define TRIO_SIGNED signed
150typedef long double trio_long_double_t;
151typedef void * trio_pointer_t;
152# define TRIO_SUFFIX_LONG(x) x ## L
153# define TRIO_PROTO(x) x
154# define TRIO_NOARGS void
155# define TRIO_ARGS1(list,a1) (a1)
156# define TRIO_ARGS2(list,a1,a2) (a1,a2)
157# define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
158# define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
159# define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
160# define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
161# define TRIO_VARGS2 TRIO_ARGS2
162# define TRIO_VARGS3 TRIO_ARGS3
163# define TRIO_VARGS4 TRIO_ARGS4
164# define TRIO_VARGS5 TRIO_ARGS5
165# define TRIO_VA_DECL ...
166# define TRIO_VA_START(x,y) va_start((x),(y))
167# define TRIO_VA_END(x) va_end(x)
Bjorn Reese026d29f2002-01-19 15:40:18 +0000168#endif
169
170#if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus)
171# define TRIO_INLINE inline
172#elif defined(TRIO_COMPILER_GCC)
173# define TRIO_INLINE __inline__
Daniel Veillardb7c29c32002-09-25 22:44:43 +0000174#elif defined(TRIO_COMPILER_MSVC)
175# define TRIO_INLINE _inline
176#elif defined(TRIO_COMPILER_BCB)
177# define TRIO_INLINE __inline
Bjorn Reese026d29f2002-01-19 15:40:18 +0000178#else
179# define TRIO_INLINE
180#endif
181
182#endif /* TRIO_TRIODEF_H */