public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/lld] Remove dbl-64/wordsize-64
@ 2021-01-18 21:39 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-01-18 21:39 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=caa884dda78ff226243f8cb344915152052a5118

commit caa884dda78ff226243f8cb344915152052a5118
Author: Wilco Dijkstra <wdijkstr@arm.com>
Date:   Thu Jan 7 15:02:51 2021 +0000

    Remove dbl-64/wordsize-64
    
    Remove the wordsize-64 implementations by merging them into the main dbl-64
    directory.  The first patch adds special cases needed for 32-bit targets
    (FIX_INT_FP_CONVERT_ZERO and FIX_DBL_LONG_CONVERT_OVERFLOW) to the
    wordsize-64 versions.  This has no effect on 64-bit targets since they don't
    define these macros.
    
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

Diff:
---
 sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c      |  3 +++
 sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c |  3 +++
 sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c    | 16 +++++++++++++---
 sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c     | 13 ++++++++++++-
 4 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
index 0b4116e0a8..b89064fb7c 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/e_log10.c
@@ -44,6 +44,7 @@
  */
 
 #include <math.h>
+#include <fix-int-fp-convert-zero.h>
 #include <math_private.h>
 #include <stdint.h>
 #include <libm-alias-finite.h>
@@ -80,6 +81,8 @@ __ieee754_log10 (double x)
   i = ((uint64_t) k & UINT64_C(0x8000000000000000)) >> 63;
   hx = (hx & UINT64_C(0x000fffffffffffff)) | ((0x3ff - i) << 52);
   y = (double) (k + i);
+  if (FIX_INT_FP_CONVERT_ZERO && y == 0.0)
+    y = 0.0;
   INSERT_WORDS64 (x, hx);
   z = y * log10_2lo + ivln10 * __ieee754_log (x);
   return z + y * log10_2hi;
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
index c8415daf25..5e4ccd9ad1 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c
@@ -20,6 +20,7 @@
 #include <math_private.h>
 #include <libm-alias-double.h>
 #include <stdint.h>
+#include <fix-int-fp-convert-zero.h>
 
 double
 __getpayload (const double *x)
@@ -30,6 +31,8 @@ __getpayload (const double *x)
       || (ix & 0xfffffffffffffULL) == 0)
     return -1;
   ix &= 0x7ffffffffffffULL;
+  if (FIX_INT_FP_CONVERT_ZERO && ix == 0)
+    return 0.0f;
   return (double) ix;
 }
 libm_alias_double (__getpayload, getpayload)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
index 0290db89ce..7020fd0156 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
@@ -20,12 +20,14 @@
 #define lround __hidden_lround
 #define __lround __hidden___lround
 
+#include <fenv.h>
+#include <limits.h>
 #include <math.h>
 #include <sysdep.h>
 
 #include <math_private.h>
 #include <libm-alias-double.h>
-
+#include <fix-fp-int-convert-overflow.h>
 
 long long int
 __llround (double x)
@@ -56,8 +58,16 @@ __llround (double x)
     }
   else
     {
-      /* The number is too large.  It is left implementation defined
-	 what happens.  */
+#ifdef FE_INVALID
+      /* The number is too large.  Unless it rounds to LLONG_MIN,
+	 FE_INVALID must be raised and the return value is
+	 unspecified.  */
+      if (FIX_DBL_LLONG_CONVERT_OVERFLOW && x != (double) LLONG_MIN)
+	{
+	  feraiseexcept (FE_INVALID);
+	  return sign == 1 ? LLONG_MAX : LLONG_MIN;
+	}
+#endif
       return (long long int) x;
     }
 
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
index 88a1f3a928..5284c4da09 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c
@@ -22,6 +22,7 @@
 
 #include <math_private.h>
 #include <libm-alias-double.h>
+#include <fix-fp-int-convert-overflow.h>
 
 /* For LP64, lround is an alias for llround.  */
 #ifndef _LP64
@@ -66,7 +67,17 @@ __lround (double x)
 	 FE_INVALID must be raised and the return value is
 	 unspecified.  */
 #ifdef FE_INVALID
-      if (sizeof (long int) == 4
+      if (FIX_DBL_LONG_CONVERT_OVERFLOW
+	  && !(sign == -1
+	       && (sizeof (long int) == 4
+		   ? x > (double) LONG_MIN - 0.5
+		   : x >= (double) LONG_MIN)))
+	{
+	  feraiseexcept (FE_INVALID);
+	  return sign == 1 ? LONG_MAX : LONG_MIN;
+	}
+      else if (!FIX_DBL_LONG_CONVERT_OVERFLOW
+	  && sizeof (long int) == 4
 	  && x <= (double) LONG_MIN - 0.5)
 	{
 	  /* If truncation produces LONG_MIN, the cast will not raise


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-18 21:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-18 21:39 [glibc/maskray/lld] Remove dbl-64/wordsize-64 Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).