/* ---------------------------------------------------------------------------- * * (c) The GHC Team, 1998-2004 * * API for invoking Haskell functions via the RTS * * To understand the structure of the RTS headers, see the wiki: * https://gitlab.haskell.org/ghc/ghc/wikis/commentary/source-tree/includes * * --------------------------------------------------------------------------*/ #pragma once #if defined(__cplusplus) extern "C" { #endif #include "HsFFI.h" #include "rts/Time.h" #include "rts/EventLogWriter.h" /* * Running the scheduler */ typedef enum { NoStatus, /* not finished yet */ Success, /* completed successfully */ Killed, /* uncaught exception */ Interrupted, /* stopped in response to a call to interruptStgRts */ HeapExhausted /* out of memory */ } SchedulerStatus; typedef struct StgClosure_ *HaskellObj; /* * An abstract type representing the token returned by rts_lock() and * used when allocating objects and threads in the RTS. */ typedef struct Capability_ Capability; /* * The public view of a Capability: we can be sure it starts with * these two components (but it may have more private fields). */ typedef struct CapabilityPublic_ { StgFunTable f; StgRegTable r; } CapabilityPublic; /* ---------------------------------------------------------------------------- RTS configuration settings, for passing to hs_init_ghc() ------------------------------------------------------------------------- */ typedef enum { RtsOptsNone, // +RTS causes an error RtsOptsIgnore, // Ignore command line arguments RtsOptsIgnoreAll, // Ignore command line and Environment arguments RtsOptsSafeOnly, // safe RTS options allowed; others cause an error RtsOptsAll // all RTS options allowed } RtsOptsEnabledEnum; struct GCDetails_; // 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 { // Whether to interpret +RTS options on the command line RtsOptsEnabledEnum rts_opts_enabled; // Whether to give RTS flag suggestions HsBool rts_opts_suggestions; // additional RTS options const char *rts_opts; // True if GHC was not passed -no-hs-main HsBool rts_hs_main; // Whether to retain CAFs (default: false) HsBool keep_cafs; // Writer a for eventlog. const EventLogWriter *eventlog_writer; // Called before processing command-line flags, so that default // settings for RtsFlags can be provided. void (* defaultsHook) (void); // Called just before exiting void (* onExitHook) (void); // Called on a stack overflow, before exiting void (* stackOverflowHook) (W_ stack_size); // Called on heap overflow, before exiting void (* outOfHeapHook) (W_ request_size, W_ heap_size); // Called when malloc() fails, before exiting void (* mallocFailHook) (W_ request_size /* in bytes */, const char *msg); // Called for every GC void (* gcDoneHook) (const struct GCDetails_ *stats); // Called when GC sync takes too long (+RTS --long-gc-sync=