fchmod-tests, fchmodat tests, lchmod tests: Add more tests.
[gnulib.git] / m4 / log1pf.m4
blobb72ab9e8ff53701b5f705afd4d4da69639721cbf
1 # log1pf.m4 serial 8
2 dnl Copyright (C) 2012-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.
7 AC_DEFUN([gl_FUNC_LOG1PF],
9   m4_divert_text([DEFAULTS], [gl_log1pf_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_FUNC_LOG1P])
13   dnl Persuade glibc <math.h> to declare log1pf().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   dnl Test whether log1pf() exists. Assume that log1pf(), if it exists, is
17   dnl defined in the same library as log1p().
18   save_LIBS="$LIBS"
19   LIBS="$LIBS $LOG1P_LIBM"
20   AC_CHECK_FUNCS([log1pf])
21   LIBS="$save_LIBS"
22   if test $ac_cv_func_log1pf = yes; then
23     LOG1PF_LIBM="$LOG1P_LIBM"
25     save_LIBS="$LIBS"
26     LIBS="$LIBS $LOG1PF_LIBM"
27     gl_FUNC_LOG1PF_WORKS
28     LIBS="$save_LIBS"
29     case "$gl_cv_func_log1pf_works" in
30       *yes) ;;
31       *) REPLACE_LOG1PF=1 ;;
32     esac
34     m4_ifdef([gl_FUNC_LOG1PF_IEEE], [
35       if test $gl_log1pf_required = ieee && test $REPLACE_LOG1PF = 0; then
36         AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
37         AC_CACHE_CHECK([whether log1pf works according to ISO C 99 with IEC 60559],
38           [gl_cv_func_log1pf_ieee],
39           [
40             save_LIBS="$LIBS"
41             LIBS="$LIBS $LOG1PF_LIBM"
42             AC_RUN_IFELSE(
43               [AC_LANG_SOURCE([[
44 #ifndef __NO_MATH_INLINES
45 # define __NO_MATH_INLINES 1 /* for glibc */
46 #endif
47 #include <math.h>
48 ]gl_FLOAT_MINUS_ZERO_CODE[
49 ]gl_FLOAT_SIGNBIT_CODE[
50 static float dummy (float x) { return 0; }
51 int main (int argc, char *argv[])
53   float (* volatile my_log1pf) (float) = argc ? log1pf : dummy;
54   /* This test fails on OpenBSD 4.9, AIX 7.1.  */
55   float y = my_log1pf (minus_zerof);
56   if (!(y == 0.0f) || (signbitf (minus_zerof) && !signbitf (y)))
57     return 1;
58   return 0;
60               ]])],
61               [gl_cv_func_log1pf_ieee=yes],
62               [gl_cv_func_log1pf_ieee=no],
63               [case "$host_os" in
64                                 # Guess yes on glibc systems.
65                  *-gnu* | gnu*) gl_cv_func_log1pf_ieee="guessing yes" ;;
66                                 # Guess yes on musl systems.
67                  *-musl*)       gl_cv_func_log1pf_ieee="guessing yes" ;;
68                                 # Guess yes on native Windows.
69                  mingw*)        gl_cv_func_log1pf_ieee="guessing yes" ;;
70                                 # If we don't know, obey --enable-cross-guesses.
71                  *)             gl_cv_func_log1pf_ieee="$gl_cross_guess_normal" ;;
72                esac
73               ])
74             LIBS="$save_LIBS"
75           ])
76         case "$gl_cv_func_log1pf_ieee" in
77           *yes) ;;
78           *) REPLACE_LOG1PF=1 ;;
79         esac
80       fi
81     ])
82   else
83     HAVE_LOG1PF=0
84   fi
85   if test $HAVE_LOG1PF = 0 || test $REPLACE_LOG1PF = 1; then
86     dnl Find libraries needed to link lib/log1pf.c.
87     LOG1PF_LIBM="$LOG1P_LIBM"
88   fi
89   AC_SUBST([LOG1PF_LIBM])
92 dnl Test whether log1pf() works.
93 dnl On IRIX 6.5, log1pf(-1.0f) returns +Infinity instead of -Infinity.
94 AC_DEFUN([gl_FUNC_LOG1PF_WORKS],
96   AC_REQUIRE([AC_PROG_CC])
97   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
98   AC_CACHE_CHECK([whether log1pf works], [gl_cv_func_log1pf_works],
99     [
100       AC_RUN_IFELSE(
101         [AC_LANG_SOURCE([[
102 #include <math.h>
103 volatile float x;
104 float y;
105 int main ()
107   x = -1.0f;
108   y = log1pf (x);
109   if (!(y + y == y && y < 0.0f))
110     return 1;
111   return 0;
113 ]])],
114         [gl_cv_func_log1pf_works=yes],
115         [gl_cv_func_log1pf_works=no],
116         [case "$host_os" in
117            irix*)  gl_cv_func_log1pf_works="guessing no" ;;
118                    # Guess yes on native Windows.
119            mingw*) gl_cv_func_log1pf_works="guessing yes" ;;
120            *)      gl_cv_func_log1pf_works="guessing yes" ;;
121          esac
122         ])
123     ])