[PATCH v2 17/32] mpi: Sync the m88k longlong.h with GCC.
Matt Turner
mattst88 at gmail.com
Wed Nov 25 21:19:54 CET 2026
* mpi/longlong.h [__m88110__] (udiv_qrnnd): Make the quotient a
USItype.
(umul_ppmm): Cast the operands.
--
Take the m88k block from GCC's copy of longlong.h, except that GCC
tests __mc88110__. GCC's m88k port defined __m88110__ for -m88110,
so keep that.
The udiv_qrnnd for the 88110 does not compile: it reads __q.__l, but
the union has no member __l. GCC's version outputs the quotient to a
USItype instead. GCC removed its m88k port in commit 7c942e1747c
("config.gcc: Purge all targets obsoleted in GCC 3.3."), so none of
this can be tested.
Signed-off-by: Matt Turner <mattst88 at gmail.com>
---
mpi/longlong.h | 86 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 45 insertions(+), 41 deletions(-)
diff --git a/mpi/longlong.h b/mpi/longlong.h
index 4bcf6e17..a69cd794 100644
--- a/mpi/longlong.h
+++ b/mpi/longlong.h
@@ -707,57 +707,61 @@ extern USItype __udiv_qrnnd (USItype *, USItype, USItype, USItype);
************** 88000 ****************
***************************************/
#if defined (__m88000__) && W_TYPE_SIZE == 32
-# define add_ssaaaa(sh, sl, ah, al, bh, bl) \
- __asm__ ("addu.co %1,%r4,%r5\n" \
- "addu.ci %0,%r2,%r3" \
- : "=r" __ll_check_output (USItype, sh), \
- "=&r" __ll_check_output (USItype, sl) \
- : "%rJ" ((USItype)(ah)), \
- "rJ" ((USItype)(bh)), \
- "%rJ" ((USItype)(al)), \
- "rJ" ((USItype)(bl)))
-# define sub_ddmmss(sh, sl, ah, al, bh, bl) \
- __asm__ ("subu.co %1,%r4,%r5\n" \
- "subu.ci %0,%r2,%r3" \
- : "=r" __ll_check_output (USItype, sh), \
- "=&r" __ll_check_output (USItype, sl) \
- : "rJ" ((USItype)(ah)), \
- "rJ" ((USItype)(bh)), \
- "rJ" ((USItype)(al)), \
- "rJ" ((USItype)(bl)))
-# define count_leading_zeros(count, x) \
+#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
+ __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
+ : "=r" __ll_check_output (USItype, sh), \
+ "=&r" __ll_check_output (USItype, sl) \
+ : "%rJ" ((USItype) (ah)), \
+ "rJ" ((USItype) (bh)), \
+ "%rJ" ((USItype) (al)), \
+ "rJ" ((USItype) (bl)))
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+ __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \
+ : "=r" __ll_check_output (USItype, sh), \
+ "=&r" __ll_check_output (USItype, sl) \
+ : "rJ" ((USItype) (ah)), \
+ "rJ" ((USItype) (bh)), \
+ "rJ" ((USItype) (al)), \
+ "rJ" ((USItype) (bl)))
+#define count_leading_zeros(count, x) \
do { \
USItype __cbtmp; \
- __asm__ ("ff1 %0,%1" \
- : "=r" (__cbtmp) \
- : "r" ((USItype)(x))); \
+ __asm__ ("ff1 %0,%1" \
+ : "=r" (__cbtmp) \
+ : "r" ((USItype) (x))); \
(count) = __cbtmp ^ 31; \
} while (0)
-# define COUNT_LEADING_ZEROS_0 63 /* sic */
-# if defined (__m88110__)
-# define umul_ppmm(wh, wl, u, v) \
+#define COUNT_LEADING_ZEROS_0 63 /* sic */
+#if defined (__m88110__)
+#define umul_ppmm(wh, wl, u, v) \
do { \
union {UDItype __ll; \
struct {USItype __h, __l;} __i; \
- } __x; \
- __asm__ ("mulu.d %0,%1,%2" : "=r" (__x.__ll) : "r" (u), "r" (v)); \
- (wh) = __x.__i.__h; \
- (wl) = __x.__i.__l; \
+ } __xx; \
+ __asm__ ("mulu.d %0,%1,%2" \
+ : "=r" (__xx.__ll) \
+ : "r" ((USItype) (u)), \
+ "r" ((USItype) (v))); \
+ (wh) = __xx.__i.__h; \
+ (wl) = __xx.__i.__l; \
} while (0)
-# define udiv_qrnnd(q, r, n1, n0, d) \
+#define udiv_qrnnd(q, r, n1, n0, d) \
({union {UDItype __ll; \
struct {USItype __h, __l;} __i; \
- } __x, __q; \
- __x.__i.__h = (n1); __x.__i.__l = (n0); \
- __asm__ ("divu.d %0,%1,%2" \
- : "=r" (__q.__ll) : "r" (__x.__ll), "r" (d)); \
- (r) = (n0) - __q.__l * (d); (q) = __q.__l; })
-# define UMUL_TIME 5
-# define UDIV_TIME 25
-# else
-# define UMUL_TIME 17
-# define UDIV_TIME 150
-# endif /* __m88110__ */
+ } __xx; \
+ USItype __q; \
+ __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
+ __asm__ ("divu.d %0,%1,%2" \
+ : "=r" (__q) \
+ : "r" (__xx.__ll), \
+ "r" ((USItype) (d))); \
+ (r) = (n0) - __q * (d); (q) = __q; })
+#define UMUL_TIME 5
+#define UDIV_TIME 25
+#else
+#define UMUL_TIME 17
+#define UDIV_TIME 150
+#endif /* __m88110__ */
#endif /* __m88000__ */
/***************************************
--
2.56.1
More information about the Gcrypt-devel
mailing list