From 1ac9a623b07722e14367dac9284372881aae3934 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 10 Oct 2011 01:04:13 +0200 Subject: [PATCH] ceill: Simplify for platforms where 'long double' == 'double'. * lib/ceill.c: Include . (ceill) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. * lib/ceil.c [!USE_LONG_DOUBLE]: Don't include a second time. * m4/ceill.m4 (gl_FUNC_CEILL): Require gl_LONG_DOUBLE_VS_DOUBLE. Determine CEILL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. * modules/ceill (Depends-on): Add ceil. Update conditions. --- ChangeLog | 11 +++++++++++ lib/ceil.c | 4 +++- lib/ceill.c | 21 +++++++++++++++++++-- m4/ceill.m4 | 14 +++++++++++--- modules/ceill | 3 ++- 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11dc4bb08..909a202b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2011-10-09 Bruno Haible + ceill: Simplify for platforms where 'long double' == 'double'. + * lib/ceill.c: Include . + (ceill) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. + * lib/ceil.c [!USE_LONG_DOUBLE]: Don't include a second + time. + * m4/ceill.m4 (gl_FUNC_CEILL): Require gl_LONG_DOUBLE_VS_DOUBLE. + Determine CEILL_LIBM according to HAVE_SAME_LONG_DOUBLE_AS_DOUBLE. + * modules/ceill (Depends-on): Add ceil. Update conditions. + +2011-10-09 Bruno Haible + floorl: Simplify for platforms where 'long double' == 'double'. * lib/floorl.c: Include . (floorl) [HAVE_SAME_LONG_DOUBLE_AS_DOUBLE]: New function. diff --git a/lib/ceil.c b/lib/ceil.c index b30902cbf..4e0354e1c 100644 --- a/lib/ceil.c +++ b/lib/ceil.c @@ -16,7 +16,9 @@ /* Written by Bruno Haible , 2007. */ -#include +#if ! defined USE_LONG_DOUBLE +# include +#endif /* Specification. */ #include diff --git a/lib/ceill.c b/lib/ceill.c index 54a4b50c5..6181c91d4 100644 --- a/lib/ceill.c +++ b/lib/ceill.c @@ -16,5 +16,22 @@ /* Written by Bruno Haible , 2007. */ -#define USE_LONG_DOUBLE -#include "ceil.c" +#include + +#if HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + +/* Specification. */ +# include + +long double +ceill (long double x) +{ + return ceil (x); +} + +#else + +# define USE_LONG_DOUBLE +# include "ceil.c" + +#endif diff --git a/m4/ceill.m4 b/m4/ceill.m4 index 40adaf12f..5f56df321 100644 --- a/m4/ceill.m4 +++ b/m4/ceill.m4 @@ -1,4 +1,4 @@ -# ceill.m4 serial 11 +# ceill.m4 serial 12 dnl Copyright (C) 2007, 2009-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, @@ -8,8 +8,11 @@ AC_DEFUN([gl_FUNC_CEILL], [ m4_divert_text([DEFAULTS], [gl_ceill_required=plain]) AC_REQUIRE([gl_MATH_H_DEFAULTS]) + AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE]) + dnl Persuade glibc to declare ceill(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + dnl Test whether ceill() is declared. AC_CHECK_DECLS([ceill], , , [[#include ]]) if test "$ac_cv_have_decl_ceill" = yes; then @@ -60,8 +63,13 @@ int main (int argc, char *argv[]) HAVE_DECL_CEILL=0 fi if test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; then - dnl No libraries are needed to link lib/ceill.c. - CEILL_LIBM= + dnl Find libraries needed to link lib/ceill.c. + if test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1; then + AC_REQUIRE([gl_FUNC_CEIL]) + CEILL_LIBM="$CEIL_LIBM" + else + CEILL_LIBM= + fi fi AC_SUBST([CEILL_LIBM]) ]) diff --git a/modules/ceill b/modules/ceill index 4ab7f3857..a5d860fc2 100644 --- a/modules/ceill +++ b/modules/ceill @@ -9,7 +9,8 @@ m4/ceill.m4 Depends-on: math extensions -float [test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1] +ceil [{ test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 1] +float [{ test $HAVE_DECL_CEILL = 0 || test $REPLACE_CEILL = 1; } && test $HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0] configure.ac: gl_FUNC_CEILL -- 2.11.0