X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStg.h;h=a63b7ec2d6f43d980375f2fd9b90c9238c7a3620;hb=e6218fe7eff4e34e1a3c823cd4b7aebe09d2d4fb;hp=1189b0e99b834f69b833d5a34fd51d0e34ce4db1;hpb=153b9cb9b11e05c4edb1b6bc0a7b972660e41f70;p=ghc-hetmet.git diff --git a/ghc/includes/Stg.h b/ghc/includes/Stg.h index 1189b0e..a63b7ec 100644 --- a/ghc/includes/Stg.h +++ b/ghc/includes/Stg.h @@ -1,5 +1,4 @@ /* ----------------------------------------------------------------------------- - * $Id: Stg.h,v 1.66 2005/01/28 12:55:52 simonmar Exp $ * * (c) The GHC Team, 1998-2004 * @@ -81,6 +80,23 @@ # error "Don't know how to inline functions with your C compiler." #endif +/* + * GCC attributes + */ +#if defined(__GNUC__) +#define GNU_ATTRIBUTE(at) __attribute__((at)) +#else +#define GNU_ATTRIBUTE(at) +#endif + +#if __GNUC__ >= 3 +#define GNUC3_ATTRIBUTE(at) __attribute__((at)) +#else +#define GNUC3_ATTRIBUTE(at) +#endif + +#define STG_UNUSED GNUC3_ATTRIBUTE(__unused__) + /* ----------------------------------------------------------------------------- Global type definitions -------------------------------------------------------------------------- */ @@ -106,7 +122,7 @@ typedef StgClosurePtr L_; typedef StgInt64 LI_; typedef StgWord64 LW_; -#define IF_(f) static F_ f(void) +#define IF_(f) static F_ GNUC3_ATTRIBUTE(used) f(void) #define FN_(f) F_ f(void) #define EF_(f) extern F_ f(void) @@ -351,6 +367,24 @@ INLINE_HEADER StgInt64 PK_Int64(W_ p_src[]) #endif /* ----------------------------------------------------------------------------- + Write-combining store + -------------------------------------------------------------------------- */ + +INLINE_HEADER void +wcStore (StgPtr p, StgWord w) +{ +#ifdef x86_64_HOST_ARCH + __asm__( + "movnti\t%1, %0" + : "=m" (*p) + : "r" (w) + ); +#else + *p = w; +#endif +} + +/* ----------------------------------------------------------------------------- Integer multiply with overflow -------------------------------------------------------------------------- */ @@ -406,15 +440,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; \