float_h.m4 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # float_h.m4 serial 9
  2. dnl Copyright (C) 2007, 2009-2014 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*)
  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_EGREP_CPP([yes],
  27. [#if defined __LP64__ || defined __x86_64__ || defined __amd64__
  28. yes
  29. #endif],
  30. [],
  31. [FLOAT_H=float.h])
  32. ;;
  33. esac
  34. ;;
  35. linux*)
  36. case "$host_cpu" in
  37. powerpc*)
  38. FLOAT_H=float.h
  39. ;;
  40. esac
  41. ;;
  42. esac
  43. case "$host_os" in
  44. aix* | freebsd* | linux*)
  45. if test -n "$FLOAT_H"; then
  46. REPLACE_FLOAT_LDBL=1
  47. fi
  48. ;;
  49. esac
  50. dnl Test against glibc-2.7 Linux/SPARC64 bug.
  51. REPLACE_ITOLD=0
  52. AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
  53. [gl_cv_func_itold_works],
  54. [
  55. AC_RUN_IFELSE(
  56. [AC_LANG_SOURCE([[
  57. int i = -1;
  58. volatile long double ld;
  59. int main ()
  60. {
  61. ld += i * 1.0L;
  62. if (ld > 0)
  63. return 1;
  64. return 0;
  65. }]])],
  66. [gl_cv_func_itold_works=yes],
  67. [gl_cv_func_itold_works=no],
  68. [case "$host" in
  69. sparc*-*-linux*)
  70. AC_EGREP_CPP([yes],
  71. [#if defined __LP64__ || defined __arch64__
  72. yes
  73. #endif],
  74. [gl_cv_func_itold_works="guessing no"],
  75. [gl_cv_func_itold_works="guessing yes"])
  76. ;;
  77. *) gl_cv_func_itold_works="guessing yes" ;;
  78. esac
  79. ])
  80. ])
  81. case "$gl_cv_func_itold_works" in
  82. *no)
  83. REPLACE_ITOLD=1
  84. dnl We add the workaround to <float.h> but also to <math.h>,
  85. dnl to increase the chances that the fix function gets pulled in.
  86. FLOAT_H=float.h
  87. ;;
  88. esac
  89. if test -n "$FLOAT_H"; then
  90. gl_NEXT_HEADERS([float.h])
  91. fi
  92. AC_SUBST([FLOAT_H])
  93. AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
  94. AC_SUBST([REPLACE_ITOLD])
  95. ])