math_h.m4 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. # math_h.m4 serial 56
  2. dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. AC_DEFUN([gl_MATH_H],
  7. [
  8. AC_REQUIRE([gl_MATH_H_DEFAULTS])
  9. gl_CHECK_NEXT_HEADERS([math.h])
  10. AC_REQUIRE([AC_C_INLINE])
  11. AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
  12. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
  13. [[/* Solaris 10 has a broken definition of NAN. Other platforms
  14. fail to provide NAN, or provide it only in C99 mode; this
  15. test only needs to fail when NAN is provided but wrong. */
  16. float f = 1.0f;
  17. #ifdef NAN
  18. f = NAN;
  19. #endif
  20. return f == 0;]])],
  21. [gl_cv_header_math_nan_works=yes],
  22. [gl_cv_header_math_nan_works=no])])
  23. if test $gl_cv_header_math_nan_works = no; then
  24. REPLACE_NAN=1
  25. fi
  26. AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
  27. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
  28. [[/* Solaris 10 has a broken definition of HUGE_VAL. */
  29. double d = HUGE_VAL;
  30. return d == 0;]])],
  31. [gl_cv_header_math_huge_val_works=yes],
  32. [gl_cv_header_math_huge_val_works=no])])
  33. if test $gl_cv_header_math_huge_val_works = no; then
  34. REPLACE_HUGE_VAL=1
  35. fi
  36. dnl Check for declarations of anything we want to poison if the
  37. dnl corresponding gnulib module is not in use.
  38. gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
  39. [acosf acosl asinf asinl atanf atanl
  40. ceilf ceill copysign copysignf copysignl cosf cosl coshf
  41. expf expl fabsf floorf floorl fma fmaf fmal fmodf frexpf frexpl
  42. ldexpf ldexpl logb logf logl log10f modff powf
  43. rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
  44. tanf tanl tanhf trunc truncf truncl])
  45. ])
  46. AC_DEFUN([gl_MATH_MODULE_INDICATOR],
  47. [
  48. dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  49. AC_REQUIRE([gl_MATH_H_DEFAULTS])
  50. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  51. dnl Define it also as a C macro, for the benefit of the unit tests.
  52. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  53. ])
  54. AC_DEFUN([gl_MATH_H_DEFAULTS],
  55. [
  56. GNULIB_ACOSF=0; AC_SUBST([GNULIB_ACOSF])
  57. GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
  58. GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF])
  59. GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
  60. GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF])
  61. GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
  62. GNULIB_ATAN2F=0; AC_SUBST([GNULIB_ATAN2F])
  63. GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL])
  64. GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
  65. GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
  66. GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN])
  67. GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
  68. GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
  69. GNULIB_COSF=0; AC_SUBST([GNULIB_COSF])
  70. GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
  71. GNULIB_COSHF=0; AC_SUBST([GNULIB_COSHF])
  72. GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF])
  73. GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
  74. GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF])
  75. GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR])
  76. GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
  77. GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
  78. GNULIB_FMA=0; AC_SUBST([GNULIB_FMA])
  79. GNULIB_FMAF=0; AC_SUBST([GNULIB_FMAF])
  80. GNULIB_FMAL=0; AC_SUBST([GNULIB_FMAL])
  81. GNULIB_FMODF=0; AC_SUBST([GNULIB_FMODF])
  82. GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
  83. GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
  84. GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
  85. GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
  86. GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
  87. GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
  88. GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF])
  89. GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
  90. GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
  91. GNULIB_LDEXPF=0; AC_SUBST([GNULIB_LDEXPF])
  92. GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
  93. GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
  94. GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF])
  95. GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
  96. GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F])
  97. GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
  98. GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
  99. GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
  100. GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
  101. GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL])
  102. GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
  103. GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
  104. GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
  105. GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
  106. GNULIB_SINF=0; AC_SUBST([GNULIB_SINF])
  107. GNULIB_SINL=0; AC_SUBST([GNULIB_SINL])
  108. GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF])
  109. GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF])
  110. GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL])
  111. GNULIB_TANF=0; AC_SUBST([GNULIB_TANF])
  112. GNULIB_TANL=0; AC_SUBST([GNULIB_TANL])
  113. GNULIB_TANHF=0; AC_SUBST([GNULIB_TANHF])
  114. GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC])
  115. GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
  116. GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
  117. dnl Assume proper GNU behavior unless another module says otherwise.
  118. HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF])
  119. HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
  120. HAVE_ASINF=1; AC_SUBST([HAVE_ASINF])
  121. HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
  122. HAVE_ATANF=1; AC_SUBST([HAVE_ATANF])
  123. HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
  124. HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F])
  125. HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN])
  126. HAVE_COPYSIGNF=1; AC_SUBST([HAVE_COPYSIGNF])
  127. HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL])
  128. HAVE_COSF=1; AC_SUBST([HAVE_COSF])
  129. HAVE_COSL=1; AC_SUBST([HAVE_COSL])
  130. HAVE_COSHF=1; AC_SUBST([HAVE_COSHF])
  131. HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
  132. HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
  133. HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
  134. HAVE_FMA=1; AC_SUBST([HAVE_FMA])
  135. HAVE_FMAF=1; AC_SUBST([HAVE_FMAF])
  136. HAVE_FMAL=1; AC_SUBST([HAVE_FMAL])
  137. HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
  138. HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
  139. HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
  140. HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
  141. HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
  142. HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF])
  143. HAVE_LOGF=1; AC_SUBST([HAVE_LOGF])
  144. HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
  145. HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F])
  146. HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
  147. HAVE_POWF=1; AC_SUBST([HAVE_POWF])
  148. HAVE_RINT=1; AC_SUBST([HAVE_RINT])
  149. HAVE_RINTF=1; AC_SUBST([HAVE_RINTF])
  150. HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
  151. HAVE_SINF=1; AC_SUBST([HAVE_SINF])
  152. HAVE_SINL=1; AC_SUBST([HAVE_SINL])
  153. HAVE_SINHF=1; AC_SUBST([HAVE_SINHF])
  154. HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF])
  155. HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
  156. HAVE_TANF=1; AC_SUBST([HAVE_TANF])
  157. HAVE_TANL=1; AC_SUBST([HAVE_TANL])
  158. HAVE_TANHF=1; AC_SUBST([HAVE_TANHF])
  159. HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
  160. HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
  161. HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
  162. HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF])
  163. HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL])
  164. HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL])
  165. HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL])
  166. HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF])
  167. HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
  168. HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL])
  169. HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL])
  170. HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
  171. HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL])
  172. HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND])
  173. HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF])
  174. HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL])
  175. HAVE_DECL_SINL=1; AC_SUBST([HAVE_DECL_SINL])
  176. HAVE_DECL_SQRTL=1; AC_SUBST([HAVE_DECL_SQRTL])
  177. HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
  178. HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC])
  179. HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
  180. HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
  181. REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL])
  182. REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF])
  183. REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL])
  184. REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR])
  185. REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
  186. REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
  187. REPLACE_FMA=0; AC_SUBST([REPLACE_FMA])
  188. REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF])
  189. REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL])
  190. REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
  191. REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
  192. REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
  193. REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
  194. REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
  195. REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
  196. REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
  197. REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
  198. REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
  199. REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
  200. REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
  201. REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])
  202. REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT])
  203. REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC])
  204. REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC])
  205. REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF])
  206. REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
  207. ])
  208. # gl_LONG_DOUBLE_VS_DOUBLE
  209. # determines whether 'long double' and 'double' have the same representation.
  210. # Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
  211. # HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
  212. # The currently known platforms where this is the case are:
  213. # Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
  214. AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
  215. [
  216. AC_CACHE_CHECK([whether long double and double are the same],
  217. [gl_cv_long_double_equals_double],
  218. [AC_COMPILE_IFELSE(
  219. [AC_LANG_PROGRAM([[#include <float.h>]],
  220. [[typedef int check[sizeof (long double) == sizeof (double)
  221. && LDBL_MANT_DIG == DBL_MANT_DIG
  222. && LDBL_MAX_EXP == DBL_MAX_EXP
  223. && LDBL_MIN_EXP == DBL_MIN_EXP
  224. ? 1 : -1];
  225. ]])],
  226. [gl_cv_long_double_equals_double=yes],
  227. [gl_cv_long_double_equals_double=no])
  228. ])
  229. if test $gl_cv_long_double_equals_double = yes; then
  230. AC_DEFINE([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE], [1],
  231. [Define to 1 if 'long double' and 'double' have the same representation.])
  232. HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1
  233. else
  234. HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0
  235. fi
  236. AC_SUBST([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE])
  237. ])