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
21 LIBS="$LIBS $FABSL_LIBM"
24 case "$gl_cv_func_fabsl_works" in
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"
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],
57 volatile long double x;
59 long double zero = 0.0L;
62 x = - (LDBL_MIN * LDBL_MIN * LDBL_MIN);
64 return (memcmp (&y, &zero, sizeof y) != 0);
67 [gl_cv_func_fabsl_works=yes],
68 [gl_cv_func_fabsl_works=no],
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" ;;