]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
lround: provide cast for wordsize-64 version if needed
authorChris Metcalf <cmetcalf@ezchip.com>
Mon, 5 Jan 2015 16:59:32 +0000 (11:59 -0500)
committerChris Metcalf <cmetcalf@ezchip.com>
Mon, 5 Jan 2015 16:59:32 +0000 (11:59 -0500)
Platforms with 64-bit registers where 32-bit values need to have the
high 32 bits set in a particular way need to have an explicit cast
when using the 64-bit sysdeps/ieee754/dbl-64/wordsize-64 version
of llround() as lround().  This includes tilegx32, and likely MIPS.
x32 does not need this, and AArch64 ILP32 will not either.  Require
it to be specified in sysdep.h to be explicit.

ChangeLog
sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c
sysdeps/tile/sysdep.h
sysdeps/x86_64/x32/sysdep.h

index 0e6e224927423b7e7d4fcfb71de7a00a8cea490a..123b0b28fcd181d5fa34e4a55631f5c51c631c50 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-01-05  Chris Metcalf  <cmetcalf@ezchip.com>
+
+       * sysdeps/ieee754/dbl-64/wordsize-64/s_llround.c [!defined _LP64
+       && REGISTER_CAST_INT32_TO_INT64]: Provide explicit lround()
+       function with cast from llround().
+       * sysdeps/tile/sysdep.h (REGISTER_CAST_INT32_TO_INT64): Define.
+       * sysdeps/x86_64/x32/sysdep.h (REGISTER_CAST_INT32_TO_INT64):
+       Define.
+
 2015-01-05  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #17793]
index 885260163e655b92ec6e401a2dd9b14e035611b9..8bb52524b7f984a8d06e15c2e55f9e790f001fff 100644 (file)
@@ -21,6 +21,7 @@
 #define __lround __hidden___lround
 
 #include <math.h>
+#include <sysdep.h>
 
 #include <math_private.h>
 
@@ -64,16 +65,31 @@ __llround (double x)
 
 weak_alias (__llround, llround)
 #ifdef NO_LONG_DOUBLE
-strong_alias (__llround, __lroundl)
-weak_alias (__llround, lroundl)
+strong_alias (__llround, __llroundl)
+weak_alias (__llround, llroundl)
 #endif
 
-/* long has the same width as long long on 64-bit machines.  */
+/* long has the same width as long long on LP64 machines, so use an alias.
+   If building for ILP32 on a machine with 64-bit registers, however,
+   use a cast if necessary.  */
 #undef lround
 #undef __lround
+#if !defined (_LP64) && REGISTER_CAST_INT32_TO_INT64
+long int
+__lround (double x)
+{
+  return __llround (x);
+}
+weak_alias (__lround, lround)
+# ifdef NO_LONG_DOUBLE
+strong_alias (__lround, __lroundl)
+weak_alias (__lround, lroundl)
+# endif
+#else
 strong_alias (__llround, __lround)
 weak_alias (__llround, lround)
-#ifdef NO_LONG_DOUBLE
-strong_alias (__llround, __llroundl)
-weak_alias (__llround, llroundl)
+# ifdef NO_LONG_DOUBLE
+strong_alias (__llround, __lroundl)
+weak_alias (__llround, lroundl)
+# endif
 #endif
index ead9dba0b4bb272c5d29b3f3881e79a46ace7fef..7b3d8739d2e3b58a35a76cad20a6cc83c61f6b44 100644 (file)
 #endif
 
 #endif /* __ASSEMBLER__ */
+
+/* On tilegx, 32-bit values must have their high 32 bits sign extended;
+   random values are not allowed.  */
+#define REGISTER_CAST_INT32_TO_INT64 1
index 9b8700522f338011f0ba3cca8046f2bad331a56e..0cbc1a083fd42f0c2d45a323ad6a31270b538fb0 100644 (file)
@@ -90,3 +90,7 @@
 # define R15_LP        "r15d"
 
 #endif /* __ASSEMBLER__ */
+
+/* On x32, it is not required to normalize a 64-bit value before using
+   it as a 32-bit value.  */
+#define REGISTER_CAST_INT32_TO_INT64 0