Commit 7b1b3279 authored by Simon Marlow's avatar Simon Marlow
Browse files

make exit() overridable, for use in DLLs

See #753
parent 444006bc
......@@ -43,6 +43,8 @@ extern void shutdownHaskellAndExit ( int exitCode );
extern void getProgArgv ( int *argc, char **argv[] );
extern void setProgArgv ( int argc, char *argv[] );
/* exit() override */
extern void (*exitFn)(int);
/* ----------------------------------------------------------------------------
Locking.
......
......@@ -459,6 +459,8 @@ shutdownHaskellAndExit(int n)
static int exit_started=rtsFalse;
#endif
void (*exitFn)(int) = 0;
void
stg_exit(int n)
{
......@@ -471,5 +473,7 @@ stg_exit(int n)
IF_PAR_DEBUG(verbose, debugBelch("==-- stg_exit %d on [%x]...", n, mytid));
shutdownParallelSystem(n);
#endif
if (exitFn)
(*exitFn)(n);
exit(n);
}
......@@ -127,7 +127,7 @@ initStorage( void )
RtsFlags.GcFlags.minAllocAreaSize >
RtsFlags.GcFlags.maxHeapSize) {
errorBelch("maximum heap size (-M) is smaller than minimum alloc area size (-A)");
exit(1);
RtsFlags.GcFlags.minAllocAreaSize = RtsFlags.GcFlags.maxHeapSize;
}
initBlockAllocator();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment