[project @ 2002-11-17 15:27:07 by panne]
authorpanne <unknown>
Sun, 17 Nov 2002 15:27:08 +0000 (15:27 +0000)
committerpanne <unknown>
Sun, 17 Nov 2002 15:27:08 +0000 (15:27 +0000)
Added RTS entry points as mandated by the FFI addendum to the Haskell
98 report. NOTE: The implementations of hs_init, hs_exit, and
hs_set_argv are still missing.

ghc/includes/HsFFI.h
ghc/rts/HsFFI.c [new file with mode: 0644]

index 7164007..7010aa1 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: HsFFI.h,v 1.16 2001/11/07 19:11:43 sof Exp $
+ * $Id: HsFFI.h,v 1.17 2002/11/17 15:27:07 panne Exp $
  *
  * (c) The GHC Team, 2000
  *
@@ -148,6 +148,15 @@ typedef void*                      HsForeignObj;   /* DEPRECATED */
 #define HS_DOUBLE_MAX_EXP      DBL_MAX_EXP
 #define HS_DOUBLE_MAX_10_EXP   DBL_MAX_10_EXP
 
+extern void hs_init     (int *argc, char **argv[]);
+extern void hs_exit     (void);
+extern void hs_set_argv (int argc, char *argv[]);
+
+extern void hs_perform_gc (void);
+
+extern void hs_free_stable_ptr (HsStablePtr *sp);
+extern void hs_free_fun_ptr    (HsFunPtr *fp);
+
 /* -------------------------------------------------------------------------- */
 
 #ifdef __cplusplus
diff --git a/ghc/rts/HsFFI.c b/ghc/rts/HsFFI.c
new file mode 100644 (file)
index 0000000..47a0495
--- /dev/null
@@ -0,0 +1,51 @@
+/* -----------------------------------------------------------------------------
+ * $Id: HsFFI.c,v 1.1 2002/11/17 15:27:08 panne Exp $
+ *
+ * (c) The GHC Team, 2002
+ *
+ * RTS entry points as mandated by the FFI addendum to the Haskell 98 report
+ *
+ * ---------------------------------------------------------------------------*/
+
+#include "HsFFI.h"
+#include "Rts.h"
+
+void
+hs_init(int *argc, char **argv[])
+{
+  /* ToDo: Implement! */
+}
+
+void
+hs_exit(void)
+{
+  /* ToDo: Implement! */
+}
+
+void
+hs_set_argv(int argc, char *argv[])
+{
+  /* ToDo: Implement! */
+}
+
+void
+hs_perform_gc(void)
+{
+    /* Hmmm, the FFI spec is a bit vague, but it seems to imply a major GC... */
+    performMajorGC();
+}
+
+void
+hs_free_stable_ptr(HsStablePtr *sp)
+{
+    /* The cast is for clarity only, both HsStablePtr and StgStablePtr are
+       typedefs for void*. */
+    freeStablePtr((StgStablePtr)sp);
+}
+
+void
+hs_free_fun_ptr(HsFunPtr *fp)
+{
+    /* I simply *love* all these similar names... */
+    freeHaskellFunctionPtr(fp);
+}