mirror of
https://github.com/Z3Prover/z3
synced 2026-05-31 06:07:46 +00:00
code simplifications
This commit is contained in:
parent
70a03c7784
commit
095b2bdf59
5 changed files with 16 additions and 32 deletions
|
|
@ -18,10 +18,10 @@ Notes:
|
||||||
--*/
|
--*/
|
||||||
#include "util/common_msgs.h"
|
#include "util/common_msgs.h"
|
||||||
|
|
||||||
char const * common_msgs::g_canceled_msg = "canceled";
|
char const common_msgs::g_canceled_msg[] = "canceled";
|
||||||
char const * common_msgs::g_max_memory_msg = "max. memory exceeded";
|
char const common_msgs::g_max_memory_msg[] = "max. memory exceeded";
|
||||||
char const * common_msgs::g_max_scopes_msg = "max. scopes exceeded";
|
char const common_msgs::g_max_scopes_msg[] = "max. scopes exceeded";
|
||||||
char const * common_msgs::g_max_steps_msg = "max. steps exceeded";
|
char const common_msgs::g_max_steps_msg[] = "max. steps exceeded";
|
||||||
char const * common_msgs::g_max_frames_msg = "max. frames exceeded";
|
char const common_msgs::g_max_frames_msg[] = "max. frames exceeded";
|
||||||
char const * common_msgs::g_no_proofs_msg = "component does not support proof generation";
|
char const common_msgs::g_no_proofs_msg[] = "component does not support proof generation";
|
||||||
char const * common_msgs::g_max_resource_msg = "max. resource limit exceeded";
|
char const common_msgs::g_max_resource_msg[] = "max. resource limit exceeded";
|
||||||
|
|
@ -20,13 +20,13 @@ Notes:
|
||||||
|
|
||||||
class common_msgs {
|
class common_msgs {
|
||||||
public:
|
public:
|
||||||
static char const * g_canceled_msg;
|
static char const g_canceled_msg[];
|
||||||
static char const * g_max_memory_msg;
|
static char const g_max_memory_msg[];
|
||||||
static char const * g_max_scopes_msg;
|
static char const g_max_scopes_msg[];
|
||||||
static char const * g_max_steps_msg;
|
static char const g_max_steps_msg[];
|
||||||
static char const * g_max_frames_msg;
|
static char const g_max_frames_msg[];
|
||||||
static char const * g_no_proofs_msg;
|
static char const g_no_proofs_msg[];
|
||||||
static char const * g_max_resource_msg;
|
static char const g_max_resource_msg[];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Z3_CANCELED_MSG common_msgs::g_canceled_msg
|
#define Z3_CANCELED_MSG common_msgs::g_canceled_msg
|
||||||
|
|
|
||||||
|
|
@ -188,16 +188,12 @@ template<bool SYNCH>
|
||||||
mpz_cell * mpz_manager<SYNCH>::allocate(unsigned capacity) {
|
mpz_cell * mpz_manager<SYNCH>::allocate(unsigned capacity) {
|
||||||
SASSERT(capacity >= m_init_cell_capacity);
|
SASSERT(capacity >= m_init_cell_capacity);
|
||||||
mpz_cell * cell;
|
mpz_cell * cell;
|
||||||
#ifdef SINGLE_THREAD
|
|
||||||
cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
|
||||||
#else
|
|
||||||
if (SYNCH) {
|
if (SYNCH) {
|
||||||
cell = reinterpret_cast<mpz_cell*>(memory::allocate(cell_size(capacity)));
|
cell = reinterpret_cast<mpz_cell*>(memory::allocate(cell_size(capacity)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
cell->m_capacity = capacity;
|
cell->m_capacity = capacity;
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
|
|
@ -206,17 +202,12 @@ mpz_cell * mpz_manager<SYNCH>::allocate(unsigned capacity) {
|
||||||
template<bool SYNCH>
|
template<bool SYNCH>
|
||||||
void mpz_manager<SYNCH>::deallocate(bool is_heap, mpz_cell * ptr) {
|
void mpz_manager<SYNCH>::deallocate(bool is_heap, mpz_cell * ptr) {
|
||||||
if (is_heap) {
|
if (is_heap) {
|
||||||
|
|
||||||
#ifdef SINGLE_THREAD
|
|
||||||
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
|
||||||
#else
|
|
||||||
if (SYNCH) {
|
if (SYNCH) {
|
||||||
memory::deallocate(ptr);
|
memory::deallocate(ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,7 @@ class mpz_manager {
|
||||||
mutable std::recursive_mutex m_lock;
|
mutable std::recursive_mutex m_lock;
|
||||||
#define MPZ_BEGIN_CRITICAL() if (SYNCH) m_lock.lock()
|
#define MPZ_BEGIN_CRITICAL() if (SYNCH) m_lock.lock()
|
||||||
#define MPZ_END_CRITICAL() if (SYNCH) m_lock.unlock()
|
#define MPZ_END_CRITICAL() if (SYNCH) m_lock.unlock()
|
||||||
|
static_assert(false);
|
||||||
#else
|
#else
|
||||||
#define MPZ_BEGIN_CRITICAL() {}
|
#define MPZ_BEGIN_CRITICAL() {}
|
||||||
#define MPZ_END_CRITICAL() {}
|
#define MPZ_END_CRITICAL() {}
|
||||||
|
|
@ -211,16 +212,12 @@ class mpz_manager {
|
||||||
|
|
||||||
mpz_t * allocate() {
|
mpz_t * allocate() {
|
||||||
mpz_t * cell;
|
mpz_t * cell;
|
||||||
#ifdef SINGLE_THREAD
|
|
||||||
cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
|
||||||
#else
|
|
||||||
if (SYNCH) {
|
if (SYNCH) {
|
||||||
cell = reinterpret_cast<mpz_t*>(memory::allocate(sizeof(mpz_t)));
|
cell = reinterpret_cast<mpz_t*>(memory::allocate(sizeof(mpz_t)));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
mpz_init(*cell);
|
mpz_init(*cell);
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
@ -228,16 +225,12 @@ class mpz_manager {
|
||||||
void deallocate(bool is_heap, mpz_t * ptr) {
|
void deallocate(bool is_heap, mpz_t * ptr) {
|
||||||
mpz_clear(*ptr);
|
mpz_clear(*ptr);
|
||||||
if (is_heap) {
|
if (is_heap) {
|
||||||
#ifdef SINGLE_THREAD
|
|
||||||
m_allocator.deallocate(sizeof(mpz_t), ptr);
|
|
||||||
#else
|
|
||||||
if (SYNCH) {
|
if (SYNCH) {
|
||||||
memory::deallocate(ptr);
|
memory::deallocate(ptr);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_allocator.deallocate(sizeof(mpz_t), ptr);
|
m_allocator.deallocate(sizeof(mpz_t), ptr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ static DECLARE_MUTEX(g_powers_of_two);
|
||||||
|
|
||||||
rational rational::power_of_two(unsigned k) {
|
rational rational::power_of_two(unsigned k) {
|
||||||
rational result;
|
rational result;
|
||||||
lock_guard lock(*g_powers_of_two);
|
|
||||||
{
|
{
|
||||||
|
lock_guard lock(*g_powers_of_two);
|
||||||
if (k >= m_powers_of_two.size())
|
if (k >= m_powers_of_two.size())
|
||||||
mk_power_up_to(m_powers_of_two, k+1);
|
mk_power_up_to(m_powers_of_two, k+1);
|
||||||
result = m_powers_of_two[k];
|
result = m_powers_of_two[k];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue