[PATCH v2 09/32] mpi: Fix the generic smul_ppmm when umul_ppmm uses __m0 and __m1.
Matt Turner
mattst88 at gmail.com
Wed Nov 25 21:19:46 CET 2026
* mpi/longlong.h [!smul_ppmm] (smul_ppmm): Rename the temporaries
__m0 and __m1 to __xm0 and __xm1.
--
The umul_ppmm for Alpha, AArch64, IBM RT and VAX declares its own
__m0 and __m1, which the generic smul_ppmm passes as the arguments,
so they are initialized from themselves and the result is garbage.
No caller in Libgcrypt uses smul_ppmm, so nothing was miscompiled.
Use the names that GCC's copy of longlong.h gives the temporaries in
its generic umul_ppmm, which is written in terms of smul_ppmm.
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
mpi/longlong.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mpi/longlong.h b/mpi/longlong.h
index e5c4ea9f..a745e12d 100644
--- a/mpi/longlong.h
+++ b/mpi/longlong.h
@@ -1461,10 +1461,10 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
# define smul_ppmm(w1, w0, u, v) \
do { \
UWtype __w1; \
- UWtype __m0 = (u), __m1 = (v); \
- umul_ppmm (__w1, w0, __m0, __m1); \
- (w1) = __w1 - (-(__m0 >> (W_TYPE_SIZE - 1)) & __m1) \
- - (-(__m1 >> (W_TYPE_SIZE - 1)) & __m0); \
+ UWtype __xm0 = (u), __xm1 = (v); \
+ umul_ppmm (__w1, w0, __xm0, __xm1); \
+ (w1) = __w1 - (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \
+ - (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \
} while (0)
#endif
--
2.56.1
More information about the Gcrypt-devel
mailing list