[project @ 2001-08-08 10:50:36 by simonmar]
[ghc-hetmet.git] / ghc / includes / PrimOps.h
index f49253a..a33db9c 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.h,v 1.76 2001/03/22 03:51:09 hwloidl Exp $
+ * $Id: PrimOps.h,v 1.80 2001/08/08 10:50:37 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -99,8 +99,8 @@
  * plugging into a new J#.  
  */
 #define addIntCzh(r,c,a,b)                     \
-{ r = a + b;                                   \
-  c = ((StgWord)(~(a^b) & (a^r)))              \
+{ r = (I_)a + (I_)b;                           \
+  c = ((StgWord)(~((I_)a^(I_)b) & ((I_)a^r)))  \
     >> (BITS_IN (I_) - 1);                     \
 }
 
@@ -171,13 +171,13 @@ typedef union {
 
 #else
 
-#define HALF_INT  (1 << (BITS_IN (I_) / 2))
+#define HALF_INT  (1LL << (BITS_IN (I_) / 2))
 
 #define stg_abs(a) ((a) < 0 ? -(a) : (a))
 
 #define mulIntCzh(r,c,a,b)                     \
 {                                              \
-  if (stg_abs(a) >= HALF_INT                   \
+  if (stg_abs(a) >= HALF_INT ||                        \
       stg_abs(b) >= HALF_INT) {                        \
     c = 1;                                     \
   } else {                                     \
@@ -664,8 +664,13 @@ EXTFUN_RTS(unsafeThawArrayzh_fast);
 /* and the out-of-line ones... */
 
 EXTFUN_RTS(newByteArrayzh_fast);
+EXTFUN_RTS(newPinnedByteArrayzh_fast);
 EXTFUN_RTS(newArrayzh_fast);
 
+// Highly unsafe, for use with a pinned ByteArray 
+// being kept alive with touch# 
+#define byteArrayContentszh(r,a) r = BYTE_ARR_CTS(a)
+
 /* encoding and decoding of floats/doubles. */
 
 /* We only support IEEE floating point format */
@@ -912,8 +917,7 @@ EXTFUN_RTS(mkForeignObjzh_fast);
 #define writeForeignObjzh(res,datum) \
    (ForeignObj_CLOSURE_DATA(res) = (P_)(datum))
 
-#define eqForeignObj(f1,f2)  ((f1)==(f2))
-
+#define eqForeignObjzh(r,f1,f2)                 r=(f1)==(f2)
 #define indexCharOffForeignObjzh(r,fo,i)       indexCharOffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
 #define indexWideCharOffForeignObjzh(r,fo,i)   indexWideCharOffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)
 #define indexIntOffForeignObjzh(r,fo,i)                indexIntOffAddrzh(r,ForeignObj_CLOSURE_DATA(fo),i)