triodef.h 6.6 KB

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