Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 1 | /************************************************************************* |
| 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 Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 18 | #ifndef TRIO_TRIODEF_H |
| 19 | #define TRIO_TRIODEF_H |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 20 | |
| 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 Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 37 | #elif defined(__osf__) && defined(__LANGUAGE_C__) |
| 38 | # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 39 | #elif defined(_MSC_VER) |
| 40 | # define TRIO_COMPILER_MSVC |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 41 | #elif defined(__BORLANDC__) |
| 42 | # define TRIO_COMPILER_BCB |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 43 | #endif |
| 44 | |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 45 | #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 |
Patrick Monnerat | ca9fc43 | 2013-12-12 15:11:40 +0800 | [diff] [blame] | 51 | #elif defined(__OS400__) |
| 52 | # define TRIO_PLATFORM_OS400 |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 53 | #elif defined(unix) || defined(__unix) || defined(__unix__) |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 54 | # define TRIO_PLATFORM_UNIX |
| 55 | #elif defined(TRIO_COMPILER_XLC) || defined(_AIX) |
| 56 | # define TRIO_PLATFORM_UNIX |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 57 | #elif defined(TRIO_COMPILER_DECC) || defined(__osf___) |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 58 | # define TRIO_PLATFORM_UNIX |
| 59 | #elif defined(__NetBSD__) |
| 60 | # define TRIO_PLATFORM_UNIX |
Daniel Veillard | f79fbfc | 2006-05-31 13:35:28 +0000 | [diff] [blame] | 61 | #elif defined(__Lynx__) |
| 62 | # define TRIO_PLATFORM_UNIX |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 63 | #elif defined(__QNX__) |
| 64 | # define TRIO_PLATFORM_UNIX |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 65 | # define TRIO_PLATFORM_QNX |
Daniel Veillard | 3c5ed91 | 2002-01-08 10:36:16 +0000 | [diff] [blame] | 66 | #elif defined(__CYGWIN__) |
| 67 | # define TRIO_PLATFORM_UNIX |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 68 | #elif defined(AMIGA) && defined(TRIO_COMPILER_GCC) |
| 69 | # define TRIO_PLATFORM_UNIX |
| 70 | #elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32) |
| 71 | # define TRIO_PLATFORM_WIN32 |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 72 | #elif defined(mpeix) || defined(__mpexl) |
| 73 | # define TRIO_PLATFORM_MPEIX |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 74 | #endif |
| 75 | |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 76 | #if defined(_AIX) |
| 77 | # define TRIO_PLATFORM_AIX |
| 78 | #elif defined(__hpux) |
| 79 | # define TRIO_PLATFORM_HPUX |
| 80 | #elif defined(sun) || defined(__sun__) |
| 81 | # if defined(__SVR4) || defined(__svr4__) |
| 82 | # define TRIO_PLATFORM_SOLARIS |
| 83 | # else |
| 84 | # define TRIO_PLATFORM_SUNOS |
| 85 | # endif |
| 86 | #endif |
| 87 | |
| 88 | #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB) |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 89 | # define TRIO_COMPILER_SUPPORTS_C89 |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 90 | # if defined(__STDC_VERSION__) |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 91 | # define TRIO_COMPILER_SUPPORTS_C90 |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 92 | # if (__STDC_VERSION__ >= 199409L) |
| 93 | # define TRIO_COMPILER_SUPPORTS_C94 |
| 94 | # endif |
| 95 | # if (__STDC_VERSION__ >= 199901L) |
| 96 | # define TRIO_COMPILER_SUPPORTS_C99 |
| 97 | # endif |
| 98 | # elif defined(TRIO_COMPILER_SUNPRO) |
| 99 | # if (__SUNPRO_C >= 0x420) |
| 100 | # define TRIO_COMPILER_SUPPORTS_C94 |
| 101 | # endif |
| 102 | # endif |
Patrick Monnerat | ca9fc43 | 2013-12-12 15:11:40 +0800 | [diff] [blame] | 103 | #elif defined(TRIO_COMPILER_XLC) && defined(__EXTENDED__) |
| 104 | # define TRIO_COMPILER_SUPPORTS_C89 |
| 105 | # define TRIO_COMPILER_SUPPORTS_C90 |
| 106 | # define TRIO_COMPILER_SUPPORTS_C94 |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 107 | #endif |
| 108 | |
| 109 | #if defined(_XOPEN_SOURCE) |
| 110 | # if defined(_XOPEN_SOURCE_EXTENDED) |
| 111 | # define TRIO_COMPILER_SUPPORTS_UNIX95 |
| 112 | # endif |
| 113 | # if (_XOPEN_VERSION >= 500) |
| 114 | # define TRIO_COMPILER_SUPPORTS_UNIX98 |
| 115 | # endif |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 116 | # if (_XOPEN_VERSION >= 600) |
| 117 | # define TRIO_COMPILER_SUPPORTS_UNIX01 |
| 118 | # endif |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 119 | #endif |
| 120 | |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 121 | /************************************************************************* |
| 122 | * Generic defines |
| 123 | */ |
| 124 | |
| 125 | #if !defined(TRIO_PUBLIC) |
| 126 | # define TRIO_PUBLIC |
| 127 | #endif |
| 128 | #if !defined(TRIO_PRIVATE) |
| 129 | # define TRIO_PRIVATE static |
| 130 | #endif |
| 131 | |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 132 | #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) |
| 133 | # define TRIO_COMPILER_ANCIENT |
| 134 | #endif |
| 135 | |
| 136 | #if defined(TRIO_COMPILER_ANCIENT) |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 137 | # define TRIO_CONST |
| 138 | # define TRIO_VOLATILE |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 139 | # define TRIO_SIGNED |
| 140 | typedef double trio_long_double_t; |
| 141 | typedef char * trio_pointer_t; |
| 142 | # define TRIO_SUFFIX_LONG(x) x |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 143 | # define TRIO_PROTO(x) () |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 144 | # define TRIO_NOARGS |
| 145 | # define TRIO_ARGS1(list,a1) list a1; |
| 146 | # define TRIO_ARGS2(list,a1,a2) list a1; a2; |
| 147 | # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; |
| 148 | # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; |
| 149 | # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; |
| 150 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; |
| 151 | # define TRIO_VARGS2(list,a1,a2) list a1; a2 |
| 152 | # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 |
| 153 | # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 |
| 154 | # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 |
| 155 | # define TRIO_VA_DECL va_dcl |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 156 | # define TRIO_VA_START(x,y) va_start(x) |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 157 | # define TRIO_VA_END(x) va_end(x) |
| 158 | #else /* ANSI C */ |
| 159 | # define TRIO_CONST const |
| 160 | # define TRIO_VOLATILE volatile |
| 161 | # define TRIO_SIGNED signed |
| 162 | typedef long double trio_long_double_t; |
| 163 | typedef void * trio_pointer_t; |
| 164 | # define TRIO_SUFFIX_LONG(x) x ## L |
| 165 | # define TRIO_PROTO(x) x |
| 166 | # define TRIO_NOARGS void |
| 167 | # define TRIO_ARGS1(list,a1) (a1) |
| 168 | # define TRIO_ARGS2(list,a1,a2) (a1,a2) |
| 169 | # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) |
| 170 | # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) |
| 171 | # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) |
| 172 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) |
| 173 | # define TRIO_VARGS2 TRIO_ARGS2 |
| 174 | # define TRIO_VARGS3 TRIO_ARGS3 |
| 175 | # define TRIO_VARGS4 TRIO_ARGS4 |
| 176 | # define TRIO_VARGS5 TRIO_ARGS5 |
| 177 | # define TRIO_VA_DECL ... |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 178 | # define TRIO_VA_START(x,y) va_start(x,y) |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 179 | # define TRIO_VA_END(x) va_end(x) |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 180 | #endif |
| 181 | |
| 182 | #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) |
| 183 | # define TRIO_INLINE inline |
| 184 | #elif defined(TRIO_COMPILER_GCC) |
| 185 | # define TRIO_INLINE __inline__ |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 186 | #elif defined(TRIO_COMPILER_MSVC) |
| 187 | # define TRIO_INLINE _inline |
| 188 | #elif defined(TRIO_COMPILER_BCB) |
| 189 | # define TRIO_INLINE __inline |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 190 | #else |
| 191 | # define TRIO_INLINE |
| 192 | #endif |
| 193 | |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 194 | /************************************************************************* |
| 195 | * Workarounds |
| 196 | */ |
| 197 | |
| 198 | #if defined(TRIO_PLATFORM_VMS) |
| 199 | /* |
| 200 | * Computations done with constants at compile time can trigger these |
| 201 | * even when compiling with IEEE enabled. |
| 202 | */ |
| 203 | # pragma message disable (UNDERFLOW, FLOATOVERFL) |
| 204 | |
Daniel Veillard | 1c96027 | 2003-04-25 23:12:22 +0000 | [diff] [blame] | 205 | # if (__CRTL_VER < 80000000) |
Daniel Veillard | a48ed3d | 2003-04-03 15:28:28 +0000 | [diff] [blame] | 206 | /* |
| 207 | * Although the compiler supports C99 language constructs, the C |
| 208 | * run-time library does not contain all C99 functions. |
| 209 | * |
| 210 | * This was the case for 70300022. Update the 80000000 value when |
| 211 | * it has been accurately determined what version of the library |
| 212 | * supports C99. |
| 213 | */ |
| 214 | # if defined(TRIO_COMPILER_SUPPORTS_C99) |
| 215 | # undef TRIO_COMPILER_SUPPORTS_C99 |
| 216 | # endif |
| 217 | # endif |
| 218 | #endif |
| 219 | |
| 220 | /* |
| 221 | * Not all preprocessors supports the LL token. |
| 222 | */ |
| 223 | #if defined(TRIO_COMPILER_BCB) |
| 224 | #else |
| 225 | # define TRIO_COMPILER_SUPPORTS_LL |
| 226 | #endif |
| 227 | |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 228 | #endif /* TRIO_TRIODEF_H */ |