float_h.m4 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # float_h.m4 serial 12
  2. dnl Copyright (C) 2007, 2009-2021 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_FLOAT_H],
  7. [
  8. AC_REQUIRE([AC_PROG_CC])
  9. AC_REQUIRE([AC_CANONICAL_HOST])
  10. FLOAT_H=
  11. REPLACE_FLOAT_LDBL=0
  12. case "$host_os" in
  13. aix* | beos* | openbsd* | mirbsd* | irix*)
  14. FLOAT_H=float.h
  15. ;;
  16. freebsd* | dragonfly*)
  17. case "$host_cpu" in
  18. changequote(,)dnl
  19. i[34567]86 )
  20. changequote([,])dnl
  21. FLOAT_H=float.h
  22. ;;
  23. x86_64 )
  24. # On x86_64 systems, the C compiler may still be generating
  25. # 32-bit code.
  26. AC_COMPILE_IFELSE(
  27. [AC_LANG_SOURCE(
  28. [[#if defined __LP64__ || defined __x86_64__ || defined __amd64__
  29. int ok;
  30. #else
  31. error fail
  32. #endif
  33. ]])],
  34. [],
  35. [FLOAT_H=float.h])
  36. ;;
  37. esac
  38. ;;
  39. linux*)
  40. case "$host_cpu" in
  41. powerpc*)
  42. FLOAT_H=float.h
  43. ;;
  44. esac
  45. ;;
  46. esac
  47. case "$host_os" in
  48. aix* | freebsd* | dragonfly* | linux*)
  49. if test -n "$FLOAT_H"; then
  50. REPLACE_FLOAT_LDBL=1
  51. fi
  52. ;;
  53. esac
  54. dnl Test against glibc-2.7 Linux/SPARC64 bug.
  55. REPLACE_ITOLD=0
  56. AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
  57. [gl_cv_func_itold_works],
  58. [
  59. AC_RUN_IFELSE(
  60. [AC_LANG_SOURCE([[
  61. int i = -1;
  62. volatile long double ld;
  63. int main ()
  64. {
  65. ld += i * 1.0L;
  66. if (ld > 0)
  67. return 1;
  68. return 0;
  69. }]])],
  70. [gl_cv_func_itold_works=yes],
  71. [gl_cv_func_itold_works=no],
  72. [case "$host" in
  73. sparc*-*-linux*)
  74. AC_COMPILE_IFELSE(
  75. [AC_LANG_SOURCE(
  76. [[#if defined __LP64__ || defined __arch64__
  77. int ok;
  78. #else
  79. error fail
  80. #endif
  81. ]])],
  82. [gl_cv_func_itold_works="guessing no"],
  83. [gl_cv_func_itold_works="guessing yes"])
  84. ;;
  85. # Guess yes on native Windows.
  86. mingw*) gl_cv_func_itold_works="guessing yes" ;;
  87. *) gl_cv_func_itold_works="guessing yes" ;;
  88. esac
  89. ])
  90. ])
  91. case "$gl_cv_func_itold_works" in
  92. *no)
  93. REPLACE_ITOLD=1
  94. dnl We add the workaround to <float.h> but also to <math.h>,
  95. dnl to increase the chances that the fix function gets pulled in.
  96. FLOAT_H=float.h
  97. ;;
  98. esac
  99. if test -n "$FLOAT_H"; then
  100. gl_NEXT_HEADERS([float.h])
  101. fi
  102. AC_SUBST([FLOAT_H])
  103. AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
  104. AC_SUBST([REPLACE_ITOLD])
  105. ])