1 | /************************************************************************* |
---|
2 | * |
---|
3 | * $Id: triodef.h,v 1.1.1.2 2002-12-26 06:43:27 ghudson 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 | * 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 |
---|
37 | #elif defined(__osf__) && defined(__LANGUAGE_C__) |
---|
38 | # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */ |
---|
39 | #elif defined(_MSC_VER) |
---|
40 | # define TRIO_COMPILER_MSVC |
---|
41 | #elif defined(__BORLANDC__) |
---|
42 | # define TRIO_COMPILER_BCB |
---|
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(__VMS) ) || 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 |
---|
55 | # define TRIO_PLATFORM_QNX |
---|
56 | #elif defined(__CYGWIN__) |
---|
57 | # define TRIO_PLATFORM_UNIX |
---|
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 |
---|
62 | #elif defined(VMS) || defined(__VMS) |
---|
63 | # define TRIO_PLATFORM_VMS |
---|
64 | #elif defined(mpeix) || defined(__mpexl) |
---|
65 | # define TRIO_PLATFORM_MPEIX |
---|
66 | #endif |
---|
67 | |
---|
68 | #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) |
---|
69 | # define TRIO_COMPILER_SUPPORTS_C89 |
---|
70 | # if defined(__STDC_VERSION__) |
---|
71 | # define TRIO_COMPILER_SUPPORTS_C90 |
---|
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(TRIO_PLATFORM_VMS) |
---|
86 | /* The compiler does support C99 but the library still does not have things |
---|
87 | * the standard requires (like nan() and strtof()) as of __CRTL_VER 70300022. |
---|
88 | */ |
---|
89 | # undef TRIO_COMPILER_SUPPORTS_C99 |
---|
90 | |
---|
91 | /* Computations done with constants at compile time can trigger these |
---|
92 | * even when compiling with IEEE enabled. |
---|
93 | */ |
---|
94 | # pragma message disable (UNDERFLOW,FLOATOVERFL) |
---|
95 | #endif /* TRIO_PLATFORM_VMS */ |
---|
96 | |
---|
97 | #if defined(_XOPEN_SOURCE) |
---|
98 | # if defined(_XOPEN_SOURCE_EXTENDED) |
---|
99 | # define TRIO_COMPILER_SUPPORTS_UNIX95 |
---|
100 | # endif |
---|
101 | # if (_XOPEN_VERSION >= 500) |
---|
102 | # define TRIO_COMPILER_SUPPORTS_UNIX98 |
---|
103 | # endif |
---|
104 | # if (_XOPEN_VERSION >= 600) |
---|
105 | # define TRIO_COMPILER_SUPPORTS_UNIX01 |
---|
106 | # endif |
---|
107 | #endif |
---|
108 | |
---|
109 | /************************************************************************* |
---|
110 | * Generic defines |
---|
111 | */ |
---|
112 | |
---|
113 | #if !defined(TRIO_PUBLIC) |
---|
114 | # define TRIO_PUBLIC |
---|
115 | #endif |
---|
116 | #if !defined(TRIO_PRIVATE) |
---|
117 | # define TRIO_PRIVATE static |
---|
118 | #endif |
---|
119 | |
---|
120 | #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus)) |
---|
121 | # define TRIO_COMPILER_ANCIENT |
---|
122 | #endif |
---|
123 | |
---|
124 | #if defined(TRIO_COMPILER_ANCIENT) |
---|
125 | # define TRIO_CONST |
---|
126 | # define TRIO_VOLATILE |
---|
127 | # define TRIO_SIGNED |
---|
128 | typedef double trio_long_double_t; |
---|
129 | typedef char * trio_pointer_t; |
---|
130 | # define TRIO_SUFFIX_LONG(x) x |
---|
131 | # define TRIO_PROTO(x) () |
---|
132 | # define TRIO_NOARGS |
---|
133 | # define TRIO_ARGS1(list,a1) list a1; |
---|
134 | # define TRIO_ARGS2(list,a1,a2) list a1; a2; |
---|
135 | # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3; |
---|
136 | # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4; |
---|
137 | # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5; |
---|
138 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6; |
---|
139 | # define TRIO_VARGS2(list,a1,a2) list a1; a2 |
---|
140 | # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3 |
---|
141 | # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4 |
---|
142 | # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5 |
---|
143 | # define TRIO_VA_DECL va_dcl |
---|
144 | # define TRIO_VA_START(x,y) va_start((x)) |
---|
145 | # define TRIO_VA_END(x) va_end(x) |
---|
146 | #else /* ANSI C */ |
---|
147 | # define TRIO_CONST const |
---|
148 | # define TRIO_VOLATILE volatile |
---|
149 | # define TRIO_SIGNED signed |
---|
150 | typedef long double trio_long_double_t; |
---|
151 | typedef void * trio_pointer_t; |
---|
152 | # define TRIO_SUFFIX_LONG(x) x ## L |
---|
153 | # define TRIO_PROTO(x) x |
---|
154 | # define TRIO_NOARGS void |
---|
155 | # define TRIO_ARGS1(list,a1) (a1) |
---|
156 | # define TRIO_ARGS2(list,a1,a2) (a1,a2) |
---|
157 | # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3) |
---|
158 | # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4) |
---|
159 | # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5) |
---|
160 | # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6) |
---|
161 | # define TRIO_VARGS2 TRIO_ARGS2 |
---|
162 | # define TRIO_VARGS3 TRIO_ARGS3 |
---|
163 | # define TRIO_VARGS4 TRIO_ARGS4 |
---|
164 | # define TRIO_VARGS5 TRIO_ARGS5 |
---|
165 | # define TRIO_VA_DECL ... |
---|
166 | # define TRIO_VA_START(x,y) va_start((x),(y)) |
---|
167 | # define TRIO_VA_END(x) va_end(x) |
---|
168 | #endif |
---|
169 | |
---|
170 | #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus) |
---|
171 | # define TRIO_INLINE inline |
---|
172 | #elif defined(TRIO_COMPILER_GCC) |
---|
173 | # define TRIO_INLINE __inline__ |
---|
174 | #elif defined(TRIO_COMPILER_MSVC) |
---|
175 | # define TRIO_INLINE _inline |
---|
176 | #elif defined(TRIO_COMPILER_BCB) |
---|
177 | # define TRIO_INLINE __inline |
---|
178 | #else |
---|
179 | # define TRIO_INLINE |
---|
180 | #endif |
---|
181 | |
---|
182 | #endif /* TRIO_TRIODEF_H */ |
---|