File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 12
12
#include < cfenv>
13
13
#include < cstdio>
14
14
#include < cstdlib>
15
+ #include < thread>
16
+ std::thread::id main_thread_id = std::this_thread::get_id();
17
+ extern " C" std::thread::id get_main_thread_id () { return main_thread_id; }
15
18
16
19
static void ConfigureFloatingPoint () {
17
20
#ifdef feclearexcept // a macro in some environments; omit std::
Original file line number Diff line number Diff line change 16
16
#include < cfenv>
17
17
#include < cstdio>
18
18
#include < cstdlib>
19
+ #include < thread>
20
+ std::thread::id get_main_thread_id ();
19
21
20
22
#ifdef HAVE_BACKTRACE
21
23
#include BACKTRACE_HEADER
@@ -79,6 +81,8 @@ static void CloseAllExternalUnits(const char *why) {
79
81
std::fputc (' \n ' , stderr);
80
82
DescribeIEEESignaledExceptions ();
81
83
}
84
+ if (get_main_thread_id () != std::this_thread::get_id ())
85
+ std::abort ();
82
86
std::exit (code);
83
87
}
84
88
@@ -94,6 +98,8 @@ static void CloseAllExternalUnits(const char *why) {
94
98
}
95
99
DescribeIEEESignaledExceptions ();
96
100
}
101
+ if (get_main_thread_id () != std::this_thread::get_id ())
102
+ std::abort ();
97
103
if (isErrorStop) {
98
104
std::exit (EXIT_FAILURE);
99
105
} else {
You can’t perform that action at this time.
0 commit comments