From b6732fbae9f80df2af52754a7cffb1b1a680623e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 18 Apr 2021 11:26:49 +0100 Subject: [PATCH] MacOs build fix proposal. Made on Big Sur, removing few unnecessary old specifics. Build with LLVM homebrew. --- Utilities/Thread.cpp | 5 +++- rpcs3/Emu/NP/fb_helpers.cpp | 2 +- rpcs3/Emu/NP/np_handler.cpp | 4 +-- rpcs3/util/types.hpp | 51 ------------------------------------- 4 files changed, 7 insertions(+), 55 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 864be57071..7c171d0079 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2984,9 +2984,12 @@ std::pair thread_ctrl::get_thread_stack() void* saddr = 0; usz ssize = 0; pthread_attr_t attr; -#ifdef __linux__ +#if defined(__linux__) pthread_getattr_np(pthread_self(), &attr); pthread_attr_getstack(&attr, &saddr, &ssize); +#elif defined(__APPLE__) + saddr = pthread_get_stackaddr_np(pthread_self()); + ssize = pthread_get_stacksize_np(pthread_self()); #else pthread_attr_get_np(pthread_self(), &attr); pthread_attr_getstackaddr(&attr, &saddr); diff --git a/rpcs3/Emu/NP/fb_helpers.cpp b/rpcs3/Emu/NP/fb_helpers.cpp index 15a9763bbc..33f89b64c0 100644 --- a/rpcs3/Emu/NP/fb_helpers.cpp +++ b/rpcs3/Emu/NP/fb_helpers.cpp @@ -195,7 +195,7 @@ u16 np_handler::RoomDataInternal_to_SceNpMatching2RoomDataInternal(const RoomDat { if (room_info->roomGroup[g_index].groupId == member->roomGroup()) { - member_info->roomGroup = vm::cast(room_info->roomGroup.addr() + (sizeof(SceNpMatching2RoomGroup) * g_index)); + member_info->roomGroup = vm::cast(room_info->roomGroup.addr() + (u32{sizeof(SceNpMatching2RoomGroup)} * g_index)); found = true; } } diff --git a/rpcs3/Emu/NP/np_handler.cpp b/rpcs3/Emu/NP/np_handler.cpp index 5ab0334c3d..a0df056878 100644 --- a/rpcs3/Emu/NP/np_handler.cpp +++ b/rpcs3/Emu/NP/np_handler.cpp @@ -26,7 +26,7 @@ #include #endif -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__APPLE__) #include #include #endif @@ -139,7 +139,7 @@ bool np_handler::discover_ip_address() bool np_handler::discover_ether_address() { -#ifdef __FreeBSD__ +#if defined(__FreeBSD__) || defined(__APPLE__) ifaddrs* ifap; if (getifaddrs(&ifap) == 0) diff --git a/rpcs3/util/types.hpp b/rpcs3/util/types.hpp index 6b0e61e13a..e88697ab0a 100644 --- a/rpcs3/util/types.hpp +++ b/rpcs3/util/types.hpp @@ -80,11 +80,7 @@ using ulong = unsigned long; using ullong = unsigned long long; using llong = long long; -#if __APPLE__ -using uptr = std::uint64_t; -#else using uptr = std::uintptr_t; -#endif using u8 = std::uint8_t; using u16 = std::uint16_t; @@ -97,53 +93,6 @@ using s16 = std::int16_t; using s32 = std::int32_t; using s64 = std::int64_t; -#if __APPLE__ -namespace std -{ - template >> - constexpr int countr_zero(T x) noexcept - { - if (x == 0) - return sizeof(T) * 8; - if constexpr (sizeof(T) <= sizeof(uint)) - return __builtin_ctz(x); - else if constexpr (sizeof(T) <= sizeof(ulong)) - return __builtin_ctzl(x); - else if constexpr (sizeof(T) <= sizeof(ullong)) - return __builtin_ctzll(x); - else - static_assert(sizeof(T) <= sizeof(ullong)); - } - - template >> - constexpr int countr_one(T x) noexcept - { - return countr_zero(~x); - } - - template >> - constexpr int countl_zero(T x) noexcept - { - if (x == 0) - return sizeof(T) * 8; - if constexpr (sizeof(T) <= sizeof(uint)) - return __builtin_clz(x) - (sizeof(uint) - sizeof(T)) * 8; - else if constexpr (sizeof(T) <= sizeof(ulong)) - return __builtin_clzl(x) - (sizeof(ulong) - sizeof(T)) * 8; - else if constexpr (sizeof(T) <= sizeof(ullong)) - return __builtin_clzll(x) - (sizeof(ullong) - sizeof(T)) * 8; - else - static_assert(sizeof(T) <= sizeof(ullong)); - } - - template >> - constexpr int countl_one(T x) noexcept - { - return countl_zero(~x); - } -} -#endif - // Get integral type from type size template struct get_int_impl