From ad9bb48fbe7700c8050a698942f7a9c4f097a91c Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 17 Apr 2009 20:54:19 +0000 Subject: [PATCH] 2009-04-17 Ken Werner * libc/include/machine/ieeefp.h: _LDBL_EQ_DBL check fixed. * libc/include/math.h (llrintl): Declare. * libm/common/llrintl.c: New File. * libm/common/Makefile.am: New File added. * libm/common/Makefile.in: Regenerate. --- newlib/ChangeLog | 8 ++++++ newlib/libc/include/machine/ieeefp.h | 6 ++-- newlib/libc/include/math.h | 1 + newlib/libm/common/Makefile.am | 6 ++-- newlib/libm/common/Makefile.in | 36 ++++++++++++++---------- newlib/libm/common/llrintl.c | 41 ++++++++++++++++++++++++++++ 6 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 newlib/libm/common/llrintl.c diff --git a/newlib/ChangeLog b/newlib/ChangeLog index c289084ee..a974daa91 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,11 @@ +2009-04-17 Ken Werner + + * libc/include/machine/ieeefp.h: _LDBL_EQ_DBL check fixed. + * libc/include/math.h (llrintl): Declare. + * libm/common/llrintl.c: New File. + * libm/common/Makefile.am: New File added. + * libm/common/Makefile.in: Regenerate. + 2009-04-17 Ken Werner * libc/configure.in: Change AC_TRY_COMPILE to AC_TRY_COMMAND to diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h index bbbec5473..643111beb 100644 --- a/newlib/libc/include/machine/ieeefp.h +++ b/newlib/libc/include/machine/ieeefp.h @@ -333,8 +333,8 @@ /* Check if long double is as wide as double. */ #if (!defined(__STRICT_ANSI__) || __STDC_VERSION__ > 199901L || \ - defined(__cplusplus)) && defined(LDBL_MANT_DIG) && \ - (DBL_MANT_DIG == LDBL_MANT_DIG && LDBL_MIN_EXP == DBL_MIN_EXP && \ - LDBL_MAX_EXP == DBL_MAX_EXP) + defined(__cplusplus)) && defined(__LDBL_MANT_DIG__) && \ + (__DBL_MANT_DIG__ == __LDBL_MANT_DIG__ && __LDBL_MIN_EXP__ == __DBL_MIN_EXP__ && \ + __LDBL_MAX_EXP__ == __DBL_MAX_EXP__) #define _LDBL_EQ_DBL #endif diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h index 95f0e216b..6f61583a4 100644 --- a/newlib/libc/include/math.h +++ b/newlib/libc/include/math.h @@ -382,6 +382,7 @@ extern long double scalblnl _PARAMS((long double, long)); extern long double tgammal _PARAMS((long double)); extern long double nearbyintl _PARAMS((long double)); extern long int lrintl _PARAMS((long double)); +extern long long int llrintl _PARAMS((long double)); extern long double roundl _PARAMS((long double)); extern long lroundl _PARAMS((long double)); extern _LONG_LONG_TYPE int llroundl _PARAMS((long double)); diff --git a/newlib/libm/common/Makefile.am b/newlib/libm/common/Makefile.am index b7dab9a3f..ed556ef1d 100644 --- a/newlib/libm/common/Makefile.am +++ b/newlib/libm/common/Makefile.am @@ -28,9 +28,9 @@ lsrc = atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \ floorl.c log1pl.c expm1l.c acosl.c asinl.c atan2l.c coshl.c sinhl.c \ expl.c ldexpl.c logl.c log10l.c powl.c sqrtl.c fmodl.c hypotl.c \ copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \ - scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c roundl.c \ - lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c fmal.c \ - acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c + scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \ + roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \ + fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c libcommon_la_LDFLAGS = -Xcompiler -nostdlib diff --git a/newlib/libm/common/Makefile.in b/newlib/libm/common/Makefile.in index 6620948df..d3e6fcc6a 100644 --- a/newlib/libm/common/Makefile.in +++ b/newlib/libm/common/Makefile.in @@ -114,14 +114,14 @@ am__objects_3 = lib_a-atanl.$(OBJEXT) lib_a-cosl.$(OBJEXT) \ lib_a-scalbnl.$(OBJEXT) lib_a-exp2l.$(OBJEXT) \ lib_a-scalblnl.$(OBJEXT) lib_a-tgammal.$(OBJEXT) \ lib_a-nearbyintl.$(OBJEXT) lib_a-lrintl.$(OBJEXT) \ - lib_a-roundl.$(OBJEXT) lib_a-lroundl.$(OBJEXT) \ - lib_a-llroundl.$(OBJEXT) lib_a-truncl.$(OBJEXT) \ - lib_a-remquol.$(OBJEXT) lib_a-fdiml.$(OBJEXT) \ - lib_a-fmaxl.$(OBJEXT) lib_a-fminl.$(OBJEXT) \ - lib_a-fmal.$(OBJEXT) lib_a-acoshl.$(OBJEXT) \ - lib_a-atanhl.$(OBJEXT) lib_a-remainderl.$(OBJEXT) \ - lib_a-lgammal.$(OBJEXT) lib_a-erfl.$(OBJEXT) \ - lib_a-erfcl.$(OBJEXT) + lib_a-llrintl.$(OBJEXT) lib_a-roundl.$(OBJEXT) \ + lib_a-lroundl.$(OBJEXT) lib_a-llroundl.$(OBJEXT) \ + lib_a-truncl.$(OBJEXT) lib_a-remquol.$(OBJEXT) \ + lib_a-fdiml.$(OBJEXT) lib_a-fmaxl.$(OBJEXT) \ + lib_a-fminl.$(OBJEXT) lib_a-fmal.$(OBJEXT) \ + lib_a-acoshl.$(OBJEXT) lib_a-atanhl.$(OBJEXT) \ + lib_a-remainderl.$(OBJEXT) lib_a-lgammal.$(OBJEXT) \ + lib_a-erfl.$(OBJEXT) lib_a-erfcl.$(OBJEXT) @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@am__objects_4 = \ @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_FALSE@ $(am__objects_3) @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ @@ -151,10 +151,10 @@ am__objects_7 = atanl.lo cosl.lo sinl.lo tanl.lo tanhl.lo frexpl.lo \ ldexpl.lo logl.lo log10l.lo powl.lo sqrtl.lo fmodl.lo \ hypotl.lo copysignl.lo nanl.lo ilogbl.lo asinhl.lo cbrtl.lo \ nextafterl.lo rintl.lo scalbnl.lo exp2l.lo scalblnl.lo \ - tgammal.lo nearbyintl.lo lrintl.lo roundl.lo lroundl.lo \ - llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.lo fminl.lo \ - fmal.lo acoshl.lo atanhl.lo remainderl.lo lgammal.lo erfl.lo \ - erfcl.lo + tgammal.lo nearbyintl.lo lrintl.lo llrintl.lo roundl.lo \ + lroundl.lo llroundl.lo truncl.lo remquol.lo fdiml.lo fmaxl.lo \ + fminl.lo fmal.lo acoshl.lo atanhl.lo remainderl.lo lgammal.lo \ + erfl.lo erfcl.lo @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@am__objects_8 = \ @HAVE_LONG_DOUBLE_TRUE@@USE_LIBTOOL_TRUE@ $(am__objects_7) @USE_LIBTOOL_TRUE@am_libcommon_la_OBJECTS = $(am__objects_5) \ @@ -346,9 +346,9 @@ lsrc = atanl.c cosl.c sinl.c tanl.c tanhl.c frexpl.c modfl.c ceill.c fabsl.c \ floorl.c log1pl.c expm1l.c acosl.c asinl.c atan2l.c coshl.c sinhl.c \ expl.c ldexpl.c logl.c log10l.c powl.c sqrtl.c fmodl.c hypotl.c \ copysignl.c nanl.c ilogbl.c asinhl.c cbrtl.c nextafterl.c rintl.c \ - scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c roundl.c \ - lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c fmal.c \ - acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c + scalbnl.c exp2l.c scalblnl.c tgammal.c nearbyintl.c lrintl.c llrintl.c \ + roundl.c lroundl.c llroundl.c truncl.c remquol.c fdiml.c fmaxl.c fminl.c \ + fmal.c acoshl.c atanhl.c remainderl.c lgammal.c erfl.c erfcl.c libcommon_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libcommon.la @@ -1098,6 +1098,12 @@ lib_a-lrintl.o: lrintl.c lib_a-lrintl.obj: lrintl.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lrintl.obj `if test -f 'lrintl.c'; then $(CYGPATH_W) 'lrintl.c'; else $(CYGPATH_W) '$(srcdir)/lrintl.c'; fi` +lib_a-llrintl.o: llrintl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-llrintl.o `test -f 'llrintl.c' || echo '$(srcdir)/'`llrintl.c + +lib_a-llrintl.obj: llrintl.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-llrintl.obj `if test -f 'llrintl.c'; then $(CYGPATH_W) 'llrintl.c'; else $(CYGPATH_W) '$(srcdir)/llrintl.c'; fi` + lib_a-roundl.o: roundl.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-roundl.o `test -f 'roundl.c' || echo '$(srcdir)/'`roundl.c diff --git a/newlib/libm/common/llrintl.c b/newlib/libm/common/llrintl.c new file mode 100644 index 000000000..0835def90 --- /dev/null +++ b/newlib/libm/common/llrintl.c @@ -0,0 +1,41 @@ +/* +(C) Copyright IBM Corp. 2009 + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. +* Neither the name of IBM nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +/* On platforms where long double is as wide as double. */ +#ifdef _LDBL_EQ_DBL +long long int +llrintl (long double x) +{ + return llrint(x); +} +#endif +