maint.mk: add per-line exclusions to prohibitions
[gnulib.git] / m4 / fabsl.m4
1 # fabsl.m4 serial 1
2 dnl Copyright (C) 2011-2012 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 Determine FABSL_LIBM.
13   gl_MATHFUNC([fabsl], [long double], [(long double)])
14   if test $gl_cv_func_fabsl_no_libm = yes \
15      || test $gl_cv_func_fabsl_in_libm = yes; then
16     save_LIBS="$LIBS"
17     LIBS="$LIBS $FABSL_LIBM"
18     gl_FUNC_FABSL_WORKS
19     LIBS="$save_LIBS"
20     case "$gl_cv_func_fabsl_works" in
21       *yes) ;;
22       *) REPLACE_FABSL=1 ;;
23     esac
24   else
25     HAVE_FABSL=0
26   fi
27   if test $HAVE_FABSL = 0 || test $REPLACE_FABSL = 1; then
28     dnl Find libraries needed to link lib/fabsl.c.
29     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
30       AC_REQUIRE([gl_FUNC_FABS])
31       FABSL_LIBM="$FABS_LIBM"
32     else
33       FABSL_LIBM=
34     fi
35   fi
36   AC_SUBST([FABSL_LIBM])
37 ])
38
39 dnl Test whether fabsl() works on a minus zero.
40 dnl On IRIX 6.5, with gcc 4.2.4 and without -fno-builtin-fabsl, the value is a
41 dnl minus zero rather than a positive zero.
42 AC_DEFUN([gl_FUNC_FABSL_WORKS],
43 [
44   AC_REQUIRE([AC_PROG_CC])
45   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
46   AC_CACHE_CHECK([whether fabsl works], [gl_cv_func_fabsl_works],
47     [
48       AC_RUN_IFELSE(
49         [AC_LANG_SOURCE([[
50 #include <float.h>
51 #include <math.h>
52 #include <string.h>
53 volatile long double x;
54 long double y;
55 long double zero = 0.0L;
56 int main ()
57 {
58   x = - (LDBL_MIN * LDBL_MIN * LDBL_MIN);
59   y = fabsl (x);
60   return (memcmp (&y, &zero, sizeof y) != 0);
61 }
62 ]])],
63         [gl_cv_func_fabsl_works=yes],
64         [gl_cv_func_fabsl_works=no],
65         [case "$host_os" in
66            irix*) gl_cv_func_fabsl_works="guessing no";;
67            *)     gl_cv_func_fabsl_works="guessing yes";;
68          esac
69         ])
70     ])
71 ])