X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=includes%2FRtsAPI.h;h=1444dbc3c587b16ef4768f7cf09b43a0f78e001d;hp=a3a41f025f48ba026ad2167131a13317cd7da6d5;hb=52cba3c47b25a78402e542ff63dc905fc5b26b62;hpb=e7d4b777a1667ccd6912115d43272c3735316eea diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h index a3a41f0..1444dbc 100644 --- a/includes/RtsAPI.h +++ b/includes/RtsAPI.h @@ -4,6 +4,9 @@ * * API for invoking Haskell functions via the RTS * + * To understand the structure of the RTS headers, see the wiki: + * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes + * * --------------------------------------------------------------------------*/ #ifndef RTSAPI_H @@ -22,10 +25,11 @@ typedef enum { NoStatus, /* not finished yet */ Success, /* completed successfully */ Killed, /* uncaught exception */ - Interrupted /* stopped in response to a call to interruptStgRts */ + Interrupted, /* stopped in response to a call to interruptStgRts */ + HeapExhausted /* out of memory */ } SchedulerStatus; -typedef StgClosure *HaskellObj; +typedef struct StgClosure_ *HaskellObj; /* * An abstract type representing the token returned by rts_lock() and @@ -42,7 +46,16 @@ extern void shutdownHaskell ( void ); extern void shutdownHaskellAndExit ( int exitCode ); extern void getProgArgv ( int *argc, char **argv[] ); extern void setProgArgv ( int argc, char *argv[] ); +extern void getFullProgArgv ( int *argc, char **argv[] ); +extern void setFullProgArgv ( int argc, char *argv[] ); +extern void freeFullProgArgv ( void ) ; + +#ifndef mingw32_HOST_OS +extern void shutdownHaskellAndSignal (int sig); +#endif +/* exit() override */ +extern void (*exitFn)(int); /* ---------------------------------------------------------------------------- Locking. @@ -57,6 +70,15 @@ Capability *rts_lock (void); // releases the token acquired with rts_lock(). void rts_unlock (Capability *token); +// If you are in a context where you know you have a current capability but +// do not know what it is, then use this to get it. Basically this only +// applies to "unsafe" foreign calls (as unsafe foreign calls are made with +// the capability held). +// +// WARNING: There is *no* guarantee this returns anything sensible (eg NULL) +// when there is no current capability. +Capability *rts_unsafeGetMyCapability (void); + /* ---------------------------------------------------------------------------- Building Haskell objects from C datatypes. ------------------------------------------------------------------------- */ @@ -141,10 +163,22 @@ rts_getSchedStatus (Capability *cap); These are used by foreign export and foreign import "wrapper" stubs. ----------------------------------------------------------------------- */ +// When producing Windows DLLs the we need to know which symbols are in the +// local package/DLL vs external ones. +// +// Note that RtsAPI.h is also included by foreign export stubs in +// the base package itself. +// +#if defined(mingw32_HOST_OS) && defined(__PIC__) && !defined(COMPILING_BASE_PACKAGE) +__declspec(dllimport) extern StgWord base_GHCziTopHandler_runIO_closure[]; +__declspec(dllimport) extern StgWord base_GHCziTopHandler_runNonIO_closure[]; +#else extern StgWord base_GHCziTopHandler_runIO_closure[]; extern StgWord base_GHCziTopHandler_runNonIO_closure[]; -#define runIO_closure base_GHCziTopHandler_runIO_closure -#define runNonIO_closure base_GHCziTopHandler_runNonIO_closure +#endif + +#define runIO_closure base_GHCziTopHandler_runIO_closure +#define runNonIO_closure base_GHCziTopHandler_runNonIO_closure /* ------------------------------------------------------------------------ */