Debian Codegraph @

m4/fabsl.m4

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