3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

Merge pull request #2329 from Z3Prover/nomp

Nomp
This commit is contained in:
Nikolaj Bjorner 2019-06-07 02:05:11 +02:00 committed by GitHub
commit e731a44880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 484 additions and 552 deletions

View file

@ -119,28 +119,22 @@ namespace api {
context::set_interruptable::set_interruptable(context & ctx, event_handler & i):
m_ctx(ctx) {
#pragma omp critical (set_interruptable)
{
SASSERT(m_ctx.m_interruptable == 0);
m_ctx.m_interruptable = &i;
}
lock_guard lock(ctx.m_mux);
SASSERT(m_ctx.m_interruptable == 0);
m_ctx.m_interruptable = &i;
}
context::set_interruptable::~set_interruptable() {
#pragma omp critical (set_interruptable)
{
m_ctx.m_interruptable = nullptr;
}
lock_guard lock(m_ctx.m_mux);
m_ctx.m_interruptable = nullptr;
}
void context::interrupt() {
#pragma omp critical (set_interruptable)
{
if (m_interruptable)
(*m_interruptable)(API_INTERRUPT_EH_CALLER);
m_limit.cancel();
m().limit().cancel();
}
lock_guard lock(m_mux);
if (m_interruptable)
(*m_interruptable)(API_INTERRUPT_EH_CALLER);
m_limit.cancel();
m().limit().cancel();
}
void context::set_error_code(Z3_error_code err, char const* opt_msg) {

View file

@ -42,6 +42,7 @@ Revision History:
#include "ast/rewriter/seq_rewriter.h"
#include "smt/smt_solver.h"
#include "solver/solver.h"
#include "util/mutex.h"
namespace smtlib {
class parser;
@ -79,6 +80,7 @@ namespace api {
scoped_ptr<ast_manager> m_manager;
scoped_ptr<cmd_context> m_cmd;
add_plugins m_plugins;
mutex m_mux;
arith_util m_arith_util;
bv_util m_bv_util;

View file

@ -16,6 +16,7 @@ Revision History:
--*/
#include<fstream>
#include<mutex>
#include "api/z3.h"
#include "api/api_log_macros.h"
#include "util/util.h"
@ -24,6 +25,13 @@ Revision History:
std::ostream * g_z3_log = nullptr;
bool g_z3_log_enabled = false;
#ifdef Z3_LOG_SYNC
static std::mutex g_log_mux;
#define SCOPED_LOCK() std::lock_guard<std::mutex> lock(g_log_mux)
#else
#define SCOPED_LOCK() {}
#endif
extern "C" {
void Z3_close_log_unsafe(void) {
if (g_z3_log != nullptr) {
@ -36,26 +44,20 @@ extern "C" {
bool Z3_API Z3_open_log(Z3_string filename) {
bool res = true;
#ifdef Z3_LOG_SYNC
#pragma omp critical (z3_log)
{
#endif
if (g_z3_log != nullptr)
Z3_close_log_unsafe();
g_z3_log = alloc(std::ofstream, filename);
if (g_z3_log->bad() || g_z3_log->fail()) {
dealloc(g_z3_log);
g_z3_log = nullptr;
res = false;
}
else {
*g_z3_log << "V \"" << Z3_MAJOR_VERSION << "." << Z3_MINOR_VERSION << "." << Z3_BUILD_NUMBER << "." << Z3_REVISION_NUMBER << " " << __DATE__ << "\"\n";
g_z3_log->flush();
g_z3_log_enabled = true;
}
#ifdef Z3_LOG_SYNC
SCOPED_LOCK();
if (g_z3_log != nullptr)
Z3_close_log_unsafe();
g_z3_log = alloc(std::ofstream, filename);
if (g_z3_log->bad() || g_z3_log->fail()) {
dealloc(g_z3_log);
g_z3_log = nullptr;
res = false;
}
else {
*g_z3_log << "V \"" << Z3_MAJOR_VERSION << "." << Z3_MINOR_VERSION << "." << Z3_BUILD_NUMBER << "." << Z3_REVISION_NUMBER << " " << __DATE__ << "\"\n";
g_z3_log->flush();
g_z3_log_enabled = true;
}
#endif
return res;
}
@ -63,27 +65,15 @@ extern "C" {
void Z3_API Z3_append_log(Z3_string str) {
if (g_z3_log == nullptr)
return;
#ifdef Z3_LOG_SYNC
#pragma omp critical (z3_log)
{
#endif
if (g_z3_log != nullptr)
_Z3_append_log(static_cast<char const *>(str));
#ifdef Z3_LOG_SYNC
}
#endif
SCOPED_LOCK();
if (g_z3_log != nullptr)
_Z3_append_log(static_cast<char const *>(str));
}
void Z3_API Z3_close_log(void) {
if (g_z3_log != nullptr) {
#ifdef Z3_LOG_SYNC
#pragma omp critical (z3_log)
{
#endif
Z3_close_log_unsafe();
#ifdef Z3_LOG_SYNC
}
#endif
SCOPED_LOCK();
Z3_close_log_unsafe();
}
}
}