[project @ 2001-11-08 16:17:35 by simonmar]
authorsimonmar <unknown>
Thu, 8 Nov 2001 16:17:35 +0000 (16:17 +0000)
committersimonmar <unknown>
Thu, 8 Nov 2001 16:17:35 +0000 (16:17 +0000)
Revert resumeThread and suspendThread to working with StgRegTable
rather than Capability, and do the conversion in the functions
themselves rather than in the inline code.  This means I don't have to
fiddle with the NCG to fix the SUSPEND_THREAD/RESUME_THREAD macros.

ghc/includes/StgMacros.h
ghc/rts/Schedule.c

index 6f35a55..5f28554 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgMacros.h,v 1.39 2001/11/08 12:46:31 simonmar Exp $
+ * $Id: StgMacros.h,v 1.40 2001/11/08 16:17:35 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -784,20 +784,17 @@ LoadThreadState (void)
  * Suspending/resuming threads for doing external C-calls (_ccall_GC).
  * These functions are defined in rts/Schedule.c.
  */
-StgInt       suspendThread ( Capability *cap );
-Capability * resumeThread  ( StgInt );
+StgInt        suspendThread ( StgRegTable * );
+StgRegTable * resumeThread  ( StgInt );
 
 #define SUSPEND_THREAD(token)                  \
    SaveThreadState();                          \
-   token = suspendThread((Capability *)((void *)BaseReg - sizeof(StgFunTable)));
+   token = suspendThread(BaseReg);
 
 #ifdef SMP
 #define RESUME_THREAD(token)                   \
-  { Capability c;                              \
-    c = resumeThread(token);                   \
-    BaseReg = &c.r;                            \
+    BaseReg = resumeThread(token);             \
     LoadThreadState();                         \
-  }
 #else
 #define RESUME_THREAD(token)                   \
    (void)resumeThread(token);                  \
index 3371bad..ec0ac22 100644 (file)
@@ -1,5 +1,5 @@
 /* ---------------------------------------------------------------------------
- * $Id: Schedule.c,v 1.105 2001/11/08 12:46:31 simonmar Exp $
+ * $Id: Schedule.c,v 1.106 2001/11/08 16:17:35 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -1356,9 +1356,13 @@ void deleteAllThreads ( void )
  * ------------------------------------------------------------------------- */
    
 StgInt
-suspendThread( Capability *cap )
+suspendThread( StgRegTable *reg )
 {
   nat tok;
+  Capability *cap;
+
+  // assume that *reg is a pointer to the StgRegTable part of a Capability
+  cap = (Capability *)((void *)reg - sizeof(StgFunTable));
 
   ACQUIRE_LOCK(&sched_mutex);
 
@@ -1382,7 +1386,7 @@ suspendThread( Capability *cap )
   return tok; 
 }
 
-Capability *
+StgRegTable *
 resumeThread( StgInt tok )
 {
   StgTSO *tso, **prev;
@@ -1420,7 +1424,7 @@ resumeThread( StgInt tok )
   cap->r.rCurrentTSO = tso;
 
   RELEASE_LOCK(&sched_mutex);
-  return cap;
+  return &cap->r;
 }