diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 0f8d05840a..2c48f72eb7 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -68,14 +68,16 @@ namespace vm return m_addr != 0; } + // test address alignment using alignof(T) bool aligned() const { return m_addr % alignof32(T) == 0; } - bool operator %(to_ne_t alignment) + // test address for arbitrary alignment or something + force_inline explicit_bool_t operator %(to_ne_t right) const { - return m_addr % alignment != 0; + return m_addr % right; } _ptr_base& operator =(const _ptr_base&) = default; diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 222c0c06e1..98b7a0a845 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -61,6 +61,22 @@ template::value>> in return static_cast((value + (align - 1)) & ~(align - 1)); } +// bool wrapper for restricting bool result conversions +struct explicit_bool_t +{ + const bool value; + + explicit_bool_t(bool value) + : value(value) + { + } + + explicit operator bool() const + { + return value; + } +}; + // return 32 bit sizeof() to avoid widening/narrowing conversions with size_t #define sizeof32(type) sizeof32_t::value