[project @ 1999-11-05 12:28:05 by simonmar]
authorsimonmar <unknown>
Fri, 5 Nov 1999 12:28:06 +0000 (12:28 +0000)
committersimonmar <unknown>
Fri, 5 Nov 1999 12:28:06 +0000 (12:28 +0000)
_ccall_GC wibbles

ghc/compiler/absCSyn/PprAbsC.lhs
ghc/includes/Stg.h
ghc/includes/StgMacros.h

index ae61d06..197bee5 100644 (file)
@@ -787,8 +787,8 @@ pprCCall op@(CCallOp op_str is_asm may_gc cconv) args results vol_regs
   where
     (pp_saves, pp_restores) = ppr_vol_regs vol_regs
     (pp_save_context, pp_restore_context)
-       | may_gc  = ( text "do { I_ id; SaveThreadState(); id = suspendThread(BaseReg);"
-                   , text "BaseReg = resumeThread(id); LoadThreadState();} while(0);"
+       | may_gc  = ( text "{ I_ id; SUSPEND_THREAD(id);"
+                   , text "RESUME_THREAD(id);}"
                    )
        | otherwise = ( pp_basic_saves $$ pp_saves,
                        pp_basic_restores $$ pp_restores)
index 756e8fb..19c3711 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Stg.h,v 1.18 1999/11/02 15:05:52 simonmar Exp $
+ * $Id: Stg.h,v 1.19 1999/11/05 12:28:05 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
  * be in vanilla C.
  */
 #ifdef NOT_IN_STG_CODE
-#define NO_REGS                        /* don't define fixed registers */
+# ifndef NO_REGS
+#  define NO_REGS                      /* don't define fixed registers */
+# endif
 #else
-#define IN_STG_CODE
+# define IN_STG_CODE
 #endif
 
 /* Configuration */
index 2d46443..8ca1f91 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgMacros.h,v 1.15 1999/11/02 17:04:28 simonmar Exp $
+ * $Id: StgMacros.h,v 1.16 1999/11/05 12:28:05 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -412,6 +412,7 @@ EDI_(stg_gen_chk_info);
    Misc
    -------------------------------------------------------------------------- */
 
+
 /* set the tag register (if we have one) */
 #define SET_TAG(t)  /* nothing */
 
@@ -660,7 +661,7 @@ extern DLL_IMPORT_DATA const StgPolyInfoTable seq_frame_info;
    we have one).
    -------------------------------------------------------------------------- */
 
-#ifndef NO_REGS
+#ifdef IN_STG_CODE
 
 static __inline__ void
 SaveThreadState(void)
@@ -702,7 +703,11 @@ LoadThreadState (void)
 # endif
 }
 
-#endif /* NO_REGS */
+#endif
+
+/* -----------------------------------------------------------------------------
+   Support for _ccall_GC_ and _casm_GC.
+   -------------------------------------------------------------------------- */
 
 /* 
  * Suspending/resuming threads for doing external C-calls (_ccall_GC).
@@ -711,5 +716,19 @@ LoadThreadState (void)
 StgInt        suspendThread ( StgRegTable *cap );
 StgRegTable * resumeThread  ( StgInt );
 
+#define SUSPEND_THREAD(token)                  \
+   SaveThreadState();                          \
+   token = suspendThread(BaseReg);
+
+#ifdef SMP
+#define RESUME_THREAD(token)                   \
+   BaseReg = resumeThread(token);              \
+   LoadThreadState();
+#else
+#define RESUME_THREAD(token)                   \
+   (void)resumeThread(token);                  \
+   LoadThreadState();
+#endif
+
 #endif /* STGMACROS_H */