diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Rts.h | 1 | ||||
-rw-r--r-- | includes/RtsAPI.h | 48 | ||||
-rw-r--r-- | includes/RtsOpts.h | 20 | ||||
-rw-r--r-- | includes/rts/Main.h | 21 |
4 files changed, 65 insertions, 25 deletions
diff --git a/includes/Rts.h b/includes/Rts.h index 91ec76d467..5caba59dbe 100644 --- a/includes/Rts.h +++ b/includes/Rts.h @@ -213,6 +213,7 @@ void _assertFail(const char *filename, unsigned int linenum) #include "rts/TTY.h" #include "rts/Utils.h" #include "rts/PrimFloat.h" +#include "rts/Main.h" /* Misc stuff without a home */ DLL_IMPORT_RTS extern char **prog_argv; /* so we can get at these from Haskell */ diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h index dc151faf07..329b1569ab 100644 --- a/includes/RtsAPI.h +++ b/includes/RtsAPI.h @@ -38,26 +38,64 @@ typedef struct StgClosure_ *HaskellObj; typedef struct Capability_ Capability; /* ---------------------------------------------------------------------------- + RTS configuration settings, for passing to hs_init_ghc() + ------------------------------------------------------------------------- */ + +typedef enum { + RtsOptsNone, // +RTS causes an error + RtsOptsSafeOnly, // safe RTS options allowed; others cause an error + RtsOptsAll // all RTS options allowed + } RtsOptsEnabledEnum; + +// The RtsConfig struct is passed (by value) to hs_init_ghc(). The +// reason for using a struct is extensibility: we can add more +// fields to this later without breaking existing client code. +typedef struct { + RtsOptsEnabledEnum rts_opts_enabled; + const char *rts_opts; +} RtsConfig; + +// Clients should start with defaultRtsConfig and then customise it. +// Bah, I really wanted this to be a const struct value, but it seems +// you can't do that in C (it generates code). +extern const RtsConfig defaultRtsConfig; + +/* ---------------------------------------------------------------------------- Starting up and shutting down the Haskell RTS. ------------------------------------------------------------------------- */ -extern void startupHaskell ( int argc, char *argv[], + +/* DEPRECATED, use hs_init() or hs_init_ghc() instead */ +extern void startupHaskell ( int argc, char *argv[], void (*init_root)(void) ); + +/* DEPRECATED, use hs_exit() instead */ extern void shutdownHaskell ( void ); + +/* + * GHC-specific version of hs_init() that allows specifying whether + * +RTS ... -RTS options are allowed or not (default: only "safe" + * options are allowed), and allows passing an option string that is + * to be interpreted by the RTS only, not passed to the program. + */ +extern void hs_init_ghc (int *argc, char **argv[], // program arguments + RtsConfig rts_config); // RTS configuration + extern void shutdownHaskellAndExit ( int exitCode ) #if __GNUC__ >= 3 __attribute__((__noreturn__)) #endif ; + +#ifndef mingw32_HOST_OS +extern void shutdownHaskellAndSignal (int sig); +#endif + 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); diff --git a/includes/RtsOpts.h b/includes/RtsOpts.h deleted file mode 100644 index b8eab68d3b..0000000000 --- a/includes/RtsOpts.h +++ /dev/null @@ -1,20 +0,0 @@ -/* ----------------------------------------------------------------------------- - * - * (c) The GHC Team, 2010 - * - * En/disable RTS options - * - * ---------------------------------------------------------------------------*/ - -#ifndef RTSOPTS_H -#define RTSOPTS_H - -typedef enum { - RtsOptsNone, // +RTS causes an error - RtsOptsSafeOnly, // safe RTS options allowed; others cause an error - RtsOptsAll // all RTS options allowed - } RtsOptsEnabledEnum; - -extern const RtsOptsEnabledEnum rtsOptsEnabled; - -#endif /* RTSOPTS_H */ diff --git a/includes/rts/Main.h b/includes/rts/Main.h new file mode 100644 index 0000000000..1c332fc95c --- /dev/null +++ b/includes/rts/Main.h @@ -0,0 +1,21 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team, 2009 + * + * Entry point for standalone Haskell programs. + * + * ---------------------------------------------------------------------------*/ + +#ifndef RTSMAIN_H +#define RTSMAIN_H + +/* ----------------------------------------------------------------------------- + * The entry point for Haskell programs that use a Haskell main function + * -------------------------------------------------------------------------- */ + +int hs_main (int argc, char *argv[], // program args + StgClosure *main_closure, // closure for Main.main + RtsConfig rts_config) // RTS configuration + GNUC3_ATTRIBUTE(__noreturn__); + +#endif /* RTSMAIN_H */ |