Finish stable split
[ghc.git] / rts / HsFFI.c
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2005
4 *
5 * RTS entry points as mandated by the FFI section of the Haskell report
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #include "PosixSource.h"
10 #include "HsFFI.h"
11 #include "Rts.h"
12
13 #include "StablePtr.h"
14 #include "Task.h"
15
16 // hs_init and hs_exit are defined in RtsStartup.c
17
18 void
19 hs_set_argv(int argc, char *argv[])
20 {
21 setProgArgv(argc,argv);
22 }
23
24 void
25 hs_perform_gc(void)
26 {
27 /* Hmmm, the FFI spec is a bit vague, but it seems to imply a major GC... */
28 performMajorGC();
29 }
30
31 // Lock the stable pointer table
32 void hs_lock_stable_ptr_table (void)
33 {
34 stablePtrLock();
35 }
36
37 // Deprecated version of hs_lock_stable_ptr_table
38 void hs_lock_stable_tables (void)
39 {
40 stablePtrLock();
41 }
42
43 // Unlock the stable pointer table
44 void hs_unlock_stable_ptr_table (void)
45 {
46 stablePtrUnlock();
47 }
48
49 // Deprecated version of hs_unlock_stable_ptr_table
50 void hs_unlock_stable_tables (void)
51 {
52 stablePtrUnlock();
53 }
54
55 void
56 hs_free_stable_ptr(HsStablePtr sp)
57 {
58 /* The cast is for clarity only, both HsStablePtr and StgStablePtr are
59 typedefs for void*. */
60 freeStablePtr((StgStablePtr)sp);
61 }
62
63 void
64 hs_free_stable_ptr_unsafe(HsStablePtr sp)
65 {
66 /* The cast is for clarity only, both HsStablePtr and StgStablePtr are
67 typedefs for void*. */
68 freeStablePtrUnsafe((StgStablePtr)sp);
69 }
70
71 void
72 hs_free_fun_ptr(HsFunPtr fp)
73 {
74 /* I simply *love* all these similar names... */
75 freeHaskellFunctionPtr(fp);
76 }
77
78 void
79 hs_thread_done(void)
80 {
81 freeMyTask();
82 }