log1p.m4 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # log1p.m4 serial 8
  2. dnl Copyright (C) 2012-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. AC_DEFUN([gl_FUNC_LOG1P],
  7. [
  8. m4_divert_text([DEFAULTS], [gl_log1p_required=plain])
  9. AC_REQUIRE([gl_MATH_H_DEFAULTS])
  10. dnl Persuade glibc <math.h> to declare log1p().
  11. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  12. dnl Determine LOG1P_LIBM.
  13. gl_COMMON_DOUBLE_MATHFUNC([log1p])
  14. dnl Test whether log1p() exists.
  15. save_LIBS="$LIBS"
  16. LIBS="$LIBS $LOG1P_LIBM"
  17. AC_CHECK_FUNCS([log1p])
  18. LIBS="$save_LIBS"
  19. if test $ac_cv_func_log1p = yes; then
  20. :
  21. m4_ifdef([gl_FUNC_LOG1P_IEEE], [
  22. if test $gl_log1p_required = ieee && test $REPLACE_LOG1P = 0; then
  23. AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
  24. AC_CACHE_CHECK([whether log1p works according to ISO C 99 with IEC 60559],
  25. [gl_cv_func_log1p_ieee],
  26. [
  27. save_LIBS="$LIBS"
  28. LIBS="$LIBS $LOG1P_LIBM"
  29. AC_RUN_IFELSE(
  30. [AC_LANG_SOURCE([[
  31. #ifndef __NO_MATH_INLINES
  32. # define __NO_MATH_INLINES 1 /* for glibc */
  33. #endif
  34. #include <math.h>
  35. ]gl_DOUBLE_MINUS_ZERO_CODE[
  36. ]gl_DOUBLE_SIGNBIT_CODE[
  37. static double dummy (double x) { return 0; }
  38. int main (int argc, char *argv[])
  39. {
  40. double (* volatile my_log1p) (double) = argc ? log1p : dummy;
  41. /* This test fails on AIX, HP-UX 11. */
  42. double y = my_log1p (minus_zerod);
  43. if (!(y == 0.0) || (signbitd (minus_zerod) && !signbitd (y)))
  44. return 1;
  45. return 0;
  46. }
  47. ]])],
  48. [gl_cv_func_log1p_ieee=yes],
  49. [gl_cv_func_log1p_ieee=no],
  50. [case "$host_os" in
  51. # Guess yes on glibc systems.
  52. *-gnu* | gnu*) gl_cv_func_log1p_ieee="guessing yes" ;;
  53. # Guess yes on musl systems.
  54. *-musl*) gl_cv_func_log1p_ieee="guessing yes" ;;
  55. # Guess yes on native Windows.
  56. mingw*) gl_cv_func_log1p_ieee="guessing yes" ;;
  57. # If we don't know, obey --enable-cross-guesses.
  58. *) gl_cv_func_log1p_ieee="$gl_cross_guess_normal" ;;
  59. esac
  60. ])
  61. LIBS="$save_LIBS"
  62. ])
  63. case "$gl_cv_func_log1p_ieee" in
  64. *yes) ;;
  65. *) REPLACE_LOG1P=1 ;;
  66. esac
  67. fi
  68. ])
  69. else
  70. HAVE_LOG1P=0
  71. fi
  72. if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then
  73. dnl Find libraries needed to link lib/log1p.c.
  74. AC_REQUIRE([gl_FUNC_ISNAND])
  75. AC_REQUIRE([gl_FUNC_LOG])
  76. AC_REQUIRE([gl_FUNC_ROUND])
  77. LOG1P_LIBM=
  78. dnl Append $ISNAND_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
  79. case " $LOG1P_LIBM " in
  80. *" $ISNAND_LIBM "*) ;;
  81. *) LOG1P_LIBM="$LOG1P_LIBM $ISNAND_LIBM" ;;
  82. esac
  83. dnl Append $LOG_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
  84. case " $LOG1P_LIBM " in
  85. *" $LOG_LIBM "*) ;;
  86. *) LOG1P_LIBM="$LOG1P_LIBM $LOG_LIBM" ;;
  87. esac
  88. dnl Append $ROUND_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
  89. case " $LOG1P_LIBM " in
  90. *" $ROUND_LIBM "*) ;;
  91. *) LOG1P_LIBM="$LOG1P_LIBM $ROUND_LIBM" ;;
  92. esac
  93. fi
  94. ])