about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/s_llround.c
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2021-01-07 15:26:26 +0000
committerWilco Dijkstra <wdijkstr@arm.com>2021-01-07 15:26:26 +0000
commit9e97f239eae1f2b1d2e694d844c0f6fd7c4dd271 (patch)
treea9a2828381bf838da12fa738da4f1bda4bee161c /sysdeps/ieee754/dbl-64/s_llround.c
parentcaa884dda78ff226243f8cb344915152052a5118 (diff)
downloadglibc-9e97f239eae1f2b1d2e694d844c0f6fd7c4dd271.tar.gz
glibc-9e97f239eae1f2b1d2e694d844c0f6fd7c4dd271.tar.xz
glibc-9e97f239eae1f2b1d2e694d844c0f6fd7c4dd271.zip
Remove dbl-64/wordsize-64 (part 2)
Remove the wordsize-64 implementations by merging them into the main dbl-64
directory.  The second patch just moves all wordsize-64 files and removes a
few wordsize-64 uses in comments and Implies files.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/ieee754/dbl-64/s_llround.c')
-rw-r--r--sysdeps/ieee754/dbl-64/s_llround.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_llround.c b/sysdeps/ieee754/dbl-64/s_llround.c
index 69a55862b6..7020fd0156 100644
--- a/sysdeps/ieee754/dbl-64/s_llround.c
+++ b/sysdeps/ieee754/dbl-64/s_llround.c
@@ -17,54 +17,43 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#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)
 {
   int32_t j0;
-  uint32_t i1, i0;
+  int64_t i0;
   long long int result;
   int sign;
 
-  EXTRACT_WORDS (i0, i1, x);
-  j0 = ((i0 >> 20) & 0x7ff) - 0x3ff;
-  sign = (i0 & 0x80000000) != 0 ? -1 : 1;
-  i0 &= 0xfffff;
-  i0 |= 0x100000;
+  EXTRACT_WORDS64 (i0, x);
+  j0 = ((i0 >> 52) & 0x7ff) - 0x3ff;
+  sign = i0 < 0 ? -1 : 1;
+  i0 &= UINT64_C(0xfffffffffffff);
+  i0 |= UINT64_C(0x10000000000000);
 
-  if (j0 < 20)
+  if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
     {
       if (j0 < 0)
 	return j0 < -1 ? 0 : sign;
+      else if (j0 >= 52)
+	result = i0 << (j0 - 52);
       else
 	{
-	  i0 += 0x80000 >> j0;
-
-	  result = i0 >> (20 - j0);
-	}
-    }
-  else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
-    {
-      if (j0 >= 52)
-	result = (((long long int) i0 << 32) | i1) << (j0 - 52);
-      else
-	{
-	  uint32_t j = i1 + (0x80000000 >> (j0 - 20));
-	  if (j < i1)
-	    ++i0;
+	  i0 += UINT64_C(0x8000000000000) >> j0;
 
-	  if (j0 == 20)
-	    result = (long long int) i0;
-	  else
-	    result = ((long long int) i0 << (j0 - 20)) | (j >> (52 - j0));
+	  result = i0 >> (52 - j0);
 	}
     }
   else
@@ -86,3 +75,11 @@ __llround (double x)
 }
 
 libm_alias_double (__llround, llround)
+
+/* long has the same width as long long on LP64 machines, so use an alias.  */
+#undef lround
+#undef __lround
+#ifdef _LP64
+strong_alias (__llround, __lround)
+libm_alias_double (__lround, lround)
+#endif