[project @ 2000-09-26 16:45:33 by simonpj]
[ghc-hetmet.git] / ghc / rts / PrimOps.hc
index 015e34a..f5c45f3 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: PrimOps.hc,v 1.53 2000/08/07 23:37:23 qrczak Exp $
+ * $Id: PrimOps.hc,v 1.55 2000/09/26 16:45:35 simonpj Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -504,30 +504,6 @@ FN_(word2Integerzh_fast)
    FE_
 }
 
-FN_(addr2Integerzh_fast)
-{
-  MP_INT result;
-  char *str;
-  FB_
-
-  MAYBE_GC(NO_PTRS,addr2Integerzh_fast);
-
-  /* args:   R1 :: Addr# */
-  str = R1.a;
-
-  /* Perform the operation */
-  if (RET_STGCALL3(int, mpz_init_set_str,&result,(str),/*base*/10))
-      abort();
-
-   /* returns (# size  :: Int#, 
-                data  :: ByteArray# 
-              #)
-   */
-  TICK_RET_UNBOXED_TUP(2);
-  RET_NP(result._mp_size, 
-         result._mp_d - sizeofW(StgArrWords));
-  FE_
-}
 
 /*
  * 'long long' primops for converting to/from Integers.
@@ -1049,6 +1025,8 @@ FN_(waitWritezh_fast)
 
 FN_(delayzh_fast)
 {
+  StgTSO *t, *prev;
+  nat target;
   FB_
     /* args: R1.i */
     ASSERT(CurrentTSO->why_blocked == NotBlocked);
@@ -1056,20 +1034,26 @@ FN_(delayzh_fast)
 
     ACQUIRE_LOCK(&sched_mutex);
 
-    /* Add on ticks_since_select, since these will be subtracted at
-     * the next awaitEvent call.
-     */
-#if defined(HAVE_SETITIMER) || defined(mingw32_TARGET_OS)
-    CurrentTSO->block_info.delay = R1.i + ticks_since_select;
-#else
-    CurrentTSO->block_info.target = R1.i + getourtimeofday();
-#endif
+    target = (R1.i / (TICK_MILLISECS*1000)) + timestamp + ticks_since_timestamp;
+    CurrentTSO->block_info.target = target;
 
-    APPEND_TO_BLOCKED_QUEUE(CurrentTSO);
+    /* Insert the new thread in the sleeping queue. */
+    prev = NULL;
+    t = sleeping_queue;
+    while (t != END_TSO_QUEUE && t->block_info.target < target) {
+       prev = t;
+       t = t->link;
+    }
+
+    CurrentTSO->link = t;
+    if (prev == NULL) {
+       sleeping_queue = CurrentTSO;
+    } else {
+       prev->link = CurrentTSO;
+    }
 
     RELEASE_LOCK(&sched_mutex);
     JMP_(stg_block_noregs);
   FE_
 }
 
-