triodef.h 6.8 KB

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