Mercurial > hg > octave-shane > gnulib-hg
changeset 8497:280cabcbb0ca
New module 'frexpl'.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Fri, 23 Mar 2007 01:26:24 +0000 |
parents | 1f851f8ed15e |
children | accc767de343 |
files | ChangeLog lib/math_.h m4/frexpl.m4 m4/math_h.m4 m4/mathl.m4 modules/frexpl modules/math modules/mathl |
diffstat | 8 files changed, 103 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-03-22 Bruno Haible <bruno@clisp.org> + + * modules/frexpl: New file. + * m4/frexpl.m4: New file. + * modules/math (Makefile.am): Also substitute GNULIB_FREXPL into math.h. + * lib/math_.h (frexpl): Test GNULIB_FREXPL instead of GNULIB_MATHL. + * m4/math_h.m4 (gl_MATH_H_DEFAULTS): Initialize GNULIB_FREXPL. + * modules/mathl (Files): Remove lib/frexpl.c, lib/frexp.c. + (Depends-on): Add frexpl. Remove isnanl-nolibm. + * m4/mathl.m4 (gl_FUNC_LONG_DOUBLE_MATH): Don't test for frexpl. + 2007-03-22 Bruno Haible <bruno@clisp.org> * lib/frexpl.c: Share code with lib/frexp.c.
--- a/lib/math_.h +++ b/lib/math_.h @@ -128,14 +128,21 @@ floorl (x)) #endif -#if @GNULIB_MATHL@ || !@HAVE_DECL_FREXPL@ +/* Write x as + x = mantissa * 2^exp + where + If x finite and nonzero: 0.5 <= |mantissa| < 1.0. + If x is zero: mantissa = x, exp = 0. + If x is infinite or NaN: mantissa = x, exp unspecified. + Store exp and return mantissa. */ +#if @GNULIB_FREXPL@ || !@HAVE_DECL_FREXPL@ extern long double frexpl (long double x, int *exp); #endif -#if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK +#if !@GNULIB_FREXPL@ || defined GNULIB_POSIXCHECK # undef frexpl # define frexpl(x,e) \ (GL_LINK_WARNING ("frexpl is unportable - " \ - "use gnulib module mathl for portability"), \ + "use gnulib module frexpl for portability"), \ frexpl (x, e)) #endif
new file mode 100644 --- /dev/null +++ b/m4/frexpl.m4 @@ -0,0 +1,47 @@ +# frexpl.m4 serial 1 +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_FREXPL], +[ + AC_REQUIRE([gl_MATH_H_DEFAULTS]) + FREXPL_LIBM= + AC_CACHE_CHECK([whether frexpl() can be used without linking with libm], + [gl_cv_func_frexpl_no_libm], + [ + AC_TRY_LINK([#include <math.h> + long double x;], + [int e; return frexpl (x, &e) > 0;], + [gl_cv_func_frexpl_no_libm=yes], + [gl_cv_func_frexpl_no_libm=no]) + ]) + if test $gl_cv_func_frexpl_no_libm = no; then + AC_CACHE_CHECK([whether frexpl() can be used with libm], + [gl_cv_func_frexpl_in_libm], + [ + save_LIBS="$LIBS" + LIBS="$LIBS -lm" + AC_TRY_LINK([#include <math.h> + long double x;], + [int e; return frexpl (x, &e) > 0;], + [gl_cv_func_frexpl_in_libm=yes], + [gl_cv_func_frexpl_in_libm=no]) + LIBS="$save_LIBS" + ]) + if test $gl_cv_func_frexpl_in_libm = yes; then + FREXPL_LIBM=-lm + fi + fi + if test $gl_cv_func_frexpl_no_libm = yes \ + || test $gl_cv_func_frexpl_in_libm = yes; then + AC_DEFINE([HAVE_FREXPL], 1, + [Define if the frexpl() function is available.]) + dnl Also check whether it's declared. + dnl MacOS X 10.3 has frexpl() in libc but doesn't declare it in <math.h>. + AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include <math.h>]) + else + AC_LIBOBJ([frexpl]) + fi +])
--- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -21,8 +21,9 @@ AC_DEFUN([gl_MATH_H_DEFAULTS], [ - GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) - GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL]) + GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) + GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) + 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]) HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
--- a/m4/mathl.m4 +++ b/m4/mathl.m4 @@ -1,5 +1,5 @@ -# mathl.m4 serial 2 -dnl Copyright (c) 2003 Free Software Foundation, Inc. +# mathl.m4 serial 3 +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, dnl with or without modifications, as long as this notice is preserved. @@ -7,7 +7,7 @@ AC_DEFUN([gl_FUNC_LONG_DOUBLE_MATH], [ AC_CHECK_LIB(m, atan) -AC_REPLACE_FUNCS(floorl ceill sqrtl frexpl ldexpl asinl acosl atanl \ +AC_REPLACE_FUNCS(floorl ceill sqrtl ldexpl asinl acosl atanl \ logl expl tanl sinl cosl) ])
new file mode 100644 --- /dev/null +++ b/modules/frexpl @@ -0,0 +1,27 @@ +Description: +frexpl() function: split a 'long double' into its constituents. + +Files: +lib/frexpl.c +lib/frexp.c +m4/frexpl.m4 + +Depends-on: +math +isnanl-nolibm + +configure.ac: +gl_FUNC_FREXPL +gl_MATH_MODULE_INDICATOR([frexpl]) + +Makefile.am: + +Include: +<math.h> + +License: +LGPL + +Maintainer: +Bruno Haible, Paolo Bonzini +
--- a/modules/math +++ b/modules/math @@ -22,6 +22,7 @@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 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_MATHL''@|$(GNULIB_MATHL)|g' \ -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \