diff --git a/Utilities/cond.cpp b/Utilities/cond.cpp index cc2de9b379..fda9a5cd84 100644 --- a/Utilities/cond.cpp +++ b/Utilities/cond.cpp @@ -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); diff --git a/Utilities/cond.h b/Utilities/cond.h index 4831911822..99eb82b83f 100644 --- a/Utilities/cond.h +++ b/Utilities/cond.h @@ -23,7 +23,7 @@ public: // Intrusive wait algorithm for lockable objects template - 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() { diff --git a/Utilities/event.h b/Utilities/event.h index ab9e690b58..ec5a0fa74e 100644 --- a/Utilities/event.h +++ b/Utilities/event.h @@ -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 expected, T state) + bool state_test_and_set(std::initializer_list expected, T state) { T _old; diff --git a/Utilities/types.h b/Utilities/types.h index ba6a8a7563..30221f616b 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -112,10 +112,6 @@ class se_t; template class atomic_t; -#if defined(__INTELLISENSE__) && !defined(_MSC_VER) -namespace std { template using void_t = void; } -#endif - // Extract T::simple_type if available, remove cv qualifiers template 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 - ignore(T) - { - } -}; - template ::value>> constexpr T align(const T& value, ullong align) { @@ -811,35 +783,6 @@ struct cmd64 : any64 static_assert(sizeof(cmd64) == 8 && std::is_pod::value, "Incorrect cmd64 type"); -// Allows to define integer convertible to multiple types -template -struct multicast : multicast -{ - constexpr multicast() - : multicast() - { - } - - // Implicit conversion to desired type - constexpr operator T1() const - { - return static_cast(Value); - } -}; - -// Recursion terminator -template -struct multicast -{ - 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 { diff --git a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp index 8fb3a96cff..8966202832 100644 --- a/rpcs3/Emu/Cell/Modules/cellSpurs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSpurs.cpp @@ -2038,7 +2038,7 @@ s32 _cellSpursWorkloadAttributeInitialize(vm::ptr 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 spurs, vm::ptr wid, vm::cptr taskset, vm::ptr 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; } diff --git a/rpcs3/Emu/Cell/Modules/cellSync.cpp b/rpcs3/Emu/Cell/Modules/cellSync.cpp index 933b383ab7..7911f709bd 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSync.cpp @@ -256,7 +256,7 @@ error_code cellSyncRwmInitialize(vm::ptr rwm, vm::ptr 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 queue, vm::ptr 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 queue, vm::cptr 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 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; } diff --git a/rpcs3/Emu/Cell/Modules/sys_mempool.cpp b/rpcs3/Emu/Cell/Modules/sys_mempool.cpp index 2e272b6cd8..017d53535b 100644 --- a/rpcs3/Emu/Cell/Modules/sys_mempool.cpp +++ b/rpcs3/Emu/Cell/Modules/sys_mempool.cpp @@ -54,7 +54,7 @@ s32 sys_mempool_create(ppu_thread& ppu, vm::ptr mempool, vm::ptr< } // Test chunk address aligment - if (chunk % 8) + if (!chunk.aligned(8)) { return CELL_EINVAL; } diff --git a/rpcs3/Emu/Cell/PPUAnalyser.cpp b/rpcs3/Emu/Cell/PPUAnalyser.cpp index f29be974dd..48069afae4 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.cpp +++ b/rpcs3/Emu/Cell/PPUAnalyser.cpp @@ -732,7 +732,7 @@ void ppu_module::analyse(u32 lib_toc, u32 entry) // Probe for (vm::cptr 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; diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 2919a7c8fa..1a410ff2ab 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -556,7 +556,7 @@ public: // Remove the ID template - static inline explicit_bool_t remove(u32 id) + static inline bool remove(u32 id) { std::shared_ptr ptr; { @@ -832,7 +832,7 @@ public: // Delete the object template - static inline explicit_bool_t remove() + static inline bool remove() { std::shared_ptr ptr; { diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 8426622123..3e9a84cb1e 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -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 operator +() const { return vm::cast(m_addr, HERE); diff --git a/rpcs3/Emu/Memory/vm_var.h b/rpcs3/Emu/Memory/vm_var.h index 5fa1f611de..a1c9c4d054 100644 --- a/rpcs3/Emu/Memory/vm_var.h +++ b/rpcs3/Emu/Memory/vm_var.h @@ -133,14 +133,14 @@ namespace vm template > [[nodiscard]] auto make_var(const T& value) { - return varb(value); + return (varb(value)); } // Make char[] variable initialized from std::string template > [[nodiscard]] auto make_str(const std::string& str) { - return _var_base(size32(str) + 1, str.c_str()); + return (_var_base(size32(str) + 1, str.c_str())); } // Global HLE variable