From d6687687c7f3b86ba712ab98533a8094e9de58f5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 30 Mar 2007 00:13:24 +0000 Subject: [PATCH] New module 'ldexpl'. --- ChangeLog | 16 +++++++++++ lib/math_.h | 10 +++++-- m4/ldexpl.m4 | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++ m4/math_h.m4 | 4 ++- m4/mathl.m4 | 4 +-- m4/printf-frexpl.m4 | 15 ++++++---- modules/ldexpl | 26 +++++++++++++++++ modules/math | 2 ++ modules/mathl | 2 +- 9 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 m4/ldexpl.m4 create mode 100644 modules/ldexpl diff --git a/ChangeLog b/ChangeLog index a5c2534d0..7c42d3bbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2007-03-29 Bruno Haible + * modules/ldexpl: New file. + * m4/ldexpl.m4: New file. + * lib/math_.h (ldexpl): Define to a replacement if REPLACE_LDEXPL is + set. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize also GNULIB_LDEXPL, + REPLACE_LDEXPL. + * modules/math (Makefile.am): Substitute also GNULIB_LDEXPL, + REPLACE_LDEXPL. + * m4/printf-frexpl.m4 (gl_FUNC_PRINTF_FREXPL): Invoke + gl_FUNC_LDEXPL_WORKS. + * m4/mathl.m4 (gl_FUNC_LONG_DOUBLE_MATH): Remove test for ldexpl. + * modules/mathl (Files): Remove lib/ldexpl.c. + (Depends-on): Add ldexpl. + +2007-03-29 Bruno Haible + * m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS): Declare frexpl. 2007-03-29 Bruno Haible diff --git a/lib/math_.h b/lib/math_.h index 0fa81d71f..e8dfb2a7d 100644 --- a/lib/math_.h +++ b/lib/math_.h @@ -149,14 +149,18 @@ extern long double frexpl (long double x, int *exp); frexpl (x, e)) #endif -#if @GNULIB_MATHL@ || !@HAVE_DECL_LDEXPL@ +/* Return x * 2^exp. */ +#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ +# define ldexpl rpl_ldexpl +#endif +#if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@ extern long double ldexpl (long double x, int exp); #endif -#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +#if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK # undef ldexpl # define ldexpl(x,e) \ (GL_LINK_WARNING ("ldexpl is unportable - " \ - "use gnulib module mathl for portability"), \ + "use gnulib module ldexpl for portability"), \ ldexpl (x, e)) #endif diff --git a/m4/ldexpl.m4 b/m4/ldexpl.m4 new file mode 100644 index 000000000..b7ef5807c --- /dev/null +++ b/m4/ldexpl.m4 @@ -0,0 +1,83 @@ +# ldexpl.m4 serial 2 +dnl Copyright (C) 2007 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_LDEXPL], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + LDEXPL_LIBM= + AC_CACHE_CHECK([whether ldexpl() can be used without linking with libm], + [gl_cv_func_ldexpl_no_libm], + [ + AC_TRY_LINK([#include + long double x;], + [return ldexpl (x, -1) > 0;], + [gl_cv_func_ldexpl_no_libm=yes], + [gl_cv_func_ldexpl_no_libm=no]) + ]) + if test $gl_cv_func_ldexpl_no_libm = no; then + AC_CACHE_CHECK([whether ldexpl() can be used with libm], + [gl_cv_func_ldexpl_in_libm], + [ + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_TRY_LINK([#include + long double x;], + [return ldexpl (x, -1) > 0;], + [gl_cv_func_ldexpl_in_libm=yes], + [gl_cv_func_ldexpl_in_libm=no]) + LIBS="$save_LIBS" + ]) + if test $gl_cv_func_ldexpl_in_libm = yes; then + LDEXPL_LIBM=-lm + fi + fi + if test $gl_cv_func_ldexpl_no_libm = yes \ + || test $gl_cv_func_ldexpl_in_libm = yes; then + save_LIBS="$LIBS" + LIBS="$LIBS $LDEXPL_LIBM" + gl_FUNC_LDEXPL_WORKS + LIBS="$save_LIBS" + case "$gl_cv_func_ldexpl_works" in + *yes) gl_func_ldexpl=yes ;; + *) gl_func_ldexpl=no; REPLACE_LDEXPL=1; LDEXPL_LIBM= ;; + esac + else + gl_func_ldexpl=no + fi + if test $gl_func_ldexpl = yes; then + AC_DEFINE([HAVE_LDEXPL], 1, + [Define if the ldexpl() function is available.]) + dnl Also check whether it's declared. + dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in . + AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include ]) + else + AC_LIBOBJ([ldexpl]) + fi +]) + +dnl Test whether ldexpl() works on finite numbers (this fails on AIX 5.1). +AC_DEFUN([gl_FUNC_LDEXPL_WORKS], +[ + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + AC_CACHE_CHECK([whether ldexpl works], [gl_cv_func_ldexpl_works], + [ + AC_TRY_RUN([ +#include +extern long double ldexpl (long double, int); +int main() +{ + volatile long double x = 1.0; + volatile long double y = ldexpl (x, -1); + return (y != 0.5L); +}], [gl_cv_func_ldexpl_works=yes], [gl_cv_func_ldexpl_works=no], + [case "$host_os" in + aix*) gl_cv_func_ldexpl_works="guessing no";; + *) gl_cv_func_ldexpl_works="guessing yes";; + esac + ]) + ]) +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index cc906f643..1202dc878 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -1,4 +1,4 @@ -# math_h.m4 serial 3 +# math_h.m4 serial 4 dnl Copyright (C) 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -23,6 +23,7 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], [ GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) + GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) @@ -40,4 +41,5 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) + REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) ]) diff --git a/m4/mathl.m4 b/m4/mathl.m4 index 57d70a5a7..5d8246620 100644 --- a/m4/mathl.m4 +++ b/m4/mathl.m4 @@ -1,4 +1,4 @@ -# mathl.m4 serial 3 +# mathl.m4 serial 4 dnl Copyright (c) 2003, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_LONG_DOUBLE_MATH], [ AC_CHECK_LIB(m, atan) -AC_REPLACE_FUNCS(floorl ceill sqrtl ldexpl asinl acosl atanl \ +AC_REPLACE_FUNCS(floorl ceill sqrtl asinl acosl atanl \ logl expl tanl sinl cosl) ]) diff --git a/m4/printf-frexpl.m4 b/m4/printf-frexpl.m4 index d522d0e3b..14acc3546 100644 --- a/m4/printf-frexpl.m4 +++ b/m4/printf-frexpl.m4 @@ -40,11 +40,16 @@ AC_DEFUN([gl_FUNC_PRINTF_FREXPL], [gl_cv_func_ldexpl_no_libm=no]) ]) if test $gl_cv_func_ldexpl_no_libm = yes; then - AC_DEFINE([HAVE_LDEXPL_IN_LIBC], 1, - [Define if the ldexpl function is available in libc.]) - dnl Also check whether it's declared. - dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in . - AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include ]) + gl_FUNC_LDEXPL_WORKS + case "$gl_cv_func_ldexpl_works" in + *yes) + AC_DEFINE([HAVE_LDEXPL_IN_LIBC], 1, + [Define if the ldexpl function is available in libc.]) + dnl Also check whether it's declared. + dnl MacOS X 10.3 has ldexpl() in libc but doesn't declare it in . + AC_CHECK_DECL([ldexpl], , [HAVE_DECL_LDEXPL=0], [#include ]) + ;; + esac fi fi ]) diff --git a/modules/ldexpl b/modules/ldexpl new file mode 100644 index 000000000..c89187a50 --- /dev/null +++ b/modules/ldexpl @@ -0,0 +1,26 @@ +Description: +ldexpl() function: multiply a 'long double' by a power of 2. + +Files: +lib/ldexpl.c +m4/ldexpl.m4 + +Depends-on: +math +isnanl-nolibm + +configure.ac: +gl_FUNC_LDEXPL +gl_MATH_MODULE_INDICATOR([ldexpl]) + +Makefile.am: + +Include: + + +License: +LGPL + +Maintainer: +Bruno Haible, Paolo Bonzini + diff --git a/modules/math b/modules/math index 5c28af7d1..eb72003be 100644 --- a/modules/math +++ b/modules/math @@ -23,6 +23,7 @@ math.h: math_.h sed -e 's|@''ABSOLUTE_MATH_H''@|$(ABSOLUTE_MATH_H)|g' \ -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \ -e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \ + -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \ -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ @@ -39,6 +40,7 @@ math.h: math_.h -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ + -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/math_.h; \ } > $@-t diff --git a/modules/mathl b/modules/mathl index 709f21efc..d9c1b13b3 100644 --- a/modules/mathl +++ b/modules/mathl @@ -9,7 +9,6 @@ lib/ceill.c lib/cosl.c lib/expl.c lib/floorl.c -lib/ldexpl.c lib/logl.c lib/sincosl.c lib/sinl.c @@ -23,6 +22,7 @@ Depends-on: math frexpl isnanl +ldexpl configure.ac: gl_FUNC_LONG_DOUBLE_MATH -- 2.11.0