1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2004
5 * Things visible externally to the RTS
7 * -------------------------------------------------------------------------- */
12 /* The RTS public interface. */
15 /* The standard FFI interface */
18 #ifdef HAVE_SYS_TYPES_H
19 #include <sys/types.h>
22 /* -----------------------------------------------------------------------------
23 Functions exported by the RTS for use in Stg code
24 -------------------------------------------------------------------------- */
27 extern void newCAF(void*);
29 extern void newCAF(StgClosure*);
33 extern HsInt genSymZh(void);
34 extern HsInt resetGenSymZh(void);
36 /* Alternate to raise(3) for threaded rts, for OpenBSD */
37 extern int genericRaise(int sig);
39 /* Concurrency/Exception PrimOps. */
40 extern int cmp_thread(StgPtr tso1, StgPtr tso2);
41 extern int rts_getThreadId(StgPtr tso);
42 extern int forkOS_createThread ( HsStablePtr entry );
43 extern pid_t forkProcess(HsStablePtr *entry);
44 extern HsBool rtsSupportsBoundThreads(void);
45 extern StgInt newSpark (StgRegTable *reg, StgClosure *p);
46 extern void stopTimer(void);
47 extern unsigned int n_capabilities;
49 /* grimy low-level support functions defined in StgPrimFloat.c */
50 extern StgDouble __encodeDouble (I_ size, StgByteArray arr, I_ e);
51 extern StgDouble __2Int_encodeDouble (I_ j_high, I_ j_low, I_ e);
52 extern StgDouble __int_encodeDouble (I_ j, I_ e);
53 extern StgDouble __word_encodeDouble (W_ j, I_ e);
54 extern StgFloat __encodeFloat (I_ size, StgByteArray arr, I_ e);
55 extern StgFloat __int_encodeFloat (I_ j, I_ e);
56 extern StgFloat __word_encodeFloat (W_ j, I_ e);
57 extern StgInt isDoubleNaN(StgDouble d);
58 extern StgInt isDoubleInfinite(StgDouble d);
59 extern StgInt isDoubleDenormalized(StgDouble d);
60 extern StgInt isDoubleNegativeZero(StgDouble d);
61 extern StgInt isFloatNaN(StgFloat f);
62 extern StgInt isFloatInfinite(StgFloat f);
63 extern StgInt isFloatDenormalized(StgFloat f);
64 extern StgInt isFloatNegativeZero(StgFloat f);
66 /* Suspending/resuming threads around foreign calls */
67 extern void * suspendThread ( StgRegTable * );
68 extern StgRegTable * resumeThread ( void * );
71 extern void stg_scheduleThread (StgRegTable *reg, struct StgTSO_ *tso);
73 /* Creating and destroying an adjustor thunk */
74 extern void* createAdjustor(int cconv, StgStablePtr hptr, StgFunPtr wptr,
76 extern void freeHaskellFunctionPtr(void* ptr);
79 extern int hs_hpc_module(char *modName, StgWord32 modCount, StgWord32 modHashNo,StgWord64 *tixArr);
80 // Simple linked list of modules
81 typedef struct _HpcModuleInfo {
82 char *modName; // name of module
83 StgWord32 tickCount; // number of ticks
84 StgWord32 tickOffset; // offset into a single large .tix Array
85 StgWord32 hashNo; // Hash number for this module's mix info
86 StgWord64 *tixArr; // tix Array; local for this module
87 struct _HpcModuleInfo *next;
90 extern HpcModuleInfo *hs_hpc_rootModule(void);
93 #if defined(mingw32_HOST_OS)
94 extern int rts_InstallConsoleEvent ( int action, StgStablePtr *handler );
95 extern void rts_ConsoleHandlerDone ( int ev );
97 extern int stg_sig_install (int, int, StgStablePtr *, void *);
100 #if defined(mingw32_HOST_OS)
101 extern StgInt console_handler;
103 extern StgInt *signal_handlers;
106 #if defined(mingw32_HOST_OS)
107 void *getIOManagerEvent (void);
108 HsWord32 readIOManagerEvent (void);
109 void sendIOManagerEvent (HsWord32 event);
111 extern void setIOManagerPipe (int fd);
114 extern void* allocateExec(unsigned int len);
118 /* -----------------------------------------------------------------------------
119 Storage manager stuff exported
120 -------------------------------------------------------------------------- */
122 extern void performGC(void);
123 extern void performMajorGC(void);
124 extern HsInt64 getAllocations( void );
125 extern void revertCAFs( void );
126 extern void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p);
127 extern void dirty_MVAR(StgRegTable *reg, StgClosure *p);
129 extern void dirty_TSO(StgClosure *tso);
131 #endif /* RTSEXTERNAL_H */