[project @ 1999-05-10 09:50:49 by simonm]
[ghc-hetmet.git] / ghc / includes / PrimOps.h
index a18ab8e..87630c4 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.h,v 1.25 1999/04/23 13:54:12 simonm Exp $
+ * $Id: PrimOps.h,v 1.30 1999/05/10 09:50:49 simonm Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -58,9 +58,6 @@
 #define zlzhzh(r,a,b)  r=(I_)((a) <(b))
 #define zlzezhzh(r,a,b)        r=(I_)((a)<=(b))
 
-/*  used by returning comparison primops, defined in Prims.hc. */
-extern DLL_IMPORT_RTS const StgClosure *PrelBase_Bool_closure_tbl[];
-
 /* -----------------------------------------------------------------------------
    Char# PrimOps.
    -------------------------------------------------------------------------- */
@@ -306,16 +303,20 @@ typedef union {
 
 /* We can do integer2Int and cmpInteger inline, since they don't need
  * to allocate any memory.
+ *
+ * integer2Int# is now modular.
  */
 
-#define integer2Intzh(r, sa,da)                                        \
-{ MP_INT arg;                                                  \
-                                                               \
-  arg._mp_size = (sa);                                         \
-  arg._mp_alloc        = ((StgArrWords *)da)->words;                   \
-  arg._mp_d    = (unsigned long int *) (BYTE_ARR_CTS(da));     \
-                                                               \
-  (r) = RET_PRIM_STGCALL1(I_,mpz_get_si,&arg);                 \
+#define integer2Intzh(r, sa,da)                                \
+{ StgWord word0 = ((StgWord *)BYTE_ARR_CTS(da))[0];    \
+  int size = sa;                                       \
+                                                       \
+  (r) =                                                        \
+    ( size == 0 ) ?                                    \
+       0 :                                             \
+       ( size < 0 && word0 != 0x8000000 ) ?            \
+         -(I_)word0 :                                  \
+         (I_)word0;                                    \
 }
 
 #define integer2Wordzh(r, sa,da)                               \