2 dnl Copyright (C) 2011-2020 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_FABSL],
9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
12 dnl Persuade glibc <math.h> to declare fabsl().
13 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 dnl Determine FABSL_LIBM.
16 gl_MATHFUNC([fabsl], [long double], [(long double)])
17 if test $gl_cv_func_fabsl_no_libm = yes \
18 || test $gl_cv_func_fabsl_in_libm = yes; then
20 LIBS="$LIBS $FABSL_LIBM"
23 case "$gl_cv_func_fabsl_works" in
30 if test $HAVE_FABSL = 0 || test $REPLACE_FABSL = 1; then
31 dnl Find libraries needed to link lib/fabsl.c.
32 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
33 AC_REQUIRE([gl_FUNC_FABS])
34 FABSL_LIBM="$FABS_LIBM"
39 AC_SUBST([FABSL_LIBM])
42 dnl Test whether fabsl() works on a minus zero.
43 dnl On IRIX 6.5, with gcc 4.2.4 and without -fno-builtin-fabsl, the value is a
44 dnl minus zero rather than a positive zero.
45 AC_DEFUN([gl_FUNC_FABSL_WORKS],
47 AC_REQUIRE([AC_PROG_CC])
48 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
49 AC_CACHE_CHECK([whether fabsl works], [gl_cv_func_fabsl_works],
56 volatile long double x;
58 long double zero = 0.0L;
61 x = - (LDBL_MIN * LDBL_MIN * LDBL_MIN);
63 return (memcmp (&y, &zero, sizeof y) != 0);
66 [gl_cv_func_fabsl_works=yes],
67 [gl_cv_func_fabsl_works=no],
69 irix*) gl_cv_func_fabsl_works="guessing no" ;;
70 # Guess yes on native Windows.
71 mingw*) gl_cv_func_fabsl_works="guessing yes" ;;
72 *) gl_cv_func_fabsl_works="guessing yes" ;;