Ticket #753: changes-exit

File changes-exit, 2.1 KB (added by guest, 9 years ago)

Patch to avoid exit() calls in DLL.

Line 
1diff -rc src-ref/ghc-6.4.2.20060411/ghc/includes/RtsAPI.h src-with-old-ghc/ghc-6.4.2.20060411/ghc/includes/RtsAPI.h
2*** src-ref/ghc-6.4.2.20060411/ghc/includes/RtsAPI.h Fri Aug 13 09:09:28 2004
3--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/includes/RtsAPI.h Fri Apr 21 10:38:30 2006
4***************
5*** 37,42 ****
6--- 37,44 ----
7  extern void getProgArgv            ( int *argc, char **argv[] );
8  extern void setProgArgv            ( int argc, char *argv[] );
9 
10+ /* exit() override */
11+ extern void (*exitFn)(int);
12 
13  /* ----------------------------------------------------------------------------
14     Locking.
15diff -rc src-ref/ghc-6.4.2.20060411/ghc/rts/RtsStartup.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/RtsStartup.c
16*** src-ref/ghc-6.4.2.20060411/ghc/rts/RtsStartup.c Wed Apr  5 10:59:19 2006
17--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/RtsStartup.c Thu May 25 12:30:09 2006
18***************
19*** 443,448 ****
20--- 452,459 ----
21  static int exit_started=rtsFalse;
22  #endif
23 
24+ void (*exitFn)(int) = 0;
25+
26  void 
27  stg_exit(int n)
28  {
29***************
30*** 455,459 ****
31--- 466,472 ----
32    IF_PAR_DEBUG(verbose, debugBelch("==-- stg_exit %d on [%x]...", n, mytid));
33    shutdownParallelSystem(n);
34  #endif
35+   if (exitFn)
36+     (*exitFn)(n);
37    exit(n);
38  }
39diff -rc src-ref/ghc-6.4.2.20060411/ghc/rts/Storage.c src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/Storage.c
40*** src-ref/ghc-6.4.2.20060411/ghc/rts/Storage.c Thu Mar 30 08:45:47 2006
41--- src-with-old-ghc/ghc-6.4.2.20060411/ghc/rts/Storage.c Thu May 25 12:33:49 2006
42***************
43*** 90,96 ****
44        RtsFlags.GcFlags.minAllocAreaSize >
45        RtsFlags.GcFlags.maxHeapSize) {
46        errorBelch("maximum heap size (-M) is smaller than minimum alloc area size (-A)");
47!       exit(1);
48    }
49 
50    initBlockAllocator();
51--- 90,96 ----
52        RtsFlags.GcFlags.minAllocAreaSize >
53        RtsFlags.GcFlags.maxHeapSize) {
54        errorBelch("maximum heap size (-M) is smaller than minimum alloc area size (-A)");
55!       RtsFlags.GcFlags.minAllocAreaSize = RtsFlags.GcFlags.maxHeapSize;
56    }
57 
58    initBlockAllocator();