From 2ca77cbd34935f25fb4768bb699f2e9269e566da Mon Sep 17 00:00:00 2001 From: Mark Burton Date: Mon, 4 Nov 2024 20:14:28 +0100 Subject: [PATCH] Add an argument to sc_stop, default to EXIT_SUCCESS, and provide sc_exit_status() to retrieve it Signed-off-by: Mark Burton --- src/sysc/kernel/sc_simcontext.cpp | 8 +++++++- src/sysc/kernel/sc_simcontext.h | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sysc/kernel/sc_simcontext.cpp b/src/sysc/kernel/sc_simcontext.cpp index 35a7e90eb..616b7da57 100644 --- a/src/sysc/kernel/sc_simcontext.cpp +++ b/src/sysc/kernel/sc_simcontext.cpp @@ -1761,10 +1761,16 @@ sc_start() SC_EXIT_ON_STARVATION ); } +static int g_exit = EXIT_SUCCESS; +SC_API int +sc_exit_code() { + return g_exit; +} SC_API void -sc_stop() +sc_stop(int exit_code) { + if (g_exit!=EXIT_SUCCESS) g_exit = exit_code; sc_get_curr_simcontext()->stop(); } diff --git a/src/sysc/kernel/sc_simcontext.h b/src/sysc/kernel/sc_simcontext.h index 9433fe0fd..d3c7b420d 100644 --- a/src/sysc/kernel/sc_simcontext.h +++ b/src/sysc/kernel/sc_simcontext.h @@ -119,7 +119,8 @@ inline void sc_start( double duration, sc_time_unit unit, sc_start( sc_time(duration,unit), p ); } -extern SC_API void sc_stop(); +extern SC_API void sc_stop(int exit_code = EXIT_SUCCESS); +extern SC_API int sc_exit_code(); // friend function declarations