This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: long double (was "strtold?")


On Thursday 16 April 2009 20:25:17 you wrote:
> Checked in with minor tweaks to ChangeLog and libm.texinfo.
>
> -- Jeff J.

Hi,

I noticed two glitches with the current long double wrappers. First, the check 
whether long double is as wide as double within ieeefp.h uses wrong defines - I 
missed some underscores. Second, the llrintl prototype and the corresponding 
wrapper function was missing. The attached patch fixes these two issues. Sorry 
for the inconvenience caused.

Ken

newlib/ChangeLog:

2009-04-17  Ken Werner  <ken.werner@de.ibm.com>

        * 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.

Index: src/newlib/libc/include/math.h
===================================================================
--- src.orig/newlib/libc/include/math.h
+++ src/newlib/libc/include/math.h
@@ -382,6 +382,7 @@ extern long double scalblnl _PARAMS((lon
 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));
Index: src/newlib/libm/common/Makefile.am
===================================================================
--- src.orig/newlib/libm/common/Makefile.am
+++ src/newlib/libm/common/Makefile.am
@@ -28,9 +28,9 @@ lsrc =	atanl.c cosl.c sinl.c tanl.c tanh
 	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
 
Index: src/newlib/libm/common/llrintl.c
===================================================================
--- /dev/null
+++ src/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 <math.h>
+
+/* 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
+
Index: src/newlib/libc/include/machine/ieeefp.h
===================================================================
--- src.orig/newlib/libc/include/machine/ieeefp.h
+++ src/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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]