triodef.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. #ifndef TRIO_TRIODEF_H
  18. #define TRIO_TRIODEF_H
  19. /*************************************************************************
  20. * Platform and compiler support detection
  21. */
  22. #if defined(__GNUC__)
  23. # define TRIO_COMPILER_GCC
  24. #elif defined(__SUNPRO_C)
  25. # define TRIO_COMPILER_SUNPRO
  26. #elif defined(__SUNPRO_CC)
  27. # define TRIO_COMPILER_SUNPRO
  28. # define __SUNPRO_C __SUNPRO_CC
  29. #elif defined(__xlC__) || defined(__IBMC__) || defined(__IBMCPP__)
  30. # define TRIO_COMPILER_XLC
  31. #elif defined(_AIX) && !defined(__GNUC__)
  32. # define TRIO_COMPILER_XLC /* Workaround for old xlc */
  33. #elif defined(__DECC) || defined(__DECCXX)
  34. # define TRIO_COMPILER_DECC
  35. #elif defined(__osf__) && defined(__LANGUAGE_C__)
  36. # define TRIO_COMPILER_DECC /* Workaround for old DEC C compilers */
  37. #elif defined(_MSC_VER)
  38. # define TRIO_COMPILER_MSVC
  39. #elif defined(__BORLANDC__)
  40. # define TRIO_COMPILER_BCB
  41. #endif
  42. #if defined(VMS) || defined(__VMS)
  43. /*
  44. * VMS is placed first to avoid identifying the platform as Unix
  45. * based on the DECC compiler later on.
  46. */
  47. # define TRIO_PLATFORM_VMS
  48. #elif defined(unix) || defined(__unix) || defined(__unix__)
  49. # define TRIO_PLATFORM_UNIX
  50. #elif defined(TRIO_COMPILER_XLC) || defined(_AIX)
  51. # define TRIO_PLATFORM_UNIX
  52. #elif defined(TRIO_COMPILER_DECC) || defined(__osf___)
  53. # define TRIO_PLATFORM_UNIX
  54. #elif defined(__NetBSD__)
  55. # define TRIO_PLATFORM_UNIX
  56. #elif defined(__QNX__)
  57. # define TRIO_PLATFORM_UNIX
  58. # define TRIO_PLATFORM_QNX
  59. #elif defined(__CYGWIN__)
  60. # define TRIO_PLATFORM_UNIX
  61. #elif defined(AMIGA) && defined(TRIO_COMPILER_GCC)
  62. # define TRIO_PLATFORM_UNIX
  63. #elif defined(TRIO_COMPILER_MSVC) || defined(WIN32) || defined(_WIN32)
  64. # define TRIO_PLATFORM_WIN32
  65. #elif defined(mpeix) || defined(__mpexl)
  66. # define TRIO_PLATFORM_MPEIX
  67. #endif
  68. #if defined(_AIX)
  69. # define TRIO_PLATFORM_AIX
  70. #elif defined(__hpux)
  71. # define TRIO_PLATFORM_HPUX
  72. #elif defined(sun) || defined(__sun__)
  73. # if defined(__SVR4) || defined(__svr4__)
  74. # define TRIO_PLATFORM_SOLARIS
  75. # else
  76. # define TRIO_PLATFORM_SUNOS
  77. # endif
  78. #endif
  79. #if defined(__STDC__) || defined(TRIO_COMPILER_MSVC) || defined(TRIO_COMPILER_BCB)
  80. # define TRIO_COMPILER_SUPPORTS_C89
  81. # if defined(__STDC_VERSION__)
  82. # define TRIO_COMPILER_SUPPORTS_C90
  83. # if (__STDC_VERSION__ >= 199409L)
  84. # define TRIO_COMPILER_SUPPORTS_C94
  85. # endif
  86. # if (__STDC_VERSION__ >= 199901L)
  87. # define TRIO_COMPILER_SUPPORTS_C99
  88. # endif
  89. # elif defined(TRIO_COMPILER_SUNPRO)
  90. # if (__SUNPRO_C >= 0x420)
  91. # define TRIO_COMPILER_SUPPORTS_C94
  92. # endif
  93. # endif
  94. #endif
  95. #if defined(_XOPEN_SOURCE)
  96. # if defined(_XOPEN_SOURCE_EXTENDED)
  97. # define TRIO_COMPILER_SUPPORTS_UNIX95
  98. # endif
  99. # if (_XOPEN_VERSION >= 500)
  100. # define TRIO_COMPILER_SUPPORTS_UNIX98
  101. # endif
  102. # if (_XOPEN_VERSION >= 600)
  103. # define TRIO_COMPILER_SUPPORTS_UNIX01
  104. # endif
  105. #endif
  106. /*************************************************************************
  107. * Generic defines
  108. */
  109. #if !defined(TRIO_PUBLIC)
  110. # define TRIO_PUBLIC
  111. #endif
  112. #if !defined(TRIO_PRIVATE)
  113. # define TRIO_PRIVATE static
  114. #endif
  115. #if !(defined(TRIO_COMPILER_SUPPORTS_C89) || defined(__cplusplus))
  116. # define TRIO_COMPILER_ANCIENT
  117. #endif
  118. #if defined(TRIO_COMPILER_ANCIENT)
  119. # define TRIO_CONST
  120. # define TRIO_VOLATILE
  121. # define TRIO_SIGNED
  122. typedef double trio_long_double_t;
  123. typedef char * trio_pointer_t;
  124. # define TRIO_SUFFIX_LONG(x) x
  125. # define TRIO_PROTO(x) ()
  126. # define TRIO_NOARGS
  127. # define TRIO_ARGS1(list,a1) list a1;
  128. # define TRIO_ARGS2(list,a1,a2) list a1; a2;
  129. # define TRIO_ARGS3(list,a1,a2,a3) list a1; a2; a3;
  130. # define TRIO_ARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4;
  131. # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5;
  132. # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) list a1; a2; a3; a4; a5; a6;
  133. # define TRIO_VARGS2(list,a1,a2) list a1; a2
  134. # define TRIO_VARGS3(list,a1,a2,a3) list a1; a2; a3
  135. # define TRIO_VARGS4(list,a1,a2,a3,a4) list a1; a2; a3; a4
  136. # define TRIO_VARGS5(list,a1,a2,a3,a4,a5) list a1; a2; a3; a4; a5
  137. # define TRIO_VA_DECL va_dcl
  138. # define TRIO_VA_START(x,y) va_start(x)
  139. # define TRIO_VA_END(x) va_end(x)
  140. #else /* ANSI C */
  141. # define TRIO_CONST const
  142. # define TRIO_VOLATILE volatile
  143. # define TRIO_SIGNED signed
  144. typedef long double trio_long_double_t;
  145. typedef void * trio_pointer_t;
  146. # define TRIO_SUFFIX_LONG(x) x ## L
  147. # define TRIO_PROTO(x) x
  148. # define TRIO_NOARGS void
  149. # define TRIO_ARGS1(list,a1) (a1)
  150. # define TRIO_ARGS2(list,a1,a2) (a1,a2)
  151. # define TRIO_ARGS3(list,a1,a2,a3) (a1,a2,a3)
  152. # define TRIO_ARGS4(list,a1,a2,a3,a4) (a1,a2,a3,a4)
  153. # define TRIO_ARGS5(list,a1,a2,a3,a4,a5) (a1,a2,a3,a4,a5)
  154. # define TRIO_ARGS6(list,a1,a2,a3,a4,a5,a6) (a1,a2,a3,a4,a5,a6)
  155. # define TRIO_VARGS2 TRIO_ARGS2
  156. # define TRIO_VARGS3 TRIO_ARGS3
  157. # define TRIO_VARGS4 TRIO_ARGS4
  158. # define TRIO_VARGS5 TRIO_ARGS5
  159. # define TRIO_VA_DECL ...
  160. # define TRIO_VA_START(x,y) va_start(x,y)
  161. # define TRIO_VA_END(x) va_end(x)
  162. #endif
  163. #if defined(TRIO_COMPILER_SUPPORTS_C99) || defined(__cplusplus)
  164. # define TRIO_INLINE inline
  165. #elif defined(TRIO_COMPILER_GCC)
  166. # define TRIO_INLINE __inline__
  167. #elif defined(TRIO_COMPILER_MSVC)
  168. # define TRIO_INLINE _inline
  169. #elif defined(TRIO_COMPILER_BCB)
  170. # define TRIO_INLINE __inline
  171. #else
  172. # define TRIO_INLINE
  173. #endif
  174. /*************************************************************************
  175. * Workarounds
  176. */
  177. #if defined(TRIO_PLATFORM_VMS)
  178. /*
  179. * Computations done with constants at compile time can trigger these
  180. * even when compiling with IEEE enabled.
  181. */
  182. # pragma message disable (UNDERFLOW, FLOATOVERFL)
  183. # if (__CRTL_VER < 80000000)
  184. /*
  185. * Although the compiler supports C99 language constructs, the C
  186. * run-time library does not contain all C99 functions.
  187. *
  188. * This was the case for 70300022. Update the 80000000 value when
  189. * it has been accurately determined what version of the library
  190. * supports C99.
  191. */
  192. # if defined(TRIO_COMPILER_SUPPORTS_C99)
  193. # undef TRIO_COMPILER_SUPPORTS_C99
  194. # endif
  195. # endif
  196. #endif
  197. /*
  198. * Not all preprocessors supports the LL token.
  199. */
  200. #if defined(TRIO_COMPILER_BCB)
  201. #else
  202. # define TRIO_COMPILER_SUPPORTS_LL
  203. #endif
  204. #endif /* TRIO_TRIODEF_H */