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