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 | |
| 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 |
| 49 | #elif defined(TRIO_COMPILER_DECC) || defined(__osf__) |
| 50 | # define TRIO_PLATFORM_UNIX |
| 51 | #elif defined(__NetBSD__) |
| 52 | # define TRIO_PLATFORM_UNIX |
| 53 | #elif defined(__QNX__) |
| 54 | # define TRIO_PLATFORM_UNIX |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 55 | # define TRIO_PLATFORM_QNX |
Daniel Veillard | 3c5ed91 | 2002-01-08 10:36:16 +0000 | [diff] [blame] | 56 | #elif defined(__CYGWIN__) |
| 57 | # define TRIO_PLATFORM_UNIX |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 58 | #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 Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 62 | #elif defined(VMS) || defined(__VMS) |
| 63 | # define TRIO_PLATFORM_VMS |
| 64 | #elif defined(mpeix) || defined(__mpexl) |
| 65 | # define TRIO_PLATFORM_MPEIX |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 68 | #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) |
| 69 | # define TRIO_COMPILER_SUPPORTS_C89 |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 70 | # if defined(__STDC_VERSION__) |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 71 | # define TRIO_COMPILER_SUPPORTS_C90 |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 72 | # 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 | |
| 85 | #if defined(_XOPEN_SOURCE) |
| 86 | # if defined(_XOPEN_SOURCE_EXTENDED) |
| 87 | # define TRIO_COMPILER_SUPPORTS_UNIX95 |
| 88 | # endif |
| 89 | # if (_XOPEN_VERSION >= 500) |
| 90 | # define TRIO_COMPILER_SUPPORTS_UNIX98 |
| 91 | # endif |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 92 | # if (_XOPEN_VERSION >= 600) |
| 93 | # define TRIO_COMPILER_SUPPORTS_UNIX01 |
| 94 | # endif |
Bjorn Reese | 4502960 | 2001-08-21 09:23:53 +0000 | [diff] [blame] | 95 | #endif |
| 96 | |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 97 | /************************************************************************* |
| 98 | * Generic defines |
| 99 | */ |
| 100 | |
| 101 | #if !defined(TRIO_PUBLIC) |
| 102 | # define TRIO_PUBLIC |
| 103 | #endif |
| 104 | #if !defined(TRIO_PRIVATE) |
| 105 | # define TRIO_PRIVATE static |
| 106 | #endif |
| 107 | |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 108 | #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) |
| 109 | # define TRIO_COMPILER_ANCIENT |
| 110 | #endif |
| 111 | |
| 112 | #if defined(TRIO_COMPILER_ANCIENT) |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 113 | # define TRIO_CONST |
| 114 | # define TRIO_VOLATILE |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 115 | # define TRIO_SIGNED |
| 116 | typedef double trio_long_double_t; |
| 117 | typedef char * trio_pointer_t; |
| 118 | # define TRIO_SUFFIX_LONG(x) x |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 119 | # define TRIO_PROTO(x) () |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 120 | # define TRIO_NOARGS |
| 121 | # define TRIO_ARGS1(list,a1) list a1; |
| 122 | # define TRIO_ARGS2(list,a1,a2) list a1; a2; |
| 123 | # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; |
| 124 | # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; |
| 125 | # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; |
| 126 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; |
| 127 | # define TRIO_VARGS2(list,a1,a2) list a1; a2 |
| 128 | # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 |
| 129 | # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 |
| 130 | # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 |
| 131 | # define TRIO_VA_DECL va_dcl |
| 132 | # define TRIO_VA_START(x,y) va_start((x)) |
| 133 | # define TRIO_VA_END(x) va_end(x) |
| 134 | #else /* ANSI C */ |
| 135 | # define TRIO_CONST const |
| 136 | # define TRIO_VOLATILE volatile |
| 137 | # define TRIO_SIGNED signed |
| 138 | typedef long double trio_long_double_t; |
| 139 | typedef void * trio_pointer_t; |
| 140 | # define TRIO_SUFFIX_LONG(x) x ## L |
| 141 | # define TRIO_PROTO(x) x |
| 142 | # define TRIO_NOARGS void |
| 143 | # define TRIO_ARGS1(list,a1) (a1) |
| 144 | # define TRIO_ARGS2(list,a1,a2) (a1,a2) |
| 145 | # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) |
| 146 | # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) |
| 147 | # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) |
| 148 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) |
| 149 | # define TRIO_VARGS2 TRIO_ARGS2 |
| 150 | # define TRIO_VARGS3 TRIO_ARGS3 |
| 151 | # define TRIO_VARGS4 TRIO_ARGS4 |
| 152 | # define TRIO_VARGS5 TRIO_ARGS5 |
| 153 | # define TRIO_VA_DECL ... |
| 154 | # define TRIO_VA_START(x,y) va_start((x),(y)) |
| 155 | # define TRIO_VA_END(x) va_end(x) |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 156 | #endif |
| 157 | |
| 158 | #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) |
| 159 | # define TRIO_INLINE inline |
| 160 | #elif defined(TRIO_COMPILER_GCC) |
| 161 | # define TRIO_INLINE __inline__ |
Daniel Veillard | b7c29c3 | 2002-09-25 22:44:43 +0000 | [diff] [blame] | 162 | #elif defined(TRIO_COMPILER_MSVC) |
| 163 | # define TRIO_INLINE _inline |
| 164 | #elif defined(TRIO_COMPILER_BCB) |
| 165 | # define TRIO_INLINE __inline |
Bjorn Reese | 026d29f | 2002-01-19 15:40:18 +0000 | [diff] [blame] | 166 | #else |
| 167 | # define TRIO_INLINE |
| 168 | #endif |
| 169 | |
| 170 | #endif /* TRIO_TRIODEF_H */ |