From: simonmar Date: Thu, 14 Jul 2005 10:38:03 +0000 (+0000) Subject: [project @ 2005-07-14 10:38:03 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~352 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a31c721ced404143e4f49e6c325f92148a6a0dc4;p=ghc-hetmet.git [project @ 2005-07-14 10:38:03 by simonmar] Fix mulMayOflo() on 64-bit archs. This fixes the arith003 failures on x86_64. --- diff --git a/ghc/includes/Stg.h b/ghc/includes/Stg.h index f11f452..9977d57 100644 --- a/ghc/includes/Stg.h +++ b/ghc/includes/Stg.h @@ -422,15 +422,16 @@ typedef union { #else -#define HALF_INT (((I_)1) << (BITS_IN (I_) / 2)) +/* Approximate version when we don't have long arithmetic (on 64-bit archs) */ -#define stg_abs(a) (((I_)(a)) < 0 ? -((I_)(a)) : ((I_)(a))) +#define HALF_POS_INT (((I_)1) << (BITS_IN (I_) / 2)) +#define HALF_NEG_INT (-HALF_POS_INT) #define mulIntMayOflo(a,b) \ ({ \ I_ c; \ - if (stg_abs(a) >= HALF_INT || \ - stg_abs(b) >= HALF_INT) { \ + if ((I_)a <= HALF_NEG_INT || a >= HALF_POS_INT \ + || (I_)b <= HALF_NEG_INT || b >= HALF_POS_INT) {\ c = 1; \ } else { \ c = 0; \