]> Savannah Git Hosting - gnulib.git/commitdiff
setpayloadl: Fix platform-specific bugs.
authorBruno Haible <bruno@clisp.org>
Tue, 16 Apr 2024 22:38:07 +0000 (00:38 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 16 Apr 2024 22:39:11 +0000 (00:39 +0200)
* lib/setpayloadl.c (setpayloadl): On m68k, consider the actual memory
layout of a 'long double'. On platforms with quadruple-precision
'long double', store 111 bits of payload, not only 110 bits.

ChangeLog
lib/setpayloadl.c

index 03c691913181af53be0d7a8925024da879d5abba..7521411127f8a122d8fa7b1e11d4172a637c46fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-04-16  Bruno Haible  <bruno@clisp.org>
+
+       setpayloadl: Fix platform-specific bugs.
+       * lib/setpayloadl.c (setpayloadl): On m68k, consider the actual memory
+       layout of a 'long double'. On platforms with quadruple-precision
+       'long double', store 111 bits of payload, not only 110 bits.
+
 2024-04-16  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Prefer 'not in' over 'not ... in'.
index 7d25bafae06be37115168089bcca5b9dbc3f89be..6b5a1e24df1e23d16c25f4a5be4c43fba31f43f3 100644 (file)
@@ -80,9 +80,8 @@ setpayloadl (long double *result, long double payload)
       x.word[1] = (x.word[1] & 0xC0000000U) | (uint32_t) (pl >> 32);
       x.word[0] = (uint32_t) pl;
 #   elif LDBL_EXPBIT0_WORD == 0 && LDBL_EXPBIT0_BIT == 16 /* on m68k */
-      x.word[0] = (x.word[0] & 0xFFFFC000U) | (uint32_t) (pl >> 48)
-      x.word[1] = (uint32_t) (pl >> 16);
-      x.word[2] = (uint32_t) (pl << 16);
+      x.word[1] = (x.word[1] & 0xC0000000U) | (uint32_t) (pl >> 32);
+      x.word[2] = (uint32_t) pl;
 #   else
 #    error "Please port gnulib setpayloadl.c to your platform!"
 #   endif
@@ -103,8 +102,8 @@ setpayloadl (long double *result, long double payload)
 #   if LDBL_EXPBIT0_BIT == 16
       memory_long_double pl;
       pl.value = payload + TWO_LDBL_MANT_DIG;
-      x.word[LDBL_EXPBIT0_WORD] = (x.word[LDBL_EXPBIT0_WORD] & 0xFFFFC000U)
-                                  | (pl.word[LDBL_EXPBIT0_WORD] & 0x00003FFFU);
+      x.word[LDBL_EXPBIT0_WORD] = (x.word[LDBL_EXPBIT0_WORD] & 0xFFFF8000U)
+                                  | (pl.word[LDBL_EXPBIT0_WORD] & 0x00007FFFU);
       x.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD == 0 ? 1 : -1)] =
         pl.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD == 0 ? 1 : -1)];
       x.word[LDBL_EXPBIT0_WORD + (LDBL_EXPBIT0_WORD == 0 ? 2 : -2)] =