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