On Fri, Apr 29, 2011 at 11:36:31PM +0200, Julien Cristau wrote:
> On Thu, Apr 21, 2011 at 18:50:31 +0200, Aurelien Jarno wrote:
>
> > That said GCC supports 32x32 => 64 multiplication on 32-bit architectures
> > for a lot of time, so there is no need to use assembly code for that.
> > The patch below fixes the problem by using standard multiplication
> > instead of assembly code. I have also included the code for MIPS64 using
> > 128-bit hints for reference, though it is not used in Debian.
> >
> Did you forget to attach the patch?
>
Indeed, here it is:
--- libzn-poly-0.8.orig/wide_arith.h
+++ libzn-poly-0.8/wide_arith.h
@@ -244,14 +244,23 @@
#if (UNSIGNED_LONG_BITS == 32)
#define ZNP_MUL_WIDE(hi, lo, a, b) \
- __asm__ ("multu %2,%3" : "=l" (lo), "=h" (hi) : "d" (a), "d" (b));
-
+ do { \
+ uint64_t result; \
+ result = (uint64_t) a * b; \
+ hi = (uint32_t)(result >> 32); \
+ lo = (uint32_t) result; \
+ } while (0);
#elif (UNSIGNED_LONG_BITS == 64)
#define ZNP_MUL_WIDE(hi, lo, a, b) \
- __asm__ ("dmultu %2,%3" : "=l" (lo), "=h" (hi) : "d" (a), "d" (b));
-
+ do { \
+ typedef unsigned int uint128_t __attribute__((mode(TI))); \
+ uint128_t result; \
+ result = (uint128_t) a * b; \
+ hi = (uint64_t)(result >> 64); \
+ lo = (uint64_t) result; \
+ } while (0);
#endif
--
Aurelien Jarno GPG: 1024D/F1BCDB73
[email protected] http://www.aurel32.net
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]