mirror of
https://github.com/Z3Prover/z3
synced 2025-10-08 08:51:55 +00:00
Add mutex to warning.cpp for thread safety
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
a1bbc163c7
commit
ce8ef4f19e
1 changed files with 11 additions and 0 deletions
|
@ -24,6 +24,10 @@ Revision History:
|
|||
#include "util/buffer.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
#ifndef SINGLE_THREAD
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#if defined( __MINGW32__ ) && ( defined( __GNUG__ ) || defined( __clang__ ) )
|
||||
#include <crtdbg.h>
|
||||
|
@ -67,6 +71,10 @@ static bool g_use_std_stdout = false;
|
|||
static std::ostream* g_error_stream = nullptr;
|
||||
static std::ostream* g_warning_stream = nullptr;
|
||||
|
||||
#ifndef SINGLE_THREAD
|
||||
static std::mutex g_warning_mutex;
|
||||
#endif
|
||||
|
||||
void send_warnings_to_stdout(bool flag) {
|
||||
g_use_std_stdout = flag;
|
||||
}
|
||||
|
@ -129,6 +137,9 @@ void print_msg(std::ostream * out, const char* prefix, const char* msg, va_list
|
|||
|
||||
void warning_msg(const char * msg, ...) {
|
||||
if (g_warning_msgs) {
|
||||
#ifndef SINGLE_THREAD
|
||||
std::lock_guard<std::mutex> lock(g_warning_mutex);
|
||||
#endif
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
print_msg(g_warning_stream, "WARNING: ", msg, args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue