mirror of
https://github.com/Z3Prover/z3
synced 2025-06-15 18:36:16 +00:00
fixup use of SYNC/SYNCH for mpz
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
7df8d17639
commit
abbee32ddc
3 changed files with 28 additions and 31 deletions
|
@ -27,14 +27,6 @@ Revision History:
|
||||||
typedef unsigned int mpn_digit;
|
typedef unsigned int mpn_digit;
|
||||||
|
|
||||||
class mpn_manager {
|
class mpn_manager {
|
||||||
#ifndef SINGLE_THREAD
|
|
||||||
std::recursive_mutex m_lock;
|
|
||||||
#define MPN_BEGIN_CRITICAL() m_lock.lock()
|
|
||||||
#define MPN_END_CRITICAL() m_lock.unlock()
|
|
||||||
#else
|
|
||||||
#define MPN_BEGIN_CRITICAL() {}
|
|
||||||
#define MPN_END_CRITICAL() {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mpn_manager();
|
mpn_manager();
|
||||||
|
|
|
@ -187,15 +187,16 @@ mpz_manager<SYNCH>::~mpz_manager() {
|
||||||
template<bool SYNCH>
|
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;
|
||||||
#ifdef SINGLE_THREAD
|
#ifdef SINGLE_THREAD
|
||||||
mpz_cell * cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
||||||
#else
|
#else
|
||||||
#if SYNC
|
if (SYNCH) {
|
||||||
mpz_cell * cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
cell = reinterpret_cast<mpz_cell*>(memory::allocate(cell_size(capacity)));
|
||||||
#else
|
}
|
||||||
mpz_cell * cell = reinterpret_cast<mpz_cell*>(memory::allocate(cell_size(capacity)));
|
else {
|
||||||
|
cell = reinterpret_cast<mpz_cell*>(m_allocator.allocate(cell_size(capacity)));
|
||||||
#endif
|
}
|
||||||
#endif
|
#endif
|
||||||
cell->m_capacity = capacity;
|
cell->m_capacity = capacity;
|
||||||
return cell;
|
return cell;
|
||||||
|
@ -207,11 +208,12 @@ void mpz_manager<SYNCH>::deallocate(bool is_heap, mpz_cell * ptr) {
|
||||||
#ifdef SINGLE_THREAD
|
#ifdef SINGLE_THREAD
|
||||||
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
||||||
#else
|
#else
|
||||||
#if SYNC
|
if (SYNCH) {
|
||||||
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
|
||||||
#else
|
|
||||||
memory::deallocate(ptr);
|
memory::deallocate(ptr);
|
||||||
#endif
|
}
|
||||||
|
else {
|
||||||
|
m_allocator.deallocate(cell_size(ptr->m_capacity), ptr);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,14 +196,16 @@ class mpz_manager {
|
||||||
mutable mpz_t m_int64_min;
|
mutable mpz_t m_int64_min;
|
||||||
|
|
||||||
mpz_t * allocate() {
|
mpz_t * allocate() {
|
||||||
|
mpz_t * cell;
|
||||||
#ifdef SINGLE_THREAD
|
#ifdef SINGLE_THREAD
|
||||||
mpz_t * cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
||||||
#else
|
#else
|
||||||
#if SYNC
|
if (SYNCH) {
|
||||||
mpz_t * cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
cell = reinterpret_cast<mpz_t*>(memory::allocate(sizeof(mpz_t)));
|
||||||
#else
|
}
|
||||||
mpz_t * cell = reinterpret_cast<mpz_t*>(memory::allocate(sizeof(mpz_t)));
|
else {
|
||||||
#endif
|
cell = reinterpret_cast<mpz_t*>(m_allocator.allocate(sizeof(mpz_t)));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
mpz_init(*cell);
|
mpz_init(*cell);
|
||||||
return cell;
|
return cell;
|
||||||
|
@ -215,11 +217,12 @@ class mpz_manager {
|
||||||
#ifdef SINGLE_THREAD
|
#ifdef SINGLE_THREAD
|
||||||
m_allocator.deallocate(sizeof(mpz_t), ptr);
|
m_allocator.deallocate(sizeof(mpz_t), ptr);
|
||||||
#else
|
#else
|
||||||
#if SYNC
|
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
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue