1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 12:31:45 +01:00

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

@ -185,7 +185,7 @@ u32 notifier::imp_notify(u32 count)
});
}
explicit_bool_t notifier::wait(u64 usec_timeout)
bool notifier::wait(u64 usec_timeout)
{
const u32 _old = m_cond.m_value.fetch_add(1);

View File

@ -23,7 +23,7 @@ public:
// Intrusive wait algorithm for lockable objects
template <typename T>
explicit_bool_t wait(T& object, u64 usec_timeout = -1)
bool wait(T& object, u64 usec_timeout = -1)
{
const u32 _old = m_value.fetch_add(1); // Increment waiter counter
object.unlock();
@ -88,7 +88,7 @@ public:
imp_unlock(1);
}
explicit_bool_t wait(u64 usec_timeout = -1);
bool wait(u64 usec_timeout = -1);
void notify_all()
{

View File

@ -71,7 +71,7 @@ public:
}
// Conditionally set state (optimized)
explicit_bool_t state_test_and_set(T expected, T state)
bool state_test_and_set(T expected, T state)
{
if (m_value == expected && m_value.compare_and_swap_test(expected, state))
{
@ -83,7 +83,7 @@ public:
}
// Conditionally set state (list version)
explicit_bool_t state_test_and_set(std::initializer_list<T> expected, T state)
bool state_test_and_set(std::initializer_list<T> expected, T state)
{
T _old;

View File

@ -112,10 +112,6 @@ class se_t;
template <typename T>
class atomic_t;
#if defined(__INTELLISENSE__) && !defined(_MSC_VER)
namespace std { template <typename...> using void_t = void; }
#endif
// Extract T::simple_type if available, remove cv qualifiers
template <typename T, typename = void>
struct simple_type_helper
@ -151,22 +147,6 @@ public:
}
};
// Bool wrapper for restricting bool result conversions
struct explicit_bool_t
{
const bool value;
constexpr explicit_bool_t(bool value)
: value(value)
{
}
explicit constexpr operator bool() const
{
return value;
}
};
#ifndef _MSC_VER
using u128 = __uint128_t;
using s128 = __int128_t;
@ -382,14 +362,6 @@ CHECK_SIZE_ALIGN(f16, 2, 2);
using f32 = float;
using f64 = double;
struct ignore
{
template <typename T>
ignore(T)
{
}
};
template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
constexpr T align(const T& value, ullong align)
{
@ -811,35 +783,6 @@ struct cmd64 : any64
static_assert(sizeof(cmd64) == 8 && std::is_pod<cmd64>::value, "Incorrect cmd64 type");
// Allows to define integer convertible to multiple types
template <typename T, T Value, typename T1 = void, typename... Ts>
struct multicast : multicast<T, Value, Ts...>
{
constexpr multicast()
: multicast<T, Value, Ts...>()
{
}
// Implicit conversion to desired type
constexpr operator T1() const
{
return static_cast<T1>(Value);
}
};
// Recursion terminator
template <typename T, T Value>
struct multicast<T, Value, void>
{
constexpr multicast() = default;
// Explicit conversion to base type
explicit constexpr operator T() const
{
return Value;
}
};
// Error code type (return type), implements error reporting. Could be a template.
struct error_code
{

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