Commit 71c045ff authored by Bruno Haible's avatar Bruno Haible

Fix tests for common <math.h> functions.

parent 494a4d32
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.
# 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])
])
# 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)])
])
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([acos])
gl_MATHFUNC([acos], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([asin])
gl_MATHFUNC([asin], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([atan])
gl_MATHFUNC([atan], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([atan2])
gl_MATHFUNC([atan2], [double], [(double, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([cbrt])
gl_MATHFUNC([cbrt], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([copysign])
gl_MATHFUNC([copysign], [double], [(double, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([cos])
gl_MATHFUNC([cos], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([cosh])
gl_MATHFUNC([cosh], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([erf])
gl_MATHFUNC([erf], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([erfc])
gl_MATHFUNC([erfc], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([exp])
gl_MATHFUNC([exp], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([fabs])
gl_MATHFUNC([fabs], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([fmod])
gl_MATHFUNC([fmod], [double], [(double, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([hypot])
gl_MATHFUNC([hypot], [double], [(double, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([j0])
gl_MATHFUNC([j0], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([j1])
gl_MATHFUNC([j1], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([jn])
gl_MATHFUNC([jn], [double], [(int, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([ldexp])
gl_MATHFUNC([ldexp], [double], [(double, int)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([lgamma])
gl_MATHFUNC([lgamma], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([log])
gl_MATHFUNC([log], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([log10])
gl_MATHFUNC([log10], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([log1p])
gl_MATHFUNC([log1p], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([logb])
gl_MATHFUNC([logb], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([modf])
gl_MATHFUNC([modf], [double], [(double, double *)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([nextafter])
gl_MATHFUNC([nextafter], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([pow])
gl_MATHFUNC([pow], [double], [(double, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([remainder])
gl_MATHFUNC([remainder], [double], [(double, double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([rint])
gl_MATHFUNC([rint], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([sin])
gl_MATHFUNC([sin], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([sinh])
gl_MATHFUNC([sinh], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([tan])
gl_MATHFUNC([tan], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([tanh])
gl_MATHFUNC([tanh], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([y0])
gl_MATHFUNC([y0], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([y1])
gl_MATHFUNC([y1], [double], [(double)])
Makefile.am:
......
......@@ -7,7 +7,7 @@ m4/mathfunc.m4
Depends-on:
configure.ac:
gl_MATHFUNC([yn])
gl_MATHFUNC([yn], [double], [(int, double)])
Makefile.am:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment