From: Bruno Haible Date: Mon, 25 Jan 2010 00:57:08 +0000 (+0100) Subject: Fix tests for common functions. X-Git-Tag: v0.1~4710 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=71c045ff3f67af2324da06ac4b676805590ed316;p=gnulib.git Fix tests for common functions. --- diff --git a/ChangeLog b/ChangeLog index f2a0c7b28..89e1a31e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,48 @@ 2010-01-24 Bruno Haible + Fix tests for common 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 + 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 8d9d826f2..5e79d4581 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 - 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 - 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 947389a92..d87648cc9 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 472fd7b1f..8f03317c3 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 1e42c0758..5bbef73a0 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 811d70e22..fd1abe5ef 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 fc3126797..22820a1f0 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 c88da5736..bcfb2936e 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 6c919ae40..5318e8027 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 77a4aca61..5ed327d42 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 4a9d71e7e..efaee3a03 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 8315997f2..02243bdc7 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 d2b8aed28..5f93d8006 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 51bbce306..6a7a6854e 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 b621c3f8f..8b70430e2 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 0862fe9d1..43997d8b2 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 3a58d2857..2c3f66ff2 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 215180c1f..1dc9d44dd 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 b2480c5f8..d4e0b3cbe 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 6eff0e34b..ef8b41876 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 eaa4a1321..20818eded 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 5a2d53750..40cc49c32 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 5e7d8336a..95279699f 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 d3d8bbf56..bb857a277 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 7c006140c..6b387e206 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 0388803bc..8816840d5 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 a07537485..0c5e4677d 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 8b6d4a72c..ed93418b8 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 8eead4847..dbcc10c71 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 2d35318c0..9d25419f6 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 304bcf57b..276c9263f 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 0d8dc60c2..87ed8e663 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 d1c5c1fc3..ffcef67d7 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 2b2eceece..6ec8a587f 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 3e5e309d2..c7f078943 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 bb1cfb663..de188af1c 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 27dcdaacd..dbe884d48 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 eab9f58cf..63d05f647 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: