7c0489
From 73f98d03d2cde34255c0a39ef18902bffdce0185 Mon Sep 17 00:00:00 2001
7c0489
From: Stefan Liebler <stli@linux.ibm.com>
7c0489
Date: Wed, 11 Dec 2019 15:09:14 +0100
7c0489
Subject: [PATCH 02/28] Always use wordsize-64 version of s_rint.c.
7c0489
7c0489
This patch replaces s_rint.c in sysdeps/dbl-64 with the one in
7c0489
sysdeps/dbl-64/wordsize-64 and removes the latter one.
7c0489
The code is not changed except changes in code style.
7c0489
7c0489
Also adjusted the include path in x86_64 file.
7c0489
7c0489
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7c0489
(cherry picked from commit ab48bdd098a675dddb360faafc497a61c4bd4334)
7c0489
---
7c0489
 sysdeps/ieee754/dbl-64/s_rint.c             | 32 ++++++------
7c0489
 sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c | 57 ---------------------
7c0489
 sysdeps/x86_64/fpu/multiarch/s_rint-c.c     |  2 +-
7c0489
 3 files changed, 17 insertions(+), 74 deletions(-)
7c0489
 delete mode 100644 sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c
7c0489
7c0489
diff --git a/sysdeps/ieee754/dbl-64/s_rint.c b/sysdeps/ieee754/dbl-64/s_rint.c
7c0489
index cb0f5ca298..7f3dc87b96 100644
7c0489
--- a/sysdeps/ieee754/dbl-64/s_rint.c
7c0489
+++ b/sysdeps/ieee754/dbl-64/s_rint.c
7c0489
@@ -1,4 +1,3 @@
7c0489
-/* @(#)s_rint.c 5.1 93/09/24 */
7c0489
 /*
7c0489
  * ====================================================
7c0489
  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7c0489
@@ -25,38 +24,39 @@
7c0489
 #include <libm-alias-double.h>
7c0489
 
7c0489
 static const double
7c0489
-  TWO52[2] = {
7c0489
-  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
7c0489
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
7c0489
+TWO52[2] = {
7c0489
+	    4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
7c0489
+	    -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
7c0489
 };
7c0489
 
7c0489
 double
7c0489
 __rint (double x)
7c0489
 {
7c0489
-  int32_t i0, j0, sx;
7c0489
-  double w, t;
7c0489
-  GET_HIGH_WORD (i0, x);
7c0489
-  sx = (i0 >> 31) & 1;
7c0489
-  j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
7c0489
+  int64_t i0, sx;
7c0489
+  int32_t j0;
7c0489
+  EXTRACT_WORDS64 (i0, x);
7c0489
+  sx = (i0 >> 63) & 1;
7c0489
+  j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
7c0489
   if (j0 < 52)
7c0489
     {
7c0489
       if (j0 < 0)
7c0489
 	{
7c0489
-	  w = TWO52[sx] + x;
7c0489
-	  t = w - TWO52[sx];
7c0489
-	  GET_HIGH_WORD (i0, t);
7c0489
-	  SET_HIGH_WORD (t, (i0 & 0x7fffffff) | (sx << 31));
7c0489
+	  double w = TWO52[sx] + x;
7c0489
+	  double t =  w - TWO52[sx];
7c0489
+	  EXTRACT_WORDS64 (i0, t);
7c0489
+	  INSERT_WORDS64 (t, (i0 & UINT64_C (0x7fffffffffffffff))
7c0489
+			  | (sx << 63));
7c0489
 	  return t;
7c0489
 	}
7c0489
     }
7c0489
   else
7c0489
     {
7c0489
       if (j0 == 0x400)
7c0489
-	return x + x;                   /* inf or NaN */
7c0489
+	return x + x;			/* inf or NaN  */
7c0489
       else
7c0489
-	return x;                       /* x is integral */
7c0489
+	return x;			/* x is integral  */
7c0489
     }
7c0489
-  w = TWO52[sx] + x;
7c0489
+  double w = TWO52[sx] + x;
7c0489
   return w - TWO52[sx];
7c0489
 }
7c0489
 #ifndef __rint
7c0489
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c
7c0489
deleted file mode 100644
7c0489
index 622e479c5f..0000000000
7c0489
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c
7c0489
+++ /dev/null
7c0489
@@ -1,57 +0,0 @@
7c0489
-/*
7c0489
- * ====================================================
7c0489
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7c0489
- *
7c0489
- * Developed at SunPro, a Sun Microsystems, Inc. business.
7c0489
- * Permission to use, copy, modify, and distribute this
7c0489
- * software is freely granted, provided that this notice
7c0489
- * is preserved.
7c0489
- * ====================================================
7c0489
- */
7c0489
-
7c0489
-/*
7c0489
- * rint(x)
7c0489
- * Return x rounded to integral value according to the prevailing
7c0489
- * rounding mode.
7c0489
- * Method:
7c0489
- *	Using floating addition.
7c0489
- * Exception:
7c0489
- *	Inexact flag raised if x not equal to rint(x).
7c0489
- */
7c0489
-
7c0489
-#include <math.h>
7c0489
-#include <math_private.h>
7c0489
-#include <libm-alias-double.h>
7c0489
-
7c0489
-static const double
7c0489
-TWO52[2]={
7c0489
-  4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */
7c0489
- -4.50359962737049600000e+15, /* 0xC3300000, 0x00000000 */
7c0489
-};
7c0489
-
7c0489
-double
7c0489
-__rint(double x)
7c0489
-{
7c0489
-	int64_t i0,sx;
7c0489
-	int32_t j0;
7c0489
-	EXTRACT_WORDS64(i0,x);
7c0489
-	sx = (i0>>63)&1;
7c0489
-	j0 = ((i0>>52)&0x7ff)-0x3ff;
7c0489
-	if(j0<52) {
7c0489
-	    if(j0<0) {
7c0489
-		double w = TWO52[sx]+x;
7c0489
-		double t =  w-TWO52[sx];
7c0489
-		EXTRACT_WORDS64(i0,t);
7c0489
-		INSERT_WORDS64(t,(i0&UINT64_C(0x7fffffffffffffff))|(sx<<63));
7c0489
-		return t;
7c0489
-	    }
7c0489
-	} else {
7c0489
-	    if(j0==0x400) return x+x;	/* inf or NaN */
7c0489
-	    else return x;		/* x is integral */
7c0489
-	}
7c0489
-	double w = TWO52[sx]+x;
7c0489
-	return w-TWO52[sx];
7c0489
-}
7c0489
-#ifndef __rint
7c0489
-libm_alias_double (__rint, rint)
7c0489
-#endif
7c0489
diff --git a/sysdeps/x86_64/fpu/multiarch/s_rint-c.c b/sysdeps/x86_64/fpu/multiarch/s_rint-c.c
7c0489
index 162a630ff9..b010150f52 100644
7c0489
--- a/sysdeps/x86_64/fpu/multiarch/s_rint-c.c
7c0489
+++ b/sysdeps/x86_64/fpu/multiarch/s_rint-c.c
7c0489
@@ -1,3 +1,3 @@
7c0489
 #undef __rint
7c0489
 #define __rint __rint_c
7c0489
-#include <sysdeps/ieee754/dbl-64/wordsize-64/s_rint.c>
7c0489
+#include <sysdeps/ieee754/dbl-64/s_rint.c>
7c0489
-- 
7c0489
2.18.2
7c0489