ENSURES usage removed

This commit is contained in:
Nekotekina 2016-08-14 22:41:01 +03:00
parent b0f5796c90
commit 1f3433464c
9 changed files with 17 additions and 24 deletions

View File

@ -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]()

View File

@ -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
}
}

View File

@ -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)

View File

@ -249,9 +249,8 @@ SPUThread::SPUThread(const std::string& name, u32 index)
: cpu_thread()
, m_name(name)
, index(index)
, offset(vm::alloc(0x40000, vm::main))
, offset(verify(vm::alloc(0x40000, vm::main), __func__))
{
ENSURES(offset);
}
void SPUThread::push_snr(u32 number, u32 value)

View File

@ -276,7 +276,6 @@ s32 sys_event_queue_receive(ppu_thread& ppu, u32 equeue_id, vm::ptr<sys_event_t>
if (ppu.gpr[3])
{
ENSURES(!idm::check<lv2_event_queue_t>(equeue_id));
return CELL_ECANCELED;
}

View File

@ -473,7 +473,7 @@ void CgBinaryDisasm::TaskFP()
break;
}
ENSURES(m_step % sizeof(u32) == 0);
verify(HERE), m_step % sizeof(u32) == 0;
data += m_step / sizeof(u32);
}
}

View File

@ -373,7 +373,7 @@ public:
m_offset = prog.ucode;
u32* vdata = (u32*)&m_buffer[m_offset];
ENSURES((m_buffer_size - m_offset) % sizeof(u32) == 0);
verify(HERE), (m_buffer_size - m_offset) % sizeof(u32) == 0;
for (u32 i = 0; i < (m_buffer_size - m_offset) / sizeof(u32); i++)
{
vdata[i] = se_storage<u32>::swap(vdata[i]); // WTF, cannot use be_t<> there?
@ -394,4 +394,4 @@ public:
u32 GetData(const u32 d) const { return d << 16 | d >> 16; }
void TaskFP();
void TaskVP();
};
};

View File

@ -662,7 +662,7 @@ std::string FragmentProgramDecompiler::Decompile()
if (dst.end) break;
ENSURES(m_offset % sizeof(u32) == 0);
verify(HERE), m_offset % sizeof(u32) == 0;
data += m_offset / sizeof(u32);
}

View File

@ -44,13 +44,13 @@ HMODULE D3DCompiler;
void loadD3D12FunctionPointers()
{
VERIFY(D3D12Module = LoadLibrary(L"d3d12.dll"));
D3D12Module = verify(LoadLibrary(L"d3d12.dll"), "d3d12.dll");
wrapD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(D3D12Module, "D3D12CreateDevice");
wrapD3D12GetDebugInterface = (PFN_D3D12_GET_DEBUG_INTERFACE)GetProcAddress(D3D12Module, "D3D12GetDebugInterface");
wrapD3D12SerializeRootSignature = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(D3D12Module, "D3D12SerializeRootSignature");
VERIFY(D3D11Module = LoadLibrary(L"d3d11.dll"));
D3D11Module = verify(LoadLibrary(L"d3d11.dll"), "d3d11.dll");
wrapD3D11On12CreateDevice = (PFN_D3D11ON12_CREATE_DEVICE)GetProcAddress(D3D11Module, "D3D11On12CreateDevice");
VERIFY(D3DCompiler = LoadLibrary(L"d3dcompiler_47.dll"));
D3DCompiler = verify(LoadLibrary(L"d3dcompiler_47.dll"), "d3dcompiler_47.dll");
wrapD3DCompile = (pD3DCompile)GetProcAddress(D3DCompiler, "D3DCompile");
}