diff options
author | Tristan Gingold <tgingold@free.fr> | 2016-03-19 07:16:58 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2016-03-19 07:18:48 +0100 |
commit | 368b69c1a09413795a1409d6b54d02139d9fa519 (patch) | |
tree | 50817855c64e1e50c5ea9d55176bed6c55a64010 /src | |
parent | 8e97758e77b2a0798bd83f99e72b32db43f0fe0e (diff) | |
download | ghdl-368b69c1a09413795a1409d6b54d02139d9fa519.tar.gz ghdl-368b69c1a09413795a1409d6b54d02139d9fa519.tar.bz2 ghdl-368b69c1a09413795a1409d6b54d02139d9fa519.zip |
Always execute finalizers and end hooks after simulation.
Fix for issue45.
Diffstat (limited to 'src')
-rw-r--r-- | src/grt/config/jumps.c | 2 | ||||
-rw-r--r-- | src/grt/grt-main.adb | 5 | ||||
-rw-r--r-- | src/grt/grt-processes.adb | 13 | ||||
-rw-r--r-- | src/grt/grt-processes.ads | 3 |
4 files changed, 18 insertions, 5 deletions
diff --git a/src/grt/config/jumps.c b/src/grt/config/jumps.c index 2170943d6..019b42eee 100644 --- a/src/grt/config/jumps.c +++ b/src/grt/config/jumps.c @@ -56,7 +56,7 @@ #ifdef USE_BUILTIN_SJLJ typedef void *JMP_BUF[5]; static int sjlj_val; -# define SETJMP(BUF) (__builtin_setjmp (BUF), sjlj_val) +# define SETJMP(BUF) (sjlj_val = 0, __builtin_setjmp (BUF), sjlj_val) # define LONGJMP(BUF, VAL) \ do { sjlj_val = (VAL); __builtin_longjmp (BUF, 1); } while (0) #else diff --git a/src/grt/grt-main.adb b/src/grt/grt-main.adb index 4b2614aad..f5006ef6b 100644 --- a/src/grt/grt-main.adb +++ b/src/grt/grt-main.adb @@ -109,6 +109,8 @@ package body Grt.Main is use Grt.Errors; Stop : Boolean; Status : Integer; + Status1 : Integer; + pragma Unreferenced (Status1); begin -- Register modules. -- They may insert hooks. @@ -172,6 +174,9 @@ package body Grt.Main is -- Do the simulation. Status := Run_Through_Longjump (Grt.Processes.Simulation'Access); + + Status1 := Run_Through_Longjump + (Grt.Processes.Finalize_Simulation'Access); end if; if Flag_Stats then diff --git a/src/grt/grt-processes.adb b/src/grt/grt-processes.adb index 242a9e595..a105e755d 100644 --- a/src/grt/grt-processes.adb +++ b/src/grt/grt-processes.adb @@ -1119,10 +1119,6 @@ package body Grt.Processes is if Nbr_Threads /= 1 then Threads.Finish; end if; - - Call_Finalizers; - - Grt.Hooks.Call_Finish_Hooks; end Simulation_Finish; function Simulation return Integer @@ -1138,4 +1134,13 @@ package body Grt.Processes is return Status; end Simulation; + function Finalize_Simulation return Integer is + begin + Call_Finalizers; + + Grt.Hooks.Call_Finish_Hooks; + + return Run_Finished; + end Finalize_Simulation; + end Grt.Processes; diff --git a/src/grt/grt-processes.ads b/src/grt/grt-processes.ads index 00b057e41..ff51b39bb 100644 --- a/src/grt/grt-processes.ads +++ b/src/grt/grt-processes.ads @@ -43,6 +43,9 @@ package Grt.Processes is -- < 0 in case of failure or stop request. function Simulation return Integer; + -- To be called after Simulation to run finalizer and end hooks. + function Finalize_Simulation return Integer; + -- Number of delta cycles. Nbr_Delta_Cycles : Integer; -- Number of non-delta cycles. |