1 /************************************************************************* 2 * 3 * $Id: triodef.h,v 1.27 2005/03/27 18:52:45 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_C) 30 # define TRIO_COMPILER_SUNPRO 31 #endif 32 33 #if defined(__SUNPRO_CC) 34 # define TRIO_COMPILER_SUNPRO 35 # define __SUNPRO_C __SUNPRO_CC 36 #endif 37 38 #if defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__) 39 # define TRIO_COMPILER_XLC 40 #else 41 # if defined(_AIX) && !defined(__GNUC__) 42 # define TRIO_COMPILER_XLC /* Workaround for old xlc */ 43 # endif 44 #endif 45 46 #if defined(__DECC) || defined(__DECCXX) 47 # define TRIO_COMPILER_DECC 48 #else 49 # if defined(__osf__) && defined(__LANGUAGE_C__) && !defined(__GNUC__) 50 # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ 51 # endif 52 #endif 53 54 #if defined(__HP_aCC) || defined(__HP_cc) 55 # define TRIO_COMPILER_HP 56 #endif 57 58 #if defined(_MSC_VER) 59 # define TRIO_COMPILER_MSVC 60 #endif 61 62 #if defined(__BORLANDC__) 63 # define TRIO_COMPILER_BCB 64 #endif 65 66 /************************************************************************* 67 * Platform support detection 68 */ 69 70 #if defined(VMS) || defined(__VMS) 71 # define TRIO_PLATFORM_VMS 72 #endif 73 74 #if defined(unix) || defined(__unix) || defined(__unix__) 75 # define TRIO_PLATFORM_UNIX 76 #endif 77 78 #if defined(TRIO_COMPILER_XLC) || defined(_AIX) 79 # define TRIO_PLATFORM_UNIX 80 #endif 81 82 #if defined(TRIO_COMPILER_DECC) || defined(__osf___) 83 # if !defined(TRIO_PLATFORM_VMS) 84 # define TRIO_PLATFORM_UNIX 85 # endif 86 #endif 87 88 #if defined(__NetBSD__) 89 # define TRIO_PLATFORM_UNIX 90 #endif 91 92 #if defined(__APPLE__) && defined(__MACH__) 93 # define TRIO_PLATFORM_UNIX 94 #endif 95 96 #if defined(__QNX__) 97 # define TRIO_PLATFORM_UNIX 98 # define TRIO_PLATFORM_QNX 99 #endif 100 101 #if defined(__CYGWIN__) 102 # define TRIO_PLATFORM_UNIX 103 #endif 104 105 #if defined(AMIGA) && defined(TRIO_COMPILER_GCC) 106 # define TRIO_PLATFORM_UNIX 107 #endif 108 109 #if defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) 110 # define TRIO_PLATFORM_WIN32 111 #endif 112 113 #if defined(mpeix) || defined(__mpexl) 114 # define TRIO_PLATFORM_MPEIX 115 #endif 116 117 #if defined(_AIX) 118 # define TRIO_PLATFORM_AIX 119 #endif 120 121 #if defined(__hpux) 122 # define TRIO_PLATFORM_HPUX 123 #endif 124 125 #if defined(sun) || defined(__sun__) 126 # if defined(__SVR4) || defined(__svr4__) 127 # define TRIO_PLATFORM_SOLARIS 128 # else 129 # define TRIO_PLATFORM_SUNOS 130 # endif 131 #endif 132 133 /************************************************************************* 134 * Standards support detection 135 */ 136 137 #if defined(__STDC__) \ 138 || defined(_MSC_EXTENSIONS) \ 139 || defined(TRIO_COMPILER_BORLAND) 140 # define PREDEF_STANDARD_C89 141 #endif 142 #if defined(__STDC_VERSION__) 143 # define PREDEF_STANDARD_C90 144 #endif 145 #if (__STDC_VERSION__ - 0 >= 199409L) 146 # define PREDEF_STANDARD_C94 147 #endif 148 #if (__STDC_VERSION__ - 0 >= 199901L) 149 # define PREDEF_STANDARD_C99 150 #endif 151 #if defined(TRIO_COMPILER_SUNPRO) && (TRIO_COMPILER_SUNPRO >= 0x420) 152 # if !defined(PREDEF_STANDARD_C94) 153 # define PREDEF_STANDARD_C94 154 # endif 155 #endif 156 157 #if defined(__cplusplus) 158 # define PREDEF_STANDARD_CXX 159 #endif 160 #if __cplusplus - 0 >= 199711L 161 # define PREDEF_STANDARD_CXX89 162 #endif 163 164 #if defined(TRIO_PLATFORM_UNIX) 165 # include <unistd.h> 166 #endif 167 168 #if (_XOPEN_VERSION - 0 >= 3) || defined(_XOPEN_XPG3) 169 # define PREDEF_STANDARD_XPG3 170 #endif 171 #if (_XOPEN_VERSION - 0 >= 4) || defined(_XOPEN_XPG4) 172 # define PREDEF_STANDARD_XPG4 173 #endif 174 #if (_XOPEN_VERSION - 0 > 4) \ 175 || (defined(_XOPEN_UNIX) && (_XOPEN_VERSION - 0 == 4)) 176 # define PREDEF_STANDARD_UNIX95 177 #endif 178 #if (_XOPEN_VERSION - 0 >= 500) 179 # define PREDEF_STANDARD_UNIX98 180 #endif 181 #if (_XOPEN_VERSION - 0 >= 600) 182 # define PREDEF_STANDARD_UNIX03 183 #endif 184 185 /************************************************************************* 186 * Generic defines 187 */ 188 189 #if !defined(TRIO_PUBLIC) 190 # define TRIO_PUBLIC 191 #endif 192 #if !defined(TRIO_PRIVATE) 193 # define TRIO_PRIVATE static 194 #endif 195 196 #if !(defined(PREDEF_STANDARD_C89) || defined(PREDEF_STANDARD_CXX)) 197 # define TRIO_COMPILER_ANCIENT 198 #endif 199 200 #if defined(TRIO_COMPILER_ANCIENT) 201 # define TRIO_CONST 202 # define TRIO_VOLATILE 203 # define TRIO_SIGNED 204 typedef double trio_long_double_t; 205 typedef char * trio_pointer_t; 206 # define TRIO_SUFFIX_LONG(x) x 207 # define TRIO_PROTO(x) () 208 # define TRIO_NOARGS 209 # define TRIO_ARGS1(list,a1) list a1; 210 # define TRIO_ARGS2(list,a1,a2) list a1; a2; 211 # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; 212 # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; 213 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; 214 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; 215 # define TRIO_VARGS2(list,a1,a2) list a1; a2 216 # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 217 # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 218 # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 219 # define TRIO_VA_DECL va_dcl 220 # define TRIO_VA_START(x,y) va_start(x) 221 # define TRIO_VA_END(x) va_end(x) 222 #else /* ANSI C */ 223 # define TRIO_CONST const 224 # define TRIO_VOLATILE volatile 225 # define TRIO_SIGNED signed 226 typedef long double trio_long_double_t; 227 typedef void * trio_pointer_t; 228 # define TRIO_SUFFIX_LONG(x) x ## L 229 # define TRIO_PROTO(x) x 230 # define TRIO_NOARGS void 231 # define TRIO_ARGS1(list,a1) (a1) 232 # define TRIO_ARGS2(list,a1,a2) (a1,a2) 233 # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) 234 # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) 235 # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) 236 # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) 237 # define TRIO_VARGS2 TRIO_ARGS2 238 # define TRIO_VARGS3 TRIO_ARGS3 239 # define TRIO_VARGS4 TRIO_ARGS4 240 # define TRIO_VARGS5 TRIO_ARGS5 241 # define TRIO_VA_DECL ... 242 # define TRIO_VA_START(x,y) va_start(x,y) 243 # define TRIO_VA_END(x) va_end(x) 244 #endif 245 246 #if defined(PREDEF_STANDARD_C99) || defined(PREDEF_STANDARD_CXX) 247 # define TRIO_INLINE inline 248 #else 249 # if defined(TRIO_COMPILER_GCC) 250 # define TRIO_INLINE __inline__ 251 # endif 252 # if defined(TRIO_COMPILER_MSVC) 253 # define TRIO_INLINE _inline 254 # endif 255 # if defined(TRIO_COMPILER_BCB) 256 # define TRIO_INLINE __inline 257 # endif 258 #endif 259 #if !defined(TRIO_INLINE) 260 # define TRIO_INLINE 261 #endif 262 263 /************************************************************************* 264 * Workarounds 265 */ 266 267 #if defined(TRIO_PLATFORM_VMS) 268 /* 269 * Computations done with constants at compile time can trigger these 270 * even when compiling with IEEE enabled. 271 */ 272 # pragma message disable (UNDERFLOW, FLOATOVERFL) 273 274 # if (__CRTL_VER < 80000000) 275 /* 276 * Although the compiler supports C99 language constructs, the C 277 * run-time library does not contain all C99 functions. 278 * 279 * This was the case for 70300022. Update the 80000000 value when 280 * it has been accurately determined what version of the library 281 * supports C99. 282 */ 283 # if defined(PREDEF_STANDARD_C99) 284 # undef PREDEF_STANDARD_C99 285 # endif 286 # endif 287 #endif 288 289 /* 290 * Not all preprocessors supports the LL token. 291 */ 292 #if defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) 293 #else 294 # define TRIO_COMPILER_SUPPORTS_LL 295 #endif 296 297 #endif /* TRIO_TRIODEF_H */ 298