From c094c3adb595d0f6fd881c6d7502291df4728cd8 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 8 Nov 2001 16:17:35 +0000 Subject: [PATCH] [project @ 2001-11-08 16:17:35 by simonmar] 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 | 13 +++++-------- ghc/rts/Schedule.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/ghc/includes/StgMacros.h b/ghc/includes/StgMacros.h index 6f35a55..5f28554 100644 --- a/ghc/includes/StgMacros.h +++ b/ghc/includes/StgMacros.h @@ -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); \ diff --git a/ghc/rts/Schedule.c b/ghc/rts/Schedule.c index 3371bad..ec0ac22 100644 --- a/ghc/rts/Schedule.c +++ b/ghc/rts/Schedule.c @@ -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; } -- 1.7.10.4