* ChangeLog: Fix misspelling
[gnulib.git] / m4 / fabsl.m4
blobf2a2e0785d2d1ee0da5c7289d454f5adb04df4bb
1 # fabsl.m4
2 # serial 5
3 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_FABSL],
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
13   dnl Persuade glibc <math.h> to declare fabsl().
14   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   dnl Determine FABSL_LIBM.
17   gl_MATHFUNC([fabsl], [long double], [(long double)])
18   if test $gl_cv_func_fabsl_no_libm = yes \
19      || test $gl_cv_func_fabsl_in_libm = yes; then
20     saved_LIBS="$LIBS"
21     LIBS="$LIBS $FABSL_LIBM"
22     gl_FUNC_FABSL_WORKS
23     LIBS="$saved_LIBS"
24     case "$gl_cv_func_fabsl_works" in
25       *yes) ;;
26       *) REPLACE_FABSL=1 ;;
27     esac
28   else
29     HAVE_FABSL=0
30   fi
31   if test $HAVE_FABSL = 0 || test $REPLACE_FABSL = 1; then
32     dnl Find libraries needed to link lib/fabsl.c.
33     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
34       AC_REQUIRE([gl_FUNC_FABS])
35       FABSL_LIBM="$FABS_LIBM"
36     else
37       FABSL_LIBM=
38     fi
39   fi
40   AC_SUBST([FABSL_LIBM])
43 dnl Test whether fabsl() works on a minus zero.
44 dnl On IRIX 6.5, with gcc 4.2.4 and without -fno-builtin-fabsl, the value is a
45 dnl minus zero rather than a positive zero.
46 AC_DEFUN([gl_FUNC_FABSL_WORKS],
48   AC_REQUIRE([AC_PROG_CC])
49   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
50   AC_CACHE_CHECK([whether fabsl works], [gl_cv_func_fabsl_works],
51     [
52       AC_RUN_IFELSE(
53         [AC_LANG_SOURCE([[
54 #include <float.h>
55 #include <math.h>
56 #include <string.h>
57 volatile long double x;
58 long double y;
59 long double zero = 0.0L;
60 int main ()
62   x = - (LDBL_MIN * LDBL_MIN * LDBL_MIN);
63   y = fabsl (x);
64   return (memcmp (&y, &zero, sizeof y) != 0);
66 ]])],
67         [gl_cv_func_fabsl_works=yes],
68         [gl_cv_func_fabsl_works=no],
69         [case "$host_os" in
70            irix*)             gl_cv_func_fabsl_works="guessing no" ;;
71                               # Guess yes on native Windows.
72            mingw* | windows*) gl_cv_func_fabsl_works="guessing yes" ;;
73            *)                 gl_cv_func_fabsl_works="guessing yes" ;;
74          esac
75         ])
76     ])