Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils/endian.hpp: Use std::byteswap, fixup regression #14498

Merged
merged 2 commits into from Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions rpcs3/Emu/Cell/lv2/sys_sync.h
Expand Up @@ -60,6 +60,11 @@ enum

enum ppu_thread_status : u32;

namespace vm
{
extern u8 g_reservations[65536 / 128 * 64];
}

// Base class for some kernel objects (shared set of 8192 objects).
struct lv2_obj
{
Expand Down Expand Up @@ -432,9 +437,15 @@ struct lv2_obj

if (cpu != &g_to_notify)
{
// Note: by the time of notification the thread could have been deallocated which is why the direct function is used
// TODO: Pass a narrower mask
atomic_wait_engine::notify_one(cpu);
if (cpu >= vm::g_reservations && cpu <= vm::g_reservations + (std::size(vm::g_reservations) - 1))
{
atomic_wait_engine::notify_all(cpu);
}
else
{
// Note: by the time of notification the thread could have been deallocated which is why the direct function is used
atomic_wait_engine::notify_one(cpu);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Memory/vm.h
Expand Up @@ -22,7 +22,7 @@ namespace vm
extern u8* const g_exec_addr;
extern u8* const g_stat_addr;
extern u8* const g_free_addr;
extern u8 g_reservations[];
extern u8 g_reservations[65536 / 128 * 64];

struct writer_lock;

Expand Down
12 changes: 9 additions & 3 deletions rpcs3/util/endian.hpp
Expand Up @@ -35,7 +35,9 @@ namespace stx

static constexpr u16 swap(u16 src) noexcept
{
#if defined(__GNUG__)
#if __cpp_lib_byteswap >= 202110L
return std::byteswap(src);
#elif defined(__GNUG__)
return __builtin_bswap16(src);
#else
if (std::is_constant_evaluated())
Expand All @@ -55,7 +57,9 @@ namespace stx

static constexpr u32 swap(u32 src) noexcept
{
#if defined(__GNUG__)
#if __cpp_lib_byteswap >= 202110L
return std::byteswap(src);
#elif defined(__GNUG__)
return __builtin_bswap32(src);
#else
if (std::is_constant_evaluated())
Expand All @@ -76,7 +80,9 @@ namespace stx

static constexpr u64 swap(u64 src) noexcept
{
#if defined(__GNUG__)
#if __cpp_lib_byteswap >= 202110L
return std::byteswap(src);
#elif defined(__GNUG__)
return __builtin_bswap64(src);
#else
if (std::is_constant_evaluated())
Expand Down