summaryrefslogtreecommitdiff
path: root/m4/cbrt.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2012-02-29 23:42:53 +0100
committerBruno Haible <bruno@clisp.org>2012-02-29 23:42:53 +0100
commita0dccde75e6a3b9c930e3577fae7a5bf9351ec09 (patch)
treecf07ebc2e9ae200885f4d1bea63f01d712b37d3b /m4/cbrt.m4
parent14ad442f598655b0dad323d32c22e8b27ad6fb5c (diff)
downloadgnulib-a0dccde75e6a3b9c930e3577fae7a5bf9351ec09.tar.gz
cbrt: Provide replacement on MSVC and Minix.
* lib/math.in.h (cbrt): New declaration. * lib/cbrt.c: New file. * m4/cbrt.m4: New file. * m4/math_h.m4 (gl_MATH_H): Test whether cbrt is declared. (gl_MATH_H_DEFAULTS): Initialize GNULIB_CBRT, HAVE_CBRT. * modules/math (Makefile.am): Substitute GNULIB_CBRT, HAVE_CBRT. * modules/cbrt (Files): Add lib/cbrt.c, m4/cbrt.m4. (Depends-on): Add dependencies. (configure.ac): Arrange to compile replacement if HAVE_CBRT is 0. * tests/test-math-c++.cc: Check the declaration of cbrt. * doc/posix-functions/cbrt.texi: Mention that the module provides a replacement.
Diffstat (limited to 'm4/cbrt.m4')
-rw-r--r--m4/cbrt.m442
1 files changed, 42 insertions, 0 deletions
diff --git a/m4/cbrt.m4 b/m4/cbrt.m4
new file mode 100644
index 0000000000..065f328afd
--- /dev/null
+++ b/m4/cbrt.m4
@@ -0,0 +1,42 @@
+# cbrt.m4 serial 1
+dnl Copyright (C) 2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_CBRT],
+[
+ AC_REQUIRE([gl_MATH_H_DEFAULTS])
+
+ dnl Determine CBRT_LIBM.
+ gl_COMMON_DOUBLE_MATHFUNC([cbrt])
+
+ dnl Test whether cbrt() exists.
+ save_LIBS="$LIBS"
+ LIBS="$LIBS $CBRT_LIBM"
+ AC_CHECK_FUNCS([cbrt])
+ LIBS="$save_LIBS"
+ if test $ac_cv_func_cbrt = no; then
+ HAVE_CBRT=0
+ dnl Find libraries needed to link lib/cbrt.c.
+ AC_REQUIRE([gl_FUNC_FABS])
+ AC_REQUIRE([gl_FUNC_FREXP])
+ AC_REQUIRE([gl_FUNC_LDEXP])
+ CBRT_LIBM=
+ dnl Append $FABS_LIBM to CBRT_LIBM, avoiding gratuitous duplicates.
+ case " $CBRT_LIBM " in
+ *" $FABS_LIBM "*) ;;
+ *) CBRT_LIBM="$CBRT_LIBM $FABS_LIBM" ;;
+ esac
+ dnl Append $FREXP_LIBM to CBRT_LIBM, avoiding gratuitous duplicates.
+ case " $CBRT_LIBM " in
+ *" $FREXP_LIBM "*) ;;
+ *) CBRT_LIBM="$CBRT_LIBM $FREXP_LIBM" ;;
+ esac
+ dnl Append $LDEXP_LIBM to CBRT_LIBM, avoiding gratuitous duplicates.
+ case " $CBRT_LIBM " in
+ *" $LDEXP_LIBM "*) ;;
+ *) CBRT_LIBM="$CBRT_LIBM $LDEXP_LIBM" ;;
+ esac
+ fi
+])