maint.mk: add per-line exclusions to prohibitions
[gnulib.git] / m4 / cbrtl.m4
1 # cbrtl.m4 serial 2
2 dnl Copyright (C) 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_CBRTL],
8 [
9   m4_divert_text([DEFAULTS], [gl_cbrtl_required=plain])
10   AC_REQUIRE([gl_MATH_H_DEFAULTS])
11   AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
12   AC_REQUIRE([gl_FUNC_CBRT])
13
14   dnl Test whether cbrtl() exists. Assume that cbrtl(), if it exists, is
15   dnl defined in the same library as cbrt().
16   save_LIBS="$LIBS"
17   LIBS="$LIBS $CBRT_LIBM"
18   AC_CHECK_FUNCS([cbrtl])
19   LIBS="$save_LIBS"
20   if test $ac_cv_func_cbrtl = yes; then
21     CBRTL_LIBM="$CBRT_LIBM"
22     dnl Also check whether it's declared.
23     dnl IRIX 6.5 has cbrtl() in libm but doesn't declare it in <math.h>.
24     AC_CHECK_DECL([cbrtl], , [HAVE_DECL_CBRTL=0], [[#include <math.h>]])
25     m4_ifdef([gl_FUNC_CBRTL_IEEE], [
26       if test $gl_cbrtl_required = ieee && test $REPLACE_CBRTL = 0; then
27         AC_CACHE_CHECK([whether cbrtl works according to ISO C 99 with IEC 60559],
28           [gl_cv_func_cbrtl_ieee],
29           [
30             save_LIBS="$LIBS"
31             LIBS="$LIBS $CBRTL_LIBM"
32             AC_RUN_IFELSE(
33               [AC_LANG_SOURCE([[
34 #ifndef __NO_MATH_INLINES
35 # define __NO_MATH_INLINES 1 /* for glibc */
36 #endif
37 #include <math.h>
38 ]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
39 ]gl_LONG_DOUBLE_SIGNBIT_CODE[
40 static long double dummy (long double x) { return 0; }
41 int main (int argc, char *argv[])
42 {
43   extern
44   #ifdef __cplusplus
45   "C"
46   #endif
47   long double cbrtl (long double);
48   long double (*my_cbrtl) (long double) = argc ? cbrtl : dummy;
49   long double f;
50   /* Test cbrtl(-0.0).
51      This test fails on IRIX 6.5.  */
52   f = my_cbrtl (minus_zerol);
53   if (!(f == 0.0L) || (signbitl (minus_zerol) && !signbitl (f)))
54     return 1;
55   return 0;
56 }
57               ]])],
58               [gl_cv_func_cbrtl_ieee=yes],
59               [gl_cv_func_cbrtl_ieee=no],
60               [gl_cv_func_cbrtl_ieee="guessing no"])
61             LIBS="$save_LIBS"
62           ])
63         case "$gl_cv_func_cbrtl_ieee" in
64           *yes) ;;
65           *) REPLACE_CBRTL=1 ;;
66         esac
67       fi
68     ])
69   else
70     HAVE_CBRTL=0
71     HAVE_DECL_CBRTL=0
72   fi
73   if test $HAVE_CBRTL = 0 || test $REPLACE_CBRTL = 1; then
74     dnl Find libraries needed to link lib/cbrtl.c.
75     if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
76       CBRTL_LIBM="$CBRT_LIBM"
77     else
78       AC_REQUIRE([gl_FUNC_FREXPL])
79       AC_REQUIRE([gl_FUNC_LDEXPL])
80       CBRTL_LIBM=
81       dnl Append $FREXPL_LIBM to CBRTL_LIBM, avoiding gratuitous duplicates.
82       case " $CBRTL_LIBM " in
83         *" $FREXPL_LIBM "*) ;;
84         *) CBRTL_LIBM="$CBRTL_LIBM $FREXPL_LIBM" ;;
85       esac
86       dnl Append $LDEXPL_LIBM to CBRTL_LIBM, avoiding gratuitous duplicates.
87       case " $CBRTL_LIBM " in
88         *" $LDEXPL_LIBM "*) ;;
89         *) CBRTL_LIBM="$CBRTL_LIBM $LDEXPL_LIBM" ;;
90       esac
91     fi
92   fi
93   AC_SUBST([CBRTL_LIBM])
94 ])