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