[project @ 1997-12-16 12:19:08 by simonm]
[ghc-hetmet.git] / ghc / includes / COptWraps.lh
index 27c862f..96f84bc 100644 (file)
@@ -232,7 +232,8 @@ in the end.
 
 Getting this right requires three extremely @MAGIC@ macros, no doubt
 chock full of assembly gook for the current platform.  These are
-@MAGIC_CALL_SETUP@, which gets ready for one of these magic calls,
+@MAGIC_CALL_SET
+UP@, which gets ready for one of these magic calls,
 @MAGIC_CALL@, which performs the call and stashes away all possible
 results, and @MAGIC_RETURN@, which collects all possible results back
 up again.
@@ -540,6 +541,13 @@ gets whatever it's after.
 
 #define WRAPPER_NAME(f)          /* nothing */
 
+/* 
+   Threaded code needs to be able to grab the return address, in case we have
+   an intervening context switch.
+ */
+
+#define SET_RETADDR(loc)  { register StgFunPtrFunPtr ra __asm__ ("$31"); loc = ra; }
+
 #define WRAPPER_SETUP(f,ignore1,ignore2)  SaveAllStgContext();
 
 #define WRAPPER_RETURN(x)  \
@@ -576,6 +584,13 @@ gets whatever it's after.
 
 #define WRAPPER_NAME(f)          /* nothing */
 
+#define SET_RETADDR(loc)       \
+    __asm__ volatile (         \
+       "mflr 0\n"              \
+       "\tst 0,%0"             \
+       :"=m" (loc) :: "0");
+/*    __asm__ volatile ("st %%r0, %0" : "=m" ((void *)(loc))); */
+
 #define WRAPPER_SETUP(f,ignore1,ignore2)  SaveAllStgContext();
 
 /* we have to make sure the STG registers are restored.