mirror of
https://github.com/Z3Prover/z3
synced 2025-04-04 08:39:57 +00:00
api: hint the compiler that logging enabled is unlikely
This commit is contained in:
parent
bd8c870bbe
commit
3aacc62229
|
@ -1798,9 +1798,9 @@ def write_log_h_preamble(log_h):
|
|||
log_h.write('#include "util/mutex.h"\n')
|
||||
log_h.write('extern atomic<bool> g_z3_log_enabled;\n')
|
||||
log_h.write('void ctx_enable_logging();\n')
|
||||
log_h.write('class z3_log_ctx { bool m_prev; public: z3_log_ctx() { ATOMIC_EXCHANGE(m_prev, g_z3_log_enabled, false); } ~z3_log_ctx() { if (m_prev) g_z3_log_enabled = true; } bool enabled() const { return m_prev; } };\n')
|
||||
log_h.write('class z3_log_ctx { bool m_prev; public: z3_log_ctx() { ATOMIC_EXCHANGE(m_prev, g_z3_log_enabled, false); } ~z3_log_ctx() { if (m_prev) [[unlikely]] g_z3_log_enabled = true; } bool enabled() const { return m_prev; } };\n')
|
||||
log_h.write('void SetR(const void * obj);\nvoid SetO(void * obj, unsigned pos);\nvoid SetAO(void * obj, unsigned pos, unsigned idx);\n')
|
||||
log_h.write('#define RETURN_Z3(Z3RES) do { auto tmp_ret = Z3RES; if (_LOG_CTX.enabled()) { SetR(tmp_ret); } return tmp_ret; } while (0)\n')
|
||||
log_h.write('#define RETURN_Z3(Z3RES) do { auto tmp_ret = Z3RES; if (_LOG_CTX.enabled()) [[unlikely]] { SetR(tmp_ret); } return tmp_ret; } while (0)\n')
|
||||
|
||||
|
||||
def write_log_c_preamble(log_c):
|
||||
|
|
Loading…
Reference in a new issue