From: Bruno Haible Date: Sun, 9 Oct 2011 23:08:51 +0000 (+0200) Subject: rintl: Simplify for platforms where 'long double' == 'double'. X-Git-Tag: v0.1~1598 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=11368c16b7faaff172abbfd8b25303389c7031e5;p=gnulib.git rintl: Simplify for platforms where 'long double' == 'double'. * lib/rintl.c: Include . (rintl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. * lib/rint.c [!USE_LONG_DOUBLE]: Don't include a second time. * m4/rintl.m4 (gl_FUNC_RINTL): Require gl_LONG_DOUBLE_VS_DOUBLE. Determine RINTL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. * modules/rintl (Depends-on): Add rint. Update conditions. --- diff --git a/ChangeLog b/ChangeLog index a342bb0ac..95f2b1d8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-09 Bruno Haible + rintl: Simplify for platforms where 'long double' == 'double'. + * lib/rintl.c: Include . + (rintl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. + * lib/rint.c [!USE_LONG_DOUBLE]: Don't include a second + time. + * m4/rintl.m4 (gl_FUNC_RINTL): Require gl_LONG_DOUBLE_VS_DOUBLE. + Determine RINTL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. + * modules/rintl (Depends-on): Add rint. Update conditions. + +2011-10-09 Bruno Haible + roundl: Simplify for platforms where 'long double' == 'double'. * lib/roundl.c: Include . (roundl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. diff --git a/lib/rint.c b/lib/rint.c index 4ba3fe554..7eefe7aab 100644 --- a/lib/rint.c +++ b/lib/rint.c @@ -15,7 +15,9 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#if ! defined USE_LONG_DOUBLE +# include +#endif /* Specification. */ #include diff --git a/lib/rintl.c b/lib/rintl.c index 6c0e9999c..d26935ef8 100644 --- a/lib/rintl.c +++ b/lib/rintl.c @@ -15,5 +15,22 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define USE_LONG_DOUBLE -#include "rint.c" +#include + +#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + +/* Specification. */ +# include + +long double +rintl (long double x) +{ + return rint (x); +} + +#else + +# define USE_LONG_DOUBLE +# include "rint.c" + +#endif diff --git a/m4/rintl.m4 b/m4/rintl.m4 index df8334103..bb88ee806 100644 --- a/m4/rintl.m4 +++ b/m4/rintl.m4 @@ -1,4 +1,4 @@ -# rintl.m4 serial 2 +# rintl.m4 serial 3 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, @@ -7,13 +7,20 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_RINTL], [ AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) dnl Determine RINTL_LIBM. gl_MATHFUNC([rintl], [long double], [(long double)]) if test $gl_cv_func_rintl_no_libm = no \ && test $gl_cv_func_rintl_in_libm = no; then HAVE_RINTL=0 - RINTL_LIBM= + dnl Find libraries needed to link lib/rintl.c. + if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then + AC_REQUIRE([gl_FUNC_RINT]) + RINTL_LIBM="$RINT_LIBM" + else + RINTL_LIBM= + fi fi AC_SUBST([RINTL_LIBM]) ]) diff --git a/modules/rintl b/modules/rintl index 80a0f528a..dac26185f 100644 --- a/modules/rintl +++ b/modules/rintl @@ -9,6 +9,7 @@ m4/mathfunc.m4 Depends-on: math +rint [test $HAVE_RINTL = 0 && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] configure.ac: gl_FUNC_RINTL