Skip to content

Commit

Permalink
main: Move initialization of runtime and user interface to same file
Browse files Browse the repository at this point in the history
Since the user interface contains some GC pointers, we need to
guarantee that the mutex in the runtime is initialized before the
garbage collected pointers in the user interface.

Move the runtime and user interface to the `main` file to guarantee
that this consstraint is respected.

Signed-off-by: Christophe de Dinechin <[email protected]>
  • Loading branch information
c3d committed Dec 8, 2024
1 parent e67ab92 commit 6365ef5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/dmcp/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
using std::max;
using std::min;

// Those are put in the same file to guarantee initialization order
runtime rt(nullptr, 0);
runtime::gcptr *runtime::GCSafe;
user_interface ui;

uint last_keystroke_time = 0;
int last_key = 0;
Expand Down
3 changes: 0 additions & 3 deletions src/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
#include <cstring>


// The one and only runtime
runtime rt(nullptr, 0);
runtime::gcptr *runtime::GCSafe;

RECORDER(runtime, 16, "RPL runtime");
RECORDER(runtime_error, 16, "RPL runtime error (anomalous behaviors)");
Expand Down
3 changes: 0 additions & 3 deletions src/user_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
#include <wctype.h>


// The primary user interface of the calculator
user_interface ui;

using std::max;
using std::min;

Expand Down

0 comments on commit 6365ef5

Please sign in to comment.