From 713b002138e8a55bbb59f507e68e834e7aef92fe Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 15 Jun 2024 10:47:22 +0100 Subject: [PATCH] vvp: fix regression in behaviour of -N option (issue #1138) The -N option was broken by PR #1068. This fix modifies and simplifies the libvvp API that was introduced in that PR. --- vvp/lib_main.cc | 11 +++-------- vvp/libvvp.h | 16 ++++++++-------- vvp/main.cc | 4 ++-- vvp/stop.cc | 4 ++-- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/vvp/lib_main.cc b/vvp/lib_main.cc index 62256d0ad1..a866274214 100644 --- a/vvp/lib_main.cc +++ b/vvp/lib_main.cc @@ -59,18 +59,13 @@ bool verbose_flag = false; static int vvp_return_value = 0; static int vvp_used = 0; -void vvp_set_stop_is_finish(bool flag) +void vvp_set_stop_is_finish(bool flag, int exit_code) { extern bool stop_is_finish; - - stop_is_finish = flag; -} - -void vvp_set_stop_is_finish_exit_code(bool flag) -{ extern int stop_is_finish_exit_code; - stop_is_finish_exit_code = flag; + stop_is_finish = flag; + stop_is_finish_exit_code = exit_code; } void vvp_set_verbose_flag(bool flag) diff --git a/vvp/libvvp.h b/vvp/libvvp.h index 081030f02c..dfdd6d012f 100644 --- a/vvp/libvvp.h +++ b/vvp/libvvp.h @@ -13,19 +13,19 @@ extern "C" { #include -/* The first three functions may be called at any time. - * vvp_set_stop_is_finish(true) is equivalent to vvp's "-n" option. +/* vvp_set_stop_is_finish(true, 0) is equivalent to vvp's "-n" option. + * vvp_set_stop_is_finish(true, 1) is equivalent to vvp's "-N" option. + * + * This function may be called at any time. */ -extern void vvp_set_stop_is_finish(bool flag); +extern void vvp_set_stop_is_finish(bool flag, int exit_code); -/* vvp_set_stop_is_finish_exit_code(true) is equivalent to vvp's "-N" option. +/* vvp_set_verbose(true) is equivalent to vvp's "-v" option. + * + * This function may be called at any time. */ -extern void vvp_set_stop_is_finish_exit_code(bool flag); - -/* vvp_set_verbose(true) is equivalent to vvp's "-v" option. */ - extern void vvp_set_verbose_flag(bool flag); /* vvp_no_signals() may be called at any time before vvp_run() to prevent diff --git a/vvp/main.cc b/vvp/main.cc index bb33c608c7..5ed80ae104 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -87,10 +87,10 @@ int main(int argc, char*argv[]) module_tab[module_cnt++] = optarg; break; case 'n': - vvp_set_stop_is_finish(true); + vvp_set_stop_is_finish(true, 0); break; case 'N': - vvp_set_stop_is_finish_exit_code(true); + vvp_set_stop_is_finish(true, 1); break; case 's': schedule_stop(0); diff --git a/vvp/stop.cc b/vvp/stop.cc index b28696a28f..b87298e9cc 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2018 Stephen Williams (steve@icarus.com) + * Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -41,7 +41,7 @@ # include "ivl_alloc.h" __vpiScope*stop_current_scope = 0; -bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */ +bool stop_is_finish = false; /* When set, $stop acts like $finish (set in main.cc). */ int stop_is_finish_exit_code = 0; #ifndef USE_READLINE