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.
7 AC_DEFUN([gl_FUNC_CBRTL],
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])
14 dnl Persuade glibc <math.h> to declare cbrtl().
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 dnl Test whether cbrtl() exists. Assume that cbrtl(), if it exists, is
18 dnl defined in the same library as cbrt().
20 LIBS="$LIBS $CBRT_LIBM"
21 AC_CHECK_FUNCS([cbrtl])
23 if test $ac_cv_func_cbrtl = yes; then
24 CBRTL_LIBM="$CBRT_LIBM"
25 dnl Also check whether it's declared.
26 dnl IRIX 6.5 has cbrtl() in libm but doesn't declare it in <math.h>.
27 AC_CHECK_DECL([cbrtl], , [HAVE_DECL_CBRTL=0], [[#include <math.h>]])
30 LIBS="$LIBS $CBRTL_LIBM"
33 case "$gl_cv_func_cbrtl_works" in
38 m4_ifdef([gl_FUNC_CBRTL_IEEE], [
39 if test $gl_cbrtl_required = ieee && test $REPLACE_CBRTL = 0; then
40 AC_CACHE_CHECK([whether cbrtl works according to ISO C 99 with IEC 60559],
41 [gl_cv_func_cbrtl_ieee],
44 LIBS="$LIBS $CBRTL_LIBM"
47 #ifndef __NO_MATH_INLINES
48 # define __NO_MATH_INLINES 1 /* for glibc */
51 ]gl_LONG_DOUBLE_MINUS_ZERO_CODE[
52 ]gl_LONG_DOUBLE_SIGNBIT_CODE[
53 static long double dummy (long double x) { return 0; }
54 int main (int argc, char *argv[])
60 long double cbrtl (long double);
61 long double (*my_cbrtl) (long double) = argc ? cbrtl : dummy;
64 This test fails on IRIX 6.5. */
65 f = my_cbrtl (minus_zerol);
66 if (!(f == 0.0L) || (signbitl (minus_zerol) && !signbitl (f)))
71 [gl_cv_func_cbrtl_ieee=yes],
72 [gl_cv_func_cbrtl_ieee=no],
73 [gl_cv_func_cbrtl_ieee="guessing no"])
76 case "$gl_cv_func_cbrtl_ieee" in
86 if test $HAVE_CBRTL = 0 || test $REPLACE_CBRTL = 1; then
87 dnl Find libraries needed to link lib/cbrtl.c.
88 if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then
89 CBRTL_LIBM="$CBRT_LIBM"
91 AC_REQUIRE([gl_FUNC_FREXPL])
92 AC_REQUIRE([gl_FUNC_LDEXPL])
94 dnl Append $FREXPL_LIBM to CBRTL_LIBM, avoiding gratuitous duplicates.
95 case " $CBRTL_LIBM " in
96 *" $FREXPL_LIBM "*) ;;
97 *) CBRTL_LIBM="$CBRTL_LIBM $FREXPL_LIBM" ;;
99 dnl Append $LDEXPL_LIBM to CBRTL_LIBM, avoiding gratuitous duplicates.
100 case " $CBRTL_LIBM " in
101 *" $LDEXPL_LIBM "*) ;;
102 *) CBRTL_LIBM="$CBRTL_LIBM $LDEXPL_LIBM" ;;
106 AC_SUBST([CBRTL_LIBM])
109 dnl Test whether cbrtl() works.
110 dnl On OpenBSD 5.1/SPARC, cbrtl(16.0L) is = 1.2599...
111 AC_DEFUN([gl_FUNC_CBRTL_WORKS],
113 AC_REQUIRE([AC_PROG_CC])
114 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
115 AC_CACHE_CHECK([whether cbrtl works], [gl_cv_func_cbrtl_works],
124 long double cbrtl (long double);
125 volatile long double x;
136 [gl_cv_func_cbrtl_works=yes],
137 [gl_cv_func_cbrtl_works=no],
139 openbsd*) gl_cv_func_cbrtl_works="guessing no";;
140 *) gl_cv_func_cbrtl_works="guessing yes";;