Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an argument to sc_stop, default to EXIT_SUCCESS, and provide sc_exit_status() to retrieve it #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/sysc/kernel/sc_simcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the assignment only be allowed if g_exit==EXIT_SUCCESS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ops - good point well made - sorry !!!

sc_get_curr_simcontext()->stop();
}

Expand Down
3 changes: 2 additions & 1 deletion src/sysc/kernel/sc_simcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading