maint: update copyright
[gnulib.git] / m4 / fabsl.m4
1 # fabsl.m4 serial 2
2 dnl Copyright (C) 2011-2014 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.
6
7 AC_DEFUN([gl_FUNC_FABSL],
8 [
9   AC_REQUIRE([gl_MATH_H_DEFAULTS])
10   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
11
12   dnl Persuade glibc <math.h> to declare fabsl().
13   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14
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
19     save_LIBS="$LIBS"
20     LIBS="$LIBS $FABSL_LIBM"
21     gl_FUNC_FABSL_WORKS
22     LIBS="$save_LIBS"
23     case "$gl_cv_func_fabsl_works" in
24       *yes) ;;
25       *) REPLACE_FABSL=1 ;;
26     esac
27   else
28     HAVE_FABSL=0
29   fi
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"
35     else
36       FABSL_LIBM=
37     fi
38   fi
39   AC_SUBST([FABSL_LIBM])
40 ])
41
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],
46 [
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],
50     [
51       AC_RUN_IFELSE(
52         [AC_LANG_SOURCE([[
53 #include <float.h>
54 #include <math.h>
55 #include <string.h>
56 volatile long double x;
57 long double y;
58 long double zero = 0.0L;
59 int main ()
60 {
61   x = - (LDBL_MIN * LDBL_MIN * LDBL_MIN);
62   y = fabsl (x);
63   return (memcmp (&y, &zero, sizeof y) != 0);
64 }
65 ]])],
66         [gl_cv_func_fabsl_works=yes],
67         [gl_cv_func_fabsl_works=no],
68         [case "$host_os" in
69            irix*) gl_cv_func_fabsl_works="guessing no";;
70            *)     gl_cv_func_fabsl_works="guessing yes";;
71          esac
72         ])
73     ])
74 ])