ENSURES usage removed
This commit is contained in:
@@ -2283,7 +2283,7 @@ std::string named_thread::get_name() const
|
||||
void named_thread::start_thread(const std::shared_ptr<void>& _this)
|
||||
{
|
||||
// Ensure it's not called from the constructor and the correct object is passed
|
||||
ENSURES(_this.get() == this);
|
||||
verify("named_thread::start_thread" HERE), _this.get() == this;
|
||||
|
||||
// Run thread
|
||||
thread_ctrl::spawn(m_thread, get_name(), [this, _this]()
|
||||
|
||||
@@ -16,30 +16,27 @@ namespace memory_helper
|
||||
void* reserve_memory(size_t size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
void* ret = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
|
||||
ENSURES(ret != NULL);
|
||||
return verify(VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS), "reserve_memory" HERE);
|
||||
#else
|
||||
void* ret = mmap(nullptr, size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
ENSURES(ret != 0);
|
||||
return verify(::mmap(nullptr, size, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0), "reserve_memory" HERE);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void commit_page_memory(void* pointer, size_t size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
VERIFY(VirtualAlloc(pointer, size, MEM_COMMIT, PAGE_READWRITE) != NULL);
|
||||
verify(HERE), VirtualAlloc(pointer, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
#else
|
||||
VERIFY(mprotect((void*)((u64)pointer & -4096), size, PROT_READ | PROT_WRITE) != -1);
|
||||
verify(HERE), ::mprotect((void*)((u64)pointer & -4096), size, PROT_READ | PROT_WRITE) != -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void free_reserved_memory(void* pointer, size_t size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
VERIFY(VirtualFree(pointer, 0, MEM_DECOMMIT) != 0);
|
||||
verify(HERE), VirtualFree(pointer, 0, MEM_DECOMMIT);
|
||||
#else
|
||||
VERIFY(mprotect(pointer, size, PROT_NONE) != -1);
|
||||
verify(HERE), ::mprotect(pointer, size, PROT_NONE) != -1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -58,14 +58,12 @@
|
||||
|
||||
#define HERE "\n(in file " __FILE__ ":" STRINGIZE(__LINE__) ")"
|
||||
|
||||
// Wrap an expression into lambda
|
||||
// Wrap an expression into lambda. Obsolete.
|
||||
#define WRAP_EXPR(...) [&] { return __VA_ARGS__; }
|
||||
|
||||
// Ensure that the expression is evaluated to true. Always evaluated and allowed to have side effects (unlike assert() macro).
|
||||
// Ensure that the expression is evaluated to true. Obsolete.
|
||||
#define VERIFY(...) do { if (!(__VA_ARGS__)) fmt::raw_error("Verification failed: " #__VA_ARGS__ HERE); } while (0)
|
||||
|
||||
// EXPECTS() and ENSURES() are intended to check function arguments and results.
|
||||
// Expressions are not guaranteed to evaluate.
|
||||
#define EXPECTS(...) do { if (!(__VA_ARGS__)) fmt::raw_error("Precondition failed: " #__VA_ARGS__ HERE); } while (0)
|
||||
#define ENSURES(...) do { if (!(__VA_ARGS__)) fmt::raw_error("Postcondition failed: " #__VA_ARGS__ HERE); } while (0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user