From 579cd92ebf7e6c45259e041957042a7d9cf3ac26 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 7 Oct 2011 00:11:51 +0200 Subject: [PATCH] frexpf: Drop assumption about library that defines frexpf. * m4/mathfunc.m4 (gl_MATHFUNC): Support also the argument types 'int *', 'float *', 'long double *', 'float', 'long double'. * m4/frexpf.m4 (gl_FUNC_FREXPF): Use gl_MATHFUNC macro instead of AC_CHECK_FUNCS. * modules/frexpf (Files): Add m4/mathfunc.m4. --- ChangeLog | 7 +++++++ m4/frexpf.m4 | 17 +++++++---------- m4/mathfunc.m4 | 16 +++++++++++----- modules/frexpf | 1 + 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdf07f08a..9f2312cf0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-10-06 Bruno Haible + frexpf: Drop assumption about library that defines frexpf. + * m4/mathfunc.m4 (gl_MATHFUNC): Support also the argument types + 'int *', 'float *', 'long double *', 'float', 'long double'. + * m4/frexpf.m4 (gl_FUNC_FREXPF): Use gl_MATHFUNC macro instead of + AC_CHECK_FUNCS. + * modules/frexpf (Files): Add m4/mathfunc.m4. + Tests for module 'frexpf'. * modules/frexpf-tests: New file. * tests/test-frexpf.c: New file. diff --git a/m4/frexpf.m4 b/m4/frexpf.m4 index 7928011c3..3aa648b69 100644 --- a/m4/frexpf.m4 +++ b/m4/frexpf.m4 @@ -1,4 +1,4 @@ -# frexpf.m4 serial 1 +# frexpf.m4 serial 2 dnl Copyright (C) 2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,15 +9,12 @@ AC_DEFUN([gl_FUNC_FREXPF], AC_REQUIRE([gl_MATH_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_FREXP]) - dnl Test whether frexpf() exists. Assume that frexpf(), if it exists, is - dnl defined in the same library as frexp(). - save_LIBS="$LIBS" - LIBS="$LIBS $FREXP_LIBM" - AC_CHECK_FUNCS([frexpf]) - LIBS="$save_LIBS" - if test $ac_cv_func_frexpf = yes; then - FREXPF_LIBM="$FREXP_LIBM" - else + dnl Test whether frexpf() exists. We cannot assume that frexpf(), if it + dnl exists, is defined in the same library as frexp(). This is not the case + dnl on NetBSD, OpenBSD. + gl_MATHFUNC([frexpf], [float], [(float, int *)]) + if test $gl_cv_func_frexpf_no_libm = no \ + && test $gl_cv_func_frexpf_in_libm = no; then HAVE_FREXPF=0 FREXPF_LIBM="$FREXP_LIBM" fi diff --git a/m4/mathfunc.m4 b/m4/mathfunc.m4 index 40a27b4b2..da6dc5ffe 100644 --- a/m4/mathfunc.m4 +++ b/m4/mathfunc.m4 @@ -1,4 +1,4 @@ -# mathfunc.m4 serial 6 +# mathfunc.m4 serial 7 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -30,8 +30,11 @@ AC_DEFUN([gl_MATHFUNC], #endif #include $2 (*funcptr) $3 = ]func[; - double d_ret;]], - [[$2 y = funcptr ]m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([$3], [int], [2])], [double \*], [&d_ret])], [double], [1.6180339887])[; + int i_ret; + float f_ret; + double d_ret; + long double l_ret;]], + [[$2 y = funcptr ]m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([$3], [int \*], [&i_ret])], [float \*], [&f_ret])], [double \*], [&d_ret])], [long double \*], [&l_ret])], [int], [2])], [float], [1.618034f])], [long double], [1.618033988749894848L])], [double], [1.6180339887])[; return y < 0.3 || y > 1.7; ]])], [gl_cv_func_]func[_no_libm=yes], @@ -50,8 +53,11 @@ AC_DEFUN([gl_MATHFUNC], #endif #include $2 (*funcptr) $3 = ]func[; - double d_ret;]], - [[$2 y = funcptr ]m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([$3], [int], [2])], [double \*], [&d_ret])], [double], [1.6180339887])[; + int i_ret; + float f_ret; + double d_ret; + long double l_ret;]], + [[$2 y = funcptr ]m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([m4_bpatsubst([$3], [int \*], [&i_ret])], [float \*], [&f_ret])], [double \*], [&d_ret])], [long double \*], [&l_ret])], [int], [2])], [float], [1.618034f])], [long double], [1.618033988749894848L])], [double], [1.6180339887])[; return y < 0.3 || y > 1.7; ]])], [gl_cv_func_]func[_in_libm=yes], diff --git a/modules/frexpf b/modules/frexpf index bd0d27383..057b304c1 100644 --- a/modules/frexpf +++ b/modules/frexpf @@ -4,6 +4,7 @@ frexpf() function: split a float into its constituents. Files: lib/frexpf.c m4/frexpf.m4 +m4/mathfunc.m4 Depends-on: math -- 2.11.0