[project @ 2001-02-12 04:55:33 by chak]
[ghc-hetmet.git] / ghc / rts / PrimOps.hc
index 2d27886..711f538 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.64 2000/12/19 12:34:01 sewardj Exp $
+ * $Id: PrimOps.hc,v 1.71 2001/02/11 17:51:07 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
    classes CCallable and CReturnable don't really exist, but the
    compiler insists on generating dictionaries containing references
    to GHC_ZcCCallable_static_info etc., so we provide dummy symbols
-   for these.
+   for these.  Some C compilers can't cope with zero-length static arrays,
+   so we have to make these one element long.
 */
 
-W_ GHC_ZCCCallable_static_info[0];
-W_ GHC_ZCCReturnable_static_info[0];
-
-
+StgWord GHC_ZCCCallable_static_info[1];
+StgWord GHC_ZCCReturnable_static_info[1];
+  
 /* -----------------------------------------------------------------------------
    Macros for Hand-written primitives.
    -------------------------------------------------------------------------- */
@@ -944,13 +944,8 @@ FN_(putMVarzh_fast)
 #endif
 
   if (info == &stg_FULL_MVAR_info) {
-#ifdef INTERPRETER
-    fprintf(stderr, "fatal: put on a full MVar in Hugs; aborting\n" );
-    exit(1);
-#else
     R1.cl = (StgClosure *)PutFullMVar_closure;
     JMP_(raisezh_fast);
-#endif
   }
   
   mvar->value = R2.cl;
@@ -1032,16 +1027,36 @@ FN_(newBCOzh_fast)
   bco = (StgBCO *) (Hp + 1 - sizeofW(StgBCO));
   SET_HDR(bco, &stg_BCO_info, CCCS);
 
-  bco->instrs     = R1.cl;
-  bco->literals   = R2.cl;
-  bco->ptrs       = R3.cl;
-  bco->itbls      = R4.cl;
+  bco->instrs     = (StgArrWords*)R1.cl;
+  bco->literals   = (StgArrWords*)R2.cl;
+  bco->ptrs       = (StgMutArrPtrs*)R3.cl;
+  bco->itbls      = (StgArrWords*)R4.cl;
 
   TICK_RET_UNBOXED_TUP(1);
   RET_P(bco);
   FE_
 }
 
+FN_(mkApUpd0zh_fast)
+{
+  /* R1.p = the fn for the AP_UPD
+  */
+  StgAP_UPD* ap;
+  FB_
+  HP_CHK_GEN_TICKY(AP_sizeW(0), R1_PTR, mkApUpd0zh_fast,);
+  TICK_ALLOC_PRIM(sizeofW(StgHeader), AP_sizeW(0)-sizeofW(StgHeader), 0);
+  CCS_ALLOC(CCCS,AP_sizeW(0)); /* ccs prof */
+  ap = (StgAP_UPD *) (Hp + 1 - AP_sizeW(0));
+  SET_HDR(ap, &stg_AP_UPD_info, CCCS);
+
+  ap->n_args = 0;
+  ap->fun = R1.cl;
+
+  TICK_RET_UNBOXED_TUP(1);
+  RET_P(ap);
+  FE_
+}
+
 /* -----------------------------------------------------------------------------
    Thread I/O blocking primitives
    -------------------------------------------------------------------------- */
@@ -1085,7 +1100,7 @@ FN_(delayzh_fast)
 
     ACQUIRE_LOCK(&sched_mutex);
 
-    target = (R1.i / (TICK_MILLISECS*1000)) + timestamp + ticks_since_timestamp;
+    target = (R1.i / (TICK_MILLISECS*1000)) + getourtimeofday();
     CurrentTSO->block_info.target = target;
 
     /* Insert the new thread in the sleeping queue. */