Remove explicit_bool_t, ignore, multicast<>

Remove vm::ptr operator %
This was a bad idea but explicit_bool_t was created almost for it
Other removed types are unused and have little to no meaning
This commit is contained in:
Nekotekina 2018-09-05 16:24:11 +03:00
parent 99ffc3fca9
commit ee96807305
11 changed files with 22 additions and 91 deletions

View file

@ -2038,7 +2038,7 @@ s32 _cellSpursWorkloadAttributeInitialize(vm::ptr<CellSpursWorkloadAttribute> at
return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER;
}
if (pm % 16)
if (!pm.aligned(16))
{
return CELL_SPURS_POLICY_MODULE_ERROR_ALIGN;
}
@ -2107,7 +2107,7 @@ s32 _spurs::add_workload(vm::ptr<CellSpurs> spurs, vm::ptr<u32> wid, vm::cptr<vo
return CELL_SPURS_POLICY_MODULE_ERROR_NULL_POINTER;
}
if (!spurs.aligned() || pm % 16)
if (!spurs.aligned() || !pm.aligned(16))
{
return CELL_SPURS_POLICY_MODULE_ERROR_ALIGN;
}
@ -3431,21 +3431,21 @@ s32 _spurs::create_task(vm::ptr<CellSpursTaskset> taskset, vm::ptr<u32> task_id,
return CELL_SPURS_TASK_ERROR_NULL_POINTER;
}
if (elf % 16)
if (!elf.aligned(16))
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}
if (_spurs::get_sdk_version() < 0x27FFFF)
{
if (context % 16)
if (!context.aligned(16))
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}
}
else
{
if (context % 128)
if (!context.aligned(128))
{
return CELL_SPURS_TASK_ERROR_ALIGN;
}

View file

@ -256,7 +256,7 @@ error_code cellSyncRwmInitialize(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer,
return CELL_SYNC_ERROR_NULL_POINTER;
}
if (UNLIKELY(!rwm.aligned() || buffer % 128))
if (UNLIKELY(!rwm.aligned() || !buffer.aligned(128)))
{
return CELL_SYNC_ERROR_ALIGN;
}
@ -418,7 +418,7 @@ error_code cellSyncQueueInitialize(vm::ptr<CellSyncQueue> queue, vm::ptr<u8> buf
return CELL_SYNC_ERROR_NULL_POINTER;
}
if (UNLIKELY(!queue.aligned() || buffer % 16))
if (UNLIKELY(!queue.aligned() || !buffer.aligned(16)))
{
return CELL_SYNC_ERROR_ALIGN;
}
@ -744,7 +744,7 @@ error_code cellSyncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::cptr<vo
return CELL_SYNC_ERROR_INVAL;
}
if (UNLIKELY(!queue.aligned() || buffer % 16))
if (UNLIKELY(!queue.aligned() || !buffer.aligned(16)))
{
return CELL_SYNC_ERROR_ALIGN;
}
@ -1075,7 +1075,7 @@ error_code _cellSyncLFQueuePushBody(ppu_thread& ppu, vm::ptr<CellSyncLFQueue> qu
return CELL_SYNC_ERROR_NULL_POINTER;
}
if (UNLIKELY(!queue.aligned() || buffer % 16))
if (UNLIKELY(!queue.aligned() || !buffer.aligned(16)))
{
return CELL_SYNC_ERROR_ALIGN;
}
@ -1370,7 +1370,7 @@ error_code _cellSyncLFQueuePopBody(ppu_thread& ppu, vm::ptr<CellSyncLFQueue> que
return CELL_SYNC_ERROR_NULL_POINTER;
}
if (UNLIKELY(!queue.aligned() || buffer % 16))
if (UNLIKELY(!queue.aligned() || !buffer.aligned(16)))
{
return CELL_SYNC_ERROR_ALIGN;
}

View file

@ -54,7 +54,7 @@ s32 sys_mempool_create(ppu_thread& ppu, vm::ptr<sys_mempool_t> mempool, vm::ptr<
}
// Test chunk address aligment
if (chunk % 8)
if (!chunk.aligned(8))
{
return CELL_EINVAL;
}

View file

@ -732,7 +732,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry)
// Probe
for (vm::cptr<u32> ptr = vm::cast(sec.addr); ptr < sec_end;)
{
if (ptr % 4 || ptr.addr() < sec.addr || ptr >= sec_end)
if (!ptr.aligned() || ptr.addr() < sec.addr || ptr >= sec_end)
{
sec_end.set(0);
break;

View file

@ -556,7 +556,7 @@ public:
// Remove the ID
template <typename T, typename Get = T>
static inline explicit_bool_t remove(u32 id)
static inline bool remove(u32 id)
{
std::shared_ptr<void> ptr;
{
@ -832,7 +832,7 @@ public:
// Delete the object
template <typename T>
static inline explicit_bool_t remove()
static inline bool remove()
{
std::shared_ptr<void> ptr;
{

View file

@ -113,17 +113,11 @@ namespace vm
}
// Test address for arbitrary alignment: (addr & (align - 1)) == 0
bool aligned(u32 align) const
bool aligned(u32 align = alignof(T)) const
{
return (m_addr & (align - 1)) == 0;
}
// Test address alignment using alignof(T)
bool aligned() const
{
return aligned(alignof(T));
}
// Get type size
static constexpr u32 size()
{
@ -136,12 +130,6 @@ namespace vm
return alignof(T);
}
// Test address for arbitrary alignment: (addr & (align - 1)) != 0
explicit_bool_t operator %(u32 align) const
{
return !aligned(align);
}
_ptr_base<T, u32> operator +() const
{
return vm::cast(m_addr, HERE);

View file

@ -133,14 +133,14 @@ namespace vm
template <typename T, typename A = stack_allocator<ppu_thread>>
[[nodiscard]] auto make_var(const T& value)
{
return varb<T, A>(value);
return (varb<T, A>(value));
}
// Make char[] variable initialized from std::string
template <typename A = stack_allocator<ppu_thread>>
[[nodiscard]] auto make_str(const std::string& str)
{
return _var_base<char[], A>(size32(str) + 1, str.c_str());
return (_var_base<char[], A>(size32(str) + 1, str.c_str()));
}
// Global HLE variable