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 ); ...@@ -43,6 +43,8 @@ extern void shutdownHaskellAndExit ( int exitCode );
extern void getProgArgv ( int *argc, char **argv[] ); extern void getProgArgv ( int *argc, char **argv[] );
extern void setProgArgv ( int argc, char *argv[] ); extern void setProgArgv ( int argc, char *argv[] );
/* exit() override */
extern void (*exitFn)(int);
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
Locking. Locking.
......
...@@ -459,6 +459,8 @@ shutdownHaskellAndExit(int n) ...@@ -459,6 +459,8 @@ shutdownHaskellAndExit(int n)
static int exit_started=rtsFalse; static int exit_started=rtsFalse;
#endif #endif
void (*exitFn)(int) = 0;
void void
stg_exit(int n) stg_exit(int n)
{ {
...@@ -471,5 +473,7 @@ stg_exit(int n) ...@@ -471,5 +473,7 @@ stg_exit(int n)
IF_PAR_DEBUG(verbose, debugBelch("==-- stg_exit %d on [%x]...", n, mytid)); IF_PAR_DEBUG(verbose, debugBelch("==-- stg_exit %d on [%x]...", n, mytid));
shutdownParallelSystem(n); shutdownParallelSystem(n);
#endif #endif
if (exitFn)
(*exitFn)(n);
exit(n); exit(n);
} }
...@@ -127,7 +127,7 @@ initStorage( void ) ...@@ -127,7 +127,7 @@ initStorage( void )
RtsFlags.GcFlags.minAllocAreaSize > RtsFlags.GcFlags.minAllocAreaSize >
RtsFlags.GcFlags.maxHeapSize) { RtsFlags.GcFlags.maxHeapSize) {
errorBelch("maximum heap size (-M) is smaller than minimum alloc area size (-A)"); errorBelch("maximum heap size (-M) is smaller than minimum alloc area size (-A)");
exit(1); RtsFlags.GcFlags.minAllocAreaSize = RtsFlags.GcFlags.maxHeapSize;
} }
initBlockAllocator(); 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