isnand.m4 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # isnand.m4 serial 12
  2. dnl Copyright (C) 2007-2023 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. dnl Check how to get or define isnand().
  7. AC_DEFUN([gl_FUNC_ISNAND],
  8. [
  9. AC_REQUIRE([gl_MATH_H_DEFAULTS])
  10. ISNAND_LIBM=
  11. gl_HAVE_ISNAND_NO_LIBM
  12. if test $gl_cv_func_isnand_no_libm = no; then
  13. gl_HAVE_ISNAND_IN_LIBM
  14. if test $gl_cv_func_isnand_in_libm = yes; then
  15. ISNAND_LIBM=-lm
  16. fi
  17. fi
  18. dnl The variable gl_func_isnand set here is used by isnan.m4.
  19. if test $gl_cv_func_isnand_no_libm = yes \
  20. || test $gl_cv_func_isnand_in_libm = yes; then
  21. gl_func_isnand=yes
  22. else
  23. gl_func_isnand=no
  24. HAVE_ISNAND=0
  25. fi
  26. AC_SUBST([ISNAND_LIBM])
  27. ])
  28. dnl Check how to get or define isnand() without linking with libm.
  29. AC_DEFUN([gl_FUNC_ISNAND_NO_LIBM],
  30. [
  31. gl_HAVE_ISNAND_NO_LIBM
  32. gl_func_isnand_no_libm=$gl_cv_func_isnand_no_libm
  33. if test $gl_cv_func_isnand_no_libm = yes; then
  34. AC_DEFINE([HAVE_ISNAND_IN_LIBC], [1],
  35. [Define if the isnan(double) function is available in libc.])
  36. fi
  37. ])
  38. dnl Prerequisites of replacement isnand definition. It does not need -lm.
  39. AC_DEFUN([gl_PREREQ_ISNAND],
  40. [
  41. AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
  42. ])
  43. dnl Test whether isnand() can be used with libm.
  44. AC_DEFUN([gl_HAVE_ISNAND_IN_LIBM],
  45. [
  46. AC_CACHE_CHECK([whether isnan(double) can be used with libm],
  47. [gl_cv_func_isnand_in_libm],
  48. [
  49. save_LIBS="$LIBS"
  50. LIBS="$LIBS -lm"
  51. AC_LINK_IFELSE(
  52. [AC_LANG_PROGRAM(
  53. [[#include <math.h>
  54. #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
  55. # undef isnand
  56. # define isnand(x) __builtin_isnan ((double)(x))
  57. #elif defined isnan
  58. # undef isnand
  59. # define isnand(x) isnan ((double)(x))
  60. #endif
  61. double x;]],
  62. [[return isnand (x);]])],
  63. [gl_cv_func_isnand_in_libm=yes],
  64. [gl_cv_func_isnand_in_libm=no])
  65. LIBS="$save_LIBS"
  66. ])
  67. ])
  68. AC_DEFUN([gl_HAVE_ISNAND_NO_LIBM],
  69. [
  70. AC_CACHE_CHECK([whether isnan(double) can be used without linking with libm],
  71. [gl_cv_func_isnand_no_libm],
  72. [
  73. AC_LINK_IFELSE(
  74. [AC_LANG_PROGRAM(
  75. [[#include <math.h>
  76. #if (__GNUC__ >= 4) || (__clang_major__ >= 4)
  77. # undef isnand
  78. # define isnand(x) __builtin_isnan ((double)(x))
  79. #else
  80. # undef isnand
  81. # define isnand(x) isnan ((double)(x))
  82. #endif
  83. double x;]],
  84. [[return isnand (x);]])],
  85. [gl_cv_func_isnand_no_libm=yes],
  86. [gl_cv_func_isnand_no_libm=no])
  87. ])
  88. ])