summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog43
-rw-r--r--m4/mathfunc.m423
-rw-r--r--m4/sqrt.m44
-rw-r--r--modules/acos2
-rw-r--r--modules/asin2
-rw-r--r--modules/atan2
-rw-r--r--modules/atan22
-rw-r--r--modules/cbrt2
-rw-r--r--modules/copysign2
-rw-r--r--modules/cos2
-rw-r--r--modules/cosh2
-rw-r--r--modules/erf2
-rw-r--r--modules/erfc2
-rw-r--r--modules/exp2
-rw-r--r--modules/fabs2
-rw-r--r--modules/fmod2
-rw-r--r--modules/hypot2
-rw-r--r--modules/j02
-rw-r--r--modules/j12
-rw-r--r--modules/jn2
-rw-r--r--modules/ldexp2
-rw-r--r--modules/lgamma2
-rw-r--r--modules/log2
-rw-r--r--modules/log102
-rw-r--r--modules/log1p2
-rw-r--r--modules/logb2
-rw-r--r--modules/modf2
-rw-r--r--modules/nextafter2
-rw-r--r--modules/pow2
-rw-r--r--modules/remainder2
-rw-r--r--modules/rint2
-rw-r--r--modules/sin2
-rw-r--r--modules/sinh2
-rw-r--r--modules/tan2
-rw-r--r--modules/tanh2
-rw-r--r--modules/y02
-rw-r--r--modules/y12
-rw-r--r--modules/yn2
38 files changed, 95 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index f2a0c7b288..89e1a31e90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,48 @@
2010-01-24 Bruno Haible <bruno@clisp.org>
+ Fix tests for common <math.h> functions.
+ * m4/mathfunc.m4 (gl_MATHFUNC): Take two additional parameters. Use a
+ code snippet that references the function pointer, rather than merely
+ calling the function. Substitute the FUNC_LIBM variable.
+ * m4/sqrt.m4 (gl_FUNC_SQRT): Update gl_MATHFUNC invocation.
+ * modules/acos (configure.ac): Likewise.
+ * modules/asin (configure.ac): Likewise.
+ * modules/atan (configure.ac): Likewise.
+ * modules/atan2 (configure.ac): Likewise.
+ * modules/cbrt (configure.ac): Likewise.
+ * modules/copysign (configure.ac): Likewise.
+ * modules/cos (configure.ac): Likewise.
+ * modules/cosh (configure.ac): Likewise.
+ * modules/erf (configure.ac): Likewise.
+ * modules/erfc (configure.ac): Likewise.
+ * modules/exp (configure.ac): Likewise.
+ * modules/fabs (configure.ac): Likewise.
+ * modules/fmod (configure.ac): Likewise.
+ * modules/hypot (configure.ac): Likewise.
+ * modules/j0 (configure.ac): Likewise.
+ * modules/j1 (configure.ac): Likewise.
+ * modules/jn (configure.ac): Likewise.
+ * modules/ldexp (configure.ac): Likewise.
+ * modules/lgamma (configure.ac): Likewise.
+ * modules/log (configure.ac): Likewise.
+ * modules/log10 (configure.ac): Likewise.
+ * modules/log1p (configure.ac): Likewise.
+ * modules/logb (configure.ac): Likewise.
+ * modules/modf (configure.ac): Likewise.
+ * modules/nextafter (configure.ac): Likewise.
+ * modules/pow (configure.ac): Likewise.
+ * modules/remainder (configure.ac): Likewise.
+ * modules/rint (configure.ac): Likewise.
+ * modules/sin (configure.ac): Likewise.
+ * modules/sinh (configure.ac): Likewise.
+ * modules/tan (configure.ac): Likewise.
+ * modules/tanh (configure.ac): Likewise.
+ * modules/y0 (configure.ac): Likewise.
+ * modules/y1 (configure.ac): Likewise.
+ * modules/yn (configure.ac): Likewise.
+
+2010-01-24 Bruno Haible <bruno@clisp.org>
+
Tests: Defeat inlining of math functions by GCC >= 4.3.0.
* tests/test-acosl.c (x): New variable.
(main): Store argument in x and fetch it from x.
diff --git a/m4/mathfunc.m4 b/m4/mathfunc.m4
index 8d9d826f20..5e79d4581a 100644
--- a/m4/mathfunc.m4
+++ b/m4/mathfunc.m4
@@ -1,15 +1,21 @@
-# mathfunc.m4 serial 1
+# mathfunc.m4 serial 2
dnl Copyright (C) 2010 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.
-# gl_MATHFUNC([sqrt])
-# tests whether the sqrt function is available in libc or libm. It sets
-# SQRT_LIBM to empty or "-lm" accordingly.
+# gl_MATHFUNC(FUNC, RETTYPE, PARAMTYPES)
+# --------------------------------------------------
+# tests whether the function FUNC is available in libc or libm.
+# RETTYPE is the return type. PARAMTYPES is a parameter list, with parentheses.
+# It sets FUNC_LIBM to empty or "-lm" accordingly.
AC_DEFUN([gl_MATHFUNC],
[
+ dnl We need the RETTYPE and PARAMTYPES in order to force linking with the
+ dnl function. With gcc >= 4.3 on glibc/x86_64, calls to the 'fabs' function
+ dnl are inlined by the compiler, therefore linking of these calls does not
+ dnl require -lm, but taking the function pointer of 'fabs' does.
m4_pushdef([func], [$1])
m4_pushdef([FUNC], [translit([$1],[abcdefghijklmnopqrstuvwxyz],
[ABCDEFGHIJKLMNOPQRSTUVWXYZ])])
@@ -22,8 +28,8 @@ AC_DEFUN([gl_MATHFUNC],
# define __NO_MATH_INLINES 1 /* for glibc */
#endif
#include <math.h>
- double x;]],
- [[return ]func[ (x) > 2 || ]func[ (x) < 0.4;]])],
+ $2 (*funcptr) $3 = ]func[;]],
+ [[return 0;]])],
[gl_cv_func_]func[_no_libm=yes],
[gl_cv_func_]func[_no_libm=no])
])
@@ -38,8 +44,8 @@ AC_DEFUN([gl_MATHFUNC],
# define __NO_MATH_INLINES 1 /* for glibc */
#endif
#include <math.h>
- double x;]],
- [[return ]func[ (x) > 2 || ]func[ (x) < 0.4;]])],
+ $2 (*funcptr) $3 = ]func[;]],
+ [[return 0;]])],
[gl_cv_func_]func[_in_libm=yes],
[gl_cv_func_]func[_in_libm=no])
LIBS="$save_LIBS"
@@ -48,6 +54,7 @@ AC_DEFUN([gl_MATHFUNC],
FUNC[]_LIBM=-lm
fi
fi
+ AC_SUBST(FUNC[_LIBM])
m4_popdef([FUNC])
m4_popdef([func])
])
diff --git a/m4/sqrt.m4 b/m4/sqrt.m4
index 947389a927..d87648cc9f 100644
--- a/m4/sqrt.m4
+++ b/m4/sqrt.m4
@@ -1,4 +1,4 @@
-# sqrt.m4 serial 1
+# sqrt.m4 serial 2
dnl Copyright (C) 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -6,5 +6,5 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_SQRT],
[
- gl_MATHFUNC([sqrt])
+ gl_MATHFUNC([sqrt], [double], [(double)])
])
diff --git a/modules/acos b/modules/acos
index 472fd7b1f5..8f03317c38 100644
--- a/modules/acos
+++ b/modules/acos
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([acos])
+gl_MATHFUNC([acos], [double], [(double)])
Makefile.am:
diff --git a/modules/asin b/modules/asin
index 1e42c0758b..5bbef73a0c 100644
--- a/modules/asin
+++ b/modules/asin
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([asin])
+gl_MATHFUNC([asin], [double], [(double)])
Makefile.am:
diff --git a/modules/atan b/modules/atan
index 811d70e22f..fd1abe5efc 100644
--- a/modules/atan
+++ b/modules/atan
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([atan])
+gl_MATHFUNC([atan], [double], [(double)])
Makefile.am:
diff --git a/modules/atan2 b/modules/atan2
index fc31267973..22820a1f04 100644
--- a/modules/atan2
+++ b/modules/atan2
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([atan2])
+gl_MATHFUNC([atan2], [double], [(double, double)])
Makefile.am:
diff --git a/modules/cbrt b/modules/cbrt
index c88da5736f..bcfb2936e0 100644
--- a/modules/cbrt
+++ b/modules/cbrt
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([cbrt])
+gl_MATHFUNC([cbrt], [double], [(double)])
Makefile.am:
diff --git a/modules/copysign b/modules/copysign
index 6c919ae40c..5318e80271 100644
--- a/modules/copysign
+++ b/modules/copysign
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([copysign])
+gl_MATHFUNC([copysign], [double], [(double, double)])
Makefile.am:
diff --git a/modules/cos b/modules/cos
index 77a4aca618..5ed327d42e 100644
--- a/modules/cos
+++ b/modules/cos
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([cos])
+gl_MATHFUNC([cos], [double], [(double)])
Makefile.am:
diff --git a/modules/cosh b/modules/cosh
index 4a9d71e7e8..efaee3a03b 100644
--- a/modules/cosh
+++ b/modules/cosh
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([cosh])
+gl_MATHFUNC([cosh], [double], [(double)])
Makefile.am:
diff --git a/modules/erf b/modules/erf
index 8315997f23..02243bdc72 100644
--- a/modules/erf
+++ b/modules/erf
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([erf])
+gl_MATHFUNC([erf], [double], [(double)])
Makefile.am:
diff --git a/modules/erfc b/modules/erfc
index d2b8aed28a..5f93d8006d 100644
--- a/modules/erfc
+++ b/modules/erfc
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([erfc])
+gl_MATHFUNC([erfc], [double], [(double)])
Makefile.am:
diff --git a/modules/exp b/modules/exp
index 51bbce306a..6a7a6854e9 100644
--- a/modules/exp
+++ b/modules/exp
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([exp])
+gl_MATHFUNC([exp], [double], [(double)])
Makefile.am:
diff --git a/modules/fabs b/modules/fabs
index b621c3f8f0..8b70430e22 100644
--- a/modules/fabs
+++ b/modules/fabs
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([fabs])
+gl_MATHFUNC([fabs], [double], [(double)])
Makefile.am:
diff --git a/modules/fmod b/modules/fmod
index 0862fe9d12..43997d8b25 100644
--- a/modules/fmod
+++ b/modules/fmod
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([fmod])
+gl_MATHFUNC([fmod], [double], [(double, double)])
Makefile.am:
diff --git a/modules/hypot b/modules/hypot
index 3a58d28578..2c3f66ff2b 100644
--- a/modules/hypot
+++ b/modules/hypot
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([hypot])
+gl_MATHFUNC([hypot], [double], [(double, double)])
Makefile.am:
diff --git a/modules/j0 b/modules/j0
index 215180c1ff..1dc9d44dd7 100644
--- a/modules/j0
+++ b/modules/j0
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([j0])
+gl_MATHFUNC([j0], [double], [(double)])
Makefile.am:
diff --git a/modules/j1 b/modules/j1
index b2480c5f82..d4e0b3cbe0 100644
--- a/modules/j1
+++ b/modules/j1
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([j1])
+gl_MATHFUNC([j1], [double], [(double)])
Makefile.am:
diff --git a/modules/jn b/modules/jn
index 6eff0e34b1..ef8b418762 100644
--- a/modules/jn
+++ b/modules/jn
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([jn])
+gl_MATHFUNC([jn], [double], [(int, double)])
Makefile.am:
diff --git a/modules/ldexp b/modules/ldexp
index eaa4a1321d..20818ededd 100644
--- a/modules/ldexp
+++ b/modules/ldexp
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([ldexp])
+gl_MATHFUNC([ldexp], [double], [(double, int)])
Makefile.am:
diff --git a/modules/lgamma b/modules/lgamma
index 5a2d537500..40cc49c323 100644
--- a/modules/lgamma
+++ b/modules/lgamma
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([lgamma])
+gl_MATHFUNC([lgamma], [double], [(double)])
Makefile.am:
diff --git a/modules/log b/modules/log
index 5e7d8336a5..95279699fa 100644
--- a/modules/log
+++ b/modules/log
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([log])
+gl_MATHFUNC([log], [double], [(double)])
Makefile.am:
diff --git a/modules/log10 b/modules/log10
index d3d8bbf56a..bb857a277f 100644
--- a/modules/log10
+++ b/modules/log10
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([log10])
+gl_MATHFUNC([log10], [double], [(double)])
Makefile.am:
diff --git a/modules/log1p b/modules/log1p
index 7c006140cf..6b387e2060 100644
--- a/modules/log1p
+++ b/modules/log1p
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([log1p])
+gl_MATHFUNC([log1p], [double], [(double)])
Makefile.am:
diff --git a/modules/logb b/modules/logb
index 0388803bcb..8816840d54 100644
--- a/modules/logb
+++ b/modules/logb
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([logb])
+gl_MATHFUNC([logb], [double], [(double)])
Makefile.am:
diff --git a/modules/modf b/modules/modf
index a075374857..0c5e4677d7 100644
--- a/modules/modf
+++ b/modules/modf
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([modf])
+gl_MATHFUNC([modf], [double], [(double, double *)])
Makefile.am:
diff --git a/modules/nextafter b/modules/nextafter
index 8b6d4a72ca..ed93418b8b 100644
--- a/modules/nextafter
+++ b/modules/nextafter
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([nextafter])
+gl_MATHFUNC([nextafter], [double], [(double)])
Makefile.am:
diff --git a/modules/pow b/modules/pow
index 8eead4847f..dbcc10c71e 100644
--- a/modules/pow
+++ b/modules/pow
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([pow])
+gl_MATHFUNC([pow], [double], [(double, double)])
Makefile.am:
diff --git a/modules/remainder b/modules/remainder
index 2d35318c09..9d25419f62 100644
--- a/modules/remainder
+++ b/modules/remainder
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([remainder])
+gl_MATHFUNC([remainder], [double], [(double, double)])
Makefile.am:
diff --git a/modules/rint b/modules/rint
index 304bcf57b4..276c9263f9 100644
--- a/modules/rint
+++ b/modules/rint
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([rint])
+gl_MATHFUNC([rint], [double], [(double)])
Makefile.am:
diff --git a/modules/sin b/modules/sin
index 0d8dc60c25..87ed8e6632 100644
--- a/modules/sin
+++ b/modules/sin
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([sin])
+gl_MATHFUNC([sin], [double], [(double)])
Makefile.am:
diff --git a/modules/sinh b/modules/sinh
index d1c5c1fc3c..ffcef67d72 100644
--- a/modules/sinh
+++ b/modules/sinh
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([sinh])
+gl_MATHFUNC([sinh], [double], [(double)])
Makefile.am:
diff --git a/modules/tan b/modules/tan
index 2b2eceece7..6ec8a587f9 100644
--- a/modules/tan
+++ b/modules/tan
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([tan])
+gl_MATHFUNC([tan], [double], [(double)])
Makefile.am:
diff --git a/modules/tanh b/modules/tanh
index 3e5e309d22..c7f078943f 100644
--- a/modules/tanh
+++ b/modules/tanh
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([tanh])
+gl_MATHFUNC([tanh], [double], [(double)])
Makefile.am:
diff --git a/modules/y0 b/modules/y0
index bb1cfb663b..de188af1c3 100644
--- a/modules/y0
+++ b/modules/y0
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([y0])
+gl_MATHFUNC([y0], [double], [(double)])
Makefile.am:
diff --git a/modules/y1 b/modules/y1
index 27dcdaacd2..dbe884d48e 100644
--- a/modules/y1
+++ b/modules/y1
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([y1])
+gl_MATHFUNC([y1], [double], [(double)])
Makefile.am:
diff --git a/modules/yn b/modules/yn
index eab9f58cfa..63d05f6472 100644
--- a/modules/yn
+++ b/modules/yn
@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
-gl_MATHFUNC([yn])
+gl_MATHFUNC([yn], [double], [(int, double)])
Makefile.am: