From 3629bfd5a7a6ff226d46aa030bd47591f647385d Mon Sep 17 00:00:00 2001 From: leitner Date: Fri, 26 Dec 2008 01:51:35 +0000 Subject: [PATCH] add non-asm version for gcc --- mult/imult64.c | 2 +- mult/umult64.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mult/imult64.c b/mult/imult64.c index 1c3c0dd..ecf4f30 100644 --- a/mult/imult64.c +++ b/mult/imult64.c @@ -1,4 +1,4 @@ -#ifdef __x86_64__ +#if defined(__x86_64__) && defined(__OPTIMIZE__) /* WARNING: this only works if compiled with -fomit-frame-pointer */ void imult64() { diff --git a/mult/umult64.c b/mult/umult64.c index acb6e67..d4ecf2c 100644 --- a/mult/umult64.c +++ b/mult/umult64.c @@ -21,6 +21,16 @@ void umult64() { #include "safemult.h" +#ifdef __GNUC__ + +int umult64(uint64 a,uint64 b,uint64* c) { + __uint128_t x=((__uint128_t)a)*b; + if ((*c=(uint64)x) != x) return 0; + return 1; +} + +#else + /* return 1 for overflow, 0 for ok */ int umult64(uint64 a,uint64 b,uint64* c) { uint32 ahi=a>>32; @@ -46,3 +56,5 @@ int umult64(uint64 a,uint64 b,uint64* c) { } #endif + +#endif