3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-26 06:07:01 +00:00

rewrite scoped_timer for linux

The previous version was racy and could lead to crashes.
The timer could be deleted before the callback was called, making it execute on already freed memory

This new version is similar to Mac's. It spawns its own thread and uses pthread_cond_wait.
Care is taken for small timeouts to avoid races in the thread creation and timer destruction.

Signed-off-by: Nuno Lopes <nlopes@microsoft.com>
This commit is contained in:
Nuno Lopes 2015-11-22 11:40:52 +00:00
parent b26735a887
commit d9bafc3fba
2 changed files with 60 additions and 34 deletions

View file

@ -19,6 +19,8 @@ Revision History:
#ifndef DEBUG_H_
#define DEBUG_H_
#include <stdlib.h>
void enable_assertions(bool f);
bool assertions_enabled();
@ -82,6 +84,12 @@ bool is_debug_enabled(const char * tag);
#define VERIFY(_x_) (void)(_x_)
#endif
#define ENSURE(_x_) \
if (!(_x_)) { \
std::cerr << "Failed to verify: " << #_x_ << "\n"; \
exit(-1); \
}
#define MAKE_NAME2(LINE) zofty_ ## LINE
#define MAKE_NAME(LINE) MAKE_NAME2(LINE)
#define DBG_UNIQUE_NAME MAKE_NAME(__LINE__)