From: Bruno Haible Date: Fri, 23 Mar 2007 01:26:24 +0000 (+0000) Subject: New module 'frexpl'. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8abd907483addabfc096285697371aed37e4d8e2;p=pspp New module 'frexpl'. --- diff --git a/ChangeLog b/ChangeLog index 0cd2fab775..31bf564da9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-03-22 Bruno Haible + + * 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 * lib/frexpl.c: Share code with lib/frexp.c. diff --git a/lib/math_.h b/lib/math_.h index 18f3807b12..48e622ec8f 100644 --- a/lib/math_.h +++ b/lib/math_.h @@ -128,14 +128,21 @@ extern long double floorl (long double x); 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 diff --git a/m4/frexpl.m4 b/m4/frexpl.m4 new file mode 100644 index 0000000000..361fd2d867 --- /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 + 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 + 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 . + AC_CHECK_DECL([frexpl], , [HAVE_DECL_FREXPL=0], [#include ]) + else + AC_LIBOBJ([frexpl]) + fi +]) diff --git a/m4/math_h.m4 b/m4/math_h.m4 index 5b393f4b84..fb3ea09f2b 100644 --- a/m4/math_h.m4 +++ b/m4/math_h.m4 @@ -21,8 +21,9 @@ AC_DEFUN([gl_MATH_MODULE_INDICATOR], 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]) diff --git a/m4/mathl.m4 b/m4/mathl.m4 index c875203d41..57d70a5a7a 100644 --- 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 @@ 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 frexpl ldexpl asinl acosl atanl \ +AC_REPLACE_FUNCS(floorl ceill sqrtl ldexpl asinl acosl atanl \ logl expl tanl sinl cosl) ]) diff --git a/modules/frexpl b/modules/frexpl new file mode 100644 index 0000000000..0bb8f586d8 --- /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: + + +License: +LGPL + +Maintainer: +Bruno Haible, Paolo Bonzini + diff --git a/modules/math b/modules/math index 7d265bdae7..288ab92a0d 100644 --- a/modules/math +++ b/modules/math @@ -22,6 +22,7 @@ math.h: math_.h { 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' \ diff --git a/modules/mathl b/modules/mathl index 4a7c5953df..b8767b0f99 100644 --- a/modules/mathl +++ b/modules/mathl @@ -9,8 +9,6 @@ lib/ceill.c lib/cosl.c lib/expl.c lib/floorl.c -lib/frexpl.c -lib/frexp.c lib/ldexpl.c lib/logl.c lib/sincosl.c @@ -23,7 +21,7 @@ m4/mathl.m4 Depends-on: math -isnanl-nolibm +frexpl configure.ac: gl_FUNC_LONG_DOUBLE_MATH