log1p.m4 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # log1p.m4 serial 3
  2. dnl Copyright (C) 2012-2017 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 (*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*) gl_cv_func_log1p_ieee="guessing yes" ;;
  53. # If we don't know, assume the worst.
  54. *) gl_cv_func_log1p_ieee="guessing no" ;;
  55. esac
  56. ])
  57. LIBS="$save_LIBS"
  58. ])
  59. case "$gl_cv_func_log1p_ieee" in
  60. *yes) ;;
  61. *) REPLACE_LOG1P=1 ;;
  62. esac
  63. fi
  64. ])
  65. else
  66. HAVE_LOG1P=0
  67. fi
  68. if test $HAVE_LOG1P = 0 || test $REPLACE_LOG1P = 1; then
  69. dnl Find libraries needed to link lib/log1p.c.
  70. AC_REQUIRE([gl_FUNC_ISNAND])
  71. AC_REQUIRE([gl_FUNC_LOG])
  72. AC_REQUIRE([gl_FUNC_ROUND])
  73. LOG1P_LIBM=
  74. dnl Append $ISNAND_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
  75. case " $LOG1P_LIBM " in
  76. *" $ISNAND_LIBM "*) ;;
  77. *) LOG1P_LIBM="$LOG1P_LIBM $ISNAND_LIBM" ;;
  78. esac
  79. dnl Append $LOG_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
  80. case " $LOG1P_LIBM " in
  81. *" $LOG_LIBM "*) ;;
  82. *) LOG1P_LIBM="$LOG1P_LIBM $LOG_LIBM" ;;
  83. esac
  84. dnl Append $ROUND_LIBM to LOG1P_LIBM, avoiding gratuitous duplicates.
  85. case " $LOG1P_LIBM " in
  86. *" $ROUND_LIBM "*) ;;
  87. *) LOG1P_LIBM="$LOG1P_LIBM $ROUND_LIBM" ;;
  88. esac
  89. fi
  90. ])