Initial macOS port bringup (#52)

This commit is contained in:
Marcin Chojnacki 2022-08-26 04:03:26 +02:00 committed by GitHub
parent a2abffd37b
commit 974edaa649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 157 additions and 122 deletions

View File

@ -20,11 +20,13 @@ if(MSVC)
# _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING # _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
# _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS # _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
elseif(UNIX) elseif(UNIX)
if(NOT APPLE)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) # legacy. Do we need to support XLIB surfaces?
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
endif()
add_definitions(-fms-extensions) add_definitions(-fms-extensions)
add_definitions(-fms-compatibility-version=19.14) add_definitions(-fms-compatibility-version=19.14)
add_definitions(-fdelayed-template-parsing) add_definitions(-fdelayed-template-parsing)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) # legacy. Do we need to support XLIB surfaces?
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
add_definitions(-maes) add_definitions(-maes)
# warnings # warnings
add_compile_options(-Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion -Wno-ambiguous-reversed-operator) add_compile_options(-Wno-switch -Wno-ignored-attributes -Wno-deprecated-enum-enum-conversion -Wno-ambiguous-reversed-operator)

View File

@ -364,7 +364,7 @@ void cemu_initForGame()
time_t theTime = (time(NULL) - 946684800); time_t theTime = (time(NULL) - 946684800);
{ {
tm* lt = localtime(&theTime); tm* lt = localtime(&theTime);
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
theTime = _mkgmtime(lt); theTime = _mkgmtime(lt);
#else #else
theTime = timegm(lt); theTime = timegm(lt);

View File

@ -1029,7 +1029,7 @@ bool FSTVerifier::VerifyContentFile(FileStream* fileContent, const NCrypto::AesK
SHA256_Init(&sha256Ctx); SHA256_Init(&sha256Ctx);
while (remainingBytes > 0) while (remainingBytes > 0)
{ {
uint32 bytesToRead = (uint32)std::min(remainingBytes, buffer.size()); uint32 bytesToRead = (uint32)std::min(remainingBytes, (uint64)buffer.size());
uint32 bytesToReadPadded = ((bytesToRead + 0xF) & ~0xF); uint32 bytesToReadPadded = ((bytesToRead + 0xF) & ~0xF);
uint32 bytesRead = fileContent->readData(buffer.data(), bytesToReadPadded); uint32 bytesRead = fileContent->readData(buffer.data(), bytesToReadPadded);
if (bytesRead != bytesToReadPadded) if (bytesRead != bytesToReadPadded)

View File

@ -8,7 +8,7 @@
#include "Cafe/OS/libs/coreinit/coreinit.h" #include "Cafe/OS/libs/coreinit/coreinit.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <Windows.h> #include <Windows.h>
#endif #endif
@ -158,7 +158,7 @@ void debugger_updateMemoryBreakpoint(DebuggerBreakpoint* bp)
{ {
std::vector<std::thread::native_handle_type> schedulerThreadHandles = coreinit::OSGetSchedulerThreads(); std::vector<std::thread::native_handle_type> schedulerThreadHandles = coreinit::OSGetSchedulerThreads();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
debuggerState.activeMemoryBreakpoint = bp; debuggerState.activeMemoryBreakpoint = bp;
for (auto& hThreadNH : schedulerThreadHandles) for (auto& hThreadNH : schedulerThreadHandles)
{ {

View File

@ -5,7 +5,7 @@
#include "util/helpers/fspinlock.h" #include "util/helpers/fspinlock.h"
#include "util/highresolutiontimer/HighResolutionTimer.h" #include "util/highresolutiontimer/HighResolutionTimer.h"
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
static __inline__ static __inline__
unsigned __int64 _umul128(unsigned __int64, unsigned __int64 _umul128(unsigned __int64,
unsigned __int64, unsigned __int64,
@ -113,7 +113,7 @@ uint64 PPCTimer_microsecondsToTsc(uint64 us)
uint64 PPCTimer_tscToMicroseconds(uint64 us) uint64 PPCTimer_tscToMicroseconds(uint64 us)
{ {
uint128_t r{}; uint128_t r{};
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
r.low = _umul128(us, 1000000ULL, &r.high); r.low = _umul128(us, 1000000ULL, &r.high);
#else #else
r.low = _umul128(us, 1000000ULL, (unsigned long long*)&r.high); r.low = _umul128(us, 1000000ULL, (unsigned long long*)&r.high);
@ -153,7 +153,7 @@ uint64 PPCTimer_getFromRDTSC()
rdtscDif = rdtscDif & ~(uint64)((sint64)rdtscDif >> 63); rdtscDif = rdtscDif & ~(uint64)((sint64)rdtscDif >> 63);
uint128_t diff{}; uint128_t diff{};
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, &diff.high); diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, &diff.high);
#else #else
diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, (unsigned long long*)&diff.high); diff.low = _umul128(rdtscDif, Espresso::CORE_CLOCK, (unsigned long long*)&diff.high);
@ -163,7 +163,7 @@ uint64 PPCTimer_getFromRDTSC()
_rdtscLastMeasure = rdtscCurrentMeasure; // only travel forward in time _rdtscLastMeasure = rdtscCurrentMeasure; // only travel forward in time
uint8 c = 0; uint8 c = 0;
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
c = _addcarry_u64(c, _rdtscAcc.low, diff.low, &_rdtscAcc.low); c = _addcarry_u64(c, _rdtscAcc.low, diff.low, &_rdtscAcc.low);
_addcarry_u64(c, _rdtscAcc.high, diff.high, &_rdtscAcc.high); _addcarry_u64(c, _rdtscAcc.high, diff.high, &_rdtscAcc.high);
#else #else

View File

@ -72,7 +72,7 @@ void PPCRecompiler_recompileIfUnvisited(uint32 enterAddress)
void PPCRecompiler_enter(PPCInterpreter_t* hCPU, PPCREC_JUMP_ENTRY funcPtr) void PPCRecompiler_enter(PPCInterpreter_t* hCPU, PPCREC_JUMP_ENTRY funcPtr)
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
uint32 prevState = _controlfp(0, 0); uint32 prevState = _controlfp(0, 0);
_controlfp(_RC_NEAR, _MCW_RC); _controlfp(_RC_NEAR, _MCW_RC);
PPCRecompiler_enterRecompilerCode((uint64)funcPtr, (uint64)hCPU); PPCRecompiler_enterRecompilerCode((uint64)funcPtr, (uint64)hCPU);

View File

@ -284,7 +284,7 @@ void LatteIndices_generateAutoLineLoopIndices(void* indexDataOutput, uint32 coun
indexMax = std::max(count, 1u) - 1; indexMax = std::max(count, 1u) - 1;
} }
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function) #pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
#endif #endif
@ -352,11 +352,11 @@ void LatteIndices_fastConvertU16_AVX2(const void* indexDataInput, void* indexDat
indexMin = std::min(indexMin, _minIndex); indexMin = std::min(indexMin, _minIndex);
} }
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#pragma clang attribute pop #pragma clang attribute pop
#endif #endif
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function) #pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
#endif #endif
@ -423,11 +423,11 @@ void LatteIndices_fastConvertU16_SSE41(const void* indexDataInput, void* indexDa
indexMin = std::min(indexMin, _minIndex); indexMin = std::min(indexMin, _minIndex);
} }
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#pragma clang attribute pop #pragma clang attribute pop
#endif #endif
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function) #pragma clang attribute push (__attribute__((target("avx2"))), apply_to=function)
#endif #endif
@ -497,7 +497,7 @@ void LatteIndices_fastConvertU32_AVX2(const void* indexDataInput, void* indexDat
indexMin = std::min(indexMin, _minIndex); indexMin = std::min(indexMin, _minIndex);
} }
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#pragma clang attribute pop #pragma clang attribute pop
#endif #endif

View File

@ -27,7 +27,7 @@
#include <wx/msgdlg.h> #include <wx/msgdlg.h>
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <psapi.h> #include <psapi.h>
#endif #endif
@ -189,7 +189,7 @@ void LatteShaderCache_load()
const auto timeLoadStart = now_cached(); const auto timeLoadStart = now_cached();
// remember current amount of committed memory // remember current amount of committed memory
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
PROCESS_MEMORY_COUNTERS pmc1; PROCESS_MEMORY_COUNTERS pmc1;
GetProcessMemoryInfo(GetCurrentProcess(), &pmc1, sizeof(PROCESS_MEMORY_COUNTERS)); GetProcessMemoryInfo(GetCurrentProcess(), &pmc1, sizeof(PROCESS_MEMORY_COUNTERS));
LONGLONG totalMem1 = pmc1.PagefileUsage; LONGLONG totalMem1 = pmc1.PagefileUsage;
@ -285,7 +285,7 @@ void LatteShaderCache_load()
LatteShaderCache_updateCompileQueue(0); LatteShaderCache_updateCompileQueue(0);
// write load time and RAM usage to log file (in dev build) // write load time and RAM usage to log file (in dev build)
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
const auto timeLoadEnd = now_cached(); const auto timeLoadEnd = now_cached();
const auto timeLoad = std::chrono::duration_cast<std::chrono::milliseconds>(timeLoadEnd - timeLoadStart).count(); const auto timeLoad = std::chrono::duration_cast<std::chrono::milliseconds>(timeLoadEnd - timeLoadStart).count();
PROCESS_MEMORY_COUNTERS pmc2; PROCESS_MEMORY_COUNTERS pmc2;

View File

@ -145,7 +145,7 @@ uint32 LatteTexture_CalculateTextureDataHash(LatteTexture* hostTexture)
bool isCompressedFormat = hostTexture->IsCompressedFormat(); bool isCompressedFormat = hostTexture->IsCompressedFormat();
if( isCompressedFormat == false ) if( isCompressedFormat == false )
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
if (_cpuExtension_AVX2) if (_cpuExtension_AVX2)
{ {
__m256i h256 = { 0 }; __m256i h256 = { 0 };

View File

@ -7,7 +7,7 @@ using namespace Latte;
namespace LatteAddrLib namespace LatteAddrLib
{ {
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
unsigned char _BitScanReverse(uint32* _Index, uint32 _Mask) unsigned char _BitScanReverse(uint32* _Index, uint32 _Mask)
{ {
if (!_Mask) if (!_Mask)

View File

@ -95,7 +95,7 @@ OpenGLRenderer::OpenGLRenderer()
glRendererState.uploadIndex = 0; glRendererState.uploadIndex = 0;
} }
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
try try
{ {
m_dxgi_wrapper = std::make_unique<DXGIWrapper>(); m_dxgi_wrapper = std::make_unique<DXGIWrapper>();
@ -191,7 +191,7 @@ void OpenGLRenderer::DeleteFontTextures()
typedef void(*GL_IMPORT)(); typedef void(*GL_IMPORT)();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
GL_IMPORT _GetOpenGLFunction(HMODULE hLib, const char* name) GL_IMPORT _GetOpenGLFunction(HMODULE hLib, const char* name)
{ {
GL_IMPORT r = (GL_IMPORT)wglGetProcAddress(name); GL_IMPORT r = (GL_IMPORT)wglGetProcAddress(name);
@ -207,7 +207,7 @@ void LoadOpenGLImports()
#include "Common/GLInclude/glFunctions.h" #include "Common/GLInclude/glFunctions.h"
#undef GLFUNC #undef GLFUNC
} }
#else #elif BOOST_OS_LINUX
GL_IMPORT _GetOpenGLFunction(void* hLib, PFNGLXGETPROCADDRESSPROC func, const char* name) GL_IMPORT _GetOpenGLFunction(void* hLib, PFNGLXGETPROCADDRESSPROC func, const char* name)
{ {
GL_IMPORT r = (GL_IMPORT)func((const GLubyte*)name); GL_IMPORT r = (GL_IMPORT)func((const GLubyte*)name);
@ -233,6 +233,11 @@ void LoadOpenGLImports()
#include "Common/GLInclude/glFunctions.h" #include "Common/GLInclude/glFunctions.h"
#undef GLFUNC #undef GLFUNC
} }
#elif BOOST_OS_MACOS
void LoadOpenGLImports()
{
cemu_assert_unimplemented();
}
#endif #endif
void OpenGLRenderer::Initialize() void OpenGLRenderer::Initialize()
@ -244,7 +249,7 @@ void OpenGLRenderer::Initialize()
LoadOpenGLImports(); LoadOpenGLImports();
GetVendorInformation(); GetVendorInformation();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
if (wglSwapIntervalEXT) if (wglSwapIntervalEXT)
wglSwapIntervalEXT(0); // disable V-Sync per default wglSwapIntervalEXT(0); // disable V-Sync per default
#endif #endif
@ -349,7 +354,7 @@ void OpenGLRenderer::NotifyLatteCommandProcessorIdle()
void OpenGLRenderer::EnableVSync(int state) void OpenGLRenderer::EnableVSync(int state)
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
if(wglSwapIntervalEXT) if(wglSwapIntervalEXT)
wglSwapIntervalEXT(state); // 1 = enabled, 0 = disabled wglSwapIntervalEXT(state); // 1 = enabled, 0 = disabled
#else #else

View File

@ -2,7 +2,7 @@
#define VKFUNC_DEFINE #define VKFUNC_DEFINE
#include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h" #include "Cafe/HW/Latte/Renderer/Vulkan/VulkanAPI.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif

View File

@ -104,7 +104,7 @@ std::vector<VulkanRenderer::DeviceInfo> VulkanRenderer::GetDevices()
requiredExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME); requiredExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
#if BOOST_OS_WINDOWS #if BOOST_OS_WINDOWS
requiredExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); requiredExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#else #elif BOOST_OS_LINUX
requiredExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); requiredExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
#endif #endif
@ -1143,7 +1143,7 @@ std::vector<const char*> VulkanRenderer::CheckInstanceExtensionSupport(FeatureCo
requiredInstanceExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME); requiredInstanceExtensions.emplace_back(VK_KHR_SURFACE_EXTENSION_NAME);
#if BOOST_OS_WINDOWS #if BOOST_OS_WINDOWS
requiredInstanceExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); requiredInstanceExtensions.emplace_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#else #elif BOOST_OS_LINUX
requiredInstanceExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); requiredInstanceExtensions.emplace_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME);
#endif #endif
if (cafeLog_isLoggingFlagEnabled(LOG_TYPE_VULKAN_VALIDATION)) if (cafeLog_isLoggingFlagEnabled(LOG_TYPE_VULKAN_VALIDATION))
@ -1319,8 +1319,11 @@ VkSurfaceKHR VulkanRenderer::CreateFramebufferSurface(VkInstance instance, struc
{ {
#if BOOST_OS_WINDOWS #if BOOST_OS_WINDOWS
return CreateWinSurface(instance, windowInfo.hwnd); return CreateWinSurface(instance, windowInfo.hwnd);
#else #elif BOOST_OS_LINUX
return CreateXlibSurface(instance, windowInfo.xlib_display, windowInfo.xlib_window); return CreateXlibSurface(instance, windowInfo.xlib_display, windowInfo.xlib_window);
#elif BOOST_OS_MACOS
cemu_assert_unimplemented();
return nullptr;
#endif #endif
} }

View File

@ -201,6 +201,9 @@ static uint16 CPU_swapEndianU16(uint16 v)
#elif BOOST_OS_LINUX #elif BOOST_OS_LINUX
#define CPU_swapEndianU64(_v) bswap_64((uint64)(_v)) #define CPU_swapEndianU64(_v) bswap_64((uint64)(_v))
#define CPU_swapEndianU32(_v) bswap_32((uint32)(_v)) #define CPU_swapEndianU32(_v) bswap_32((uint32)(_v))
#elif BOOST_OS_MACOS
#define CPU_swapEndianU64(_v) OSSwapInt64((uint64)(_v))
#define CPU_swapEndianU32(_v) OSSwapInt32((uint32)(_v))
#endif #endif
// direct memory access (no hardware interface access) // direct memory access (no hardware interface access)

View File

@ -78,7 +78,7 @@ void CafeInit()
rpxPathStart = 0; rpxPathStart = 0;
} }
std::string_view rpxFileName = std::basic_string_view<char>(_pathToExecutable.data() + rpxPathStart, _pathToExecutable.data() + _pathToExecutable.size()); std::string_view rpxFileName(_pathToExecutable.data() + rpxPathStart, _pathToExecutable.size() - rpxPathStart);
argStorageIndex = 0; argStorageIndex = 0;
_coreinitInfo->argc = 0; _coreinitInfo->argc = 0;

View File

@ -424,7 +424,7 @@ typedef struct
static_assert(sizeof(UCParamStruct_t) == 0x54); // unsure static_assert(sizeof(UCParamStruct_t) == 0x54); // unsure
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#define _strcmpi strcasecmp #define _strcmpi strcasecmp
#endif #endif

View File

@ -63,7 +63,8 @@ namespace coreinit
bool negativeAlignment = alignment < 0; bool negativeAlignment = alignment < 0;
if (negativeAlignment) if (negativeAlignment)
alignment = -alignment; alignment = -alignment;
if (!std::has_single_bit<uint32>((uint32)alignment)) uint32 bits = (uint32)alignment;
if (bits == 0 || (bits & (bits - 1)) != 0)
{ {
cemuLog_log(LogType::APIErrors, "MEMGetAllocatableSizeForFrmHeapEx(): Invalid alignment"); cemuLog_log(LogType::APIErrors, "MEMGetAllocatableSizeForFrmHeapEx(): Invalid alignment");
return 0; return 0;

View File

@ -455,7 +455,7 @@ void export_curl_multi_fdset(PPCInterpreter_t* hCPU)
ppcDefineParamMEMPTR(exceptionFd, wu_fd_set, 3); ppcDefineParamMEMPTR(exceptionFd, wu_fd_set, 3);
ppcDefineParamU32BEPtr(maxFd, 4); ppcDefineParamU32BEPtr(maxFd, 4);
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
cemuLog_log(LogType::Force, "curl_multi_fdset(...) - todo"); cemuLog_log(LogType::Force, "curl_multi_fdset(...) - todo");
osLib_returnFromFunction(hCPU, 0); osLib_returnFromFunction(hCPU, 0);

View File

@ -242,7 +242,7 @@ namespace save
} }
catch (const std::exception& ex) catch (const std::exception& ex)
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
std::wstringstream errorMsg; std::wstringstream errorMsg;
errorMsg << L"Couldn't move your save files!" << std::endl << std::endl; errorMsg << L"Couldn't move your save files!" << std::endl << std::endl;
errorMsg << L"Error: " << ex.what() << std::endl << std::endl; errorMsg << L"Error: " << ex.what() << std::endl << std::endl;

View File

@ -3,7 +3,7 @@
#include <bitset> #include <bitset>
#include "nsyshid.h" #include "nsyshid.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <setupapi.h> #include <setupapi.h>
#include <initguid.h> #include <initguid.h>

View File

@ -6,7 +6,7 @@
#include "Common/socket.h" #include "Common/socket.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#define WU_AF_INET 2 #define WU_AF_INET 2
@ -2085,7 +2085,7 @@ void nsysnet_load()
osLib_addFunction("nsysnet", "NSSLExportInternalClientCertificate", nsysnet::export_NSSLExportInternalClientCertificate); osLib_addFunction("nsysnet", "NSSLExportInternalClientCertificate", nsysnet::export_NSSLExportInternalClientCertificate);
} }
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
void nsysnet_notifyCloseSharedSocket(SOCKET existingSocket) void nsysnet_notifyCloseSharedSocket(SOCKET existingSocket)
{ {

View File

@ -2,7 +2,7 @@
#include <set> #include <set>
#include <vector> #include <vector>
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <WinSock2.h> #include <WinSock2.h>
#else #else
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -12,7 +12,7 @@
#include <fmt/format.h> #include <fmt/format.h>
#ifdef __clang__ #ifdef __clang__
#include "Common/linux/fast_float.h" #include "Common/unix/fast_float.h"
#define _EP_FROM_CHARS_DBL(...) _convFastFloatResult(fast_float::from_chars(__VA_ARGS__)) #define _EP_FROM_CHARS_DBL(...) _convFastFloatResult(fast_float::from_chars(__VA_ARGS__))
inline std::from_chars_result _convFastFloatResult(fast_float::from_chars_result r) inline std::from_chars_result _convFastFloatResult(fast_float::from_chars_result r)

View File

@ -200,7 +200,7 @@ void cafeLog_log(uint32 type, const char* format, ...)
char logTempStr[2048]; char logTempStr[2048];
va_list(args); va_list(args);
va_start(args, format); va_start(args, format);
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
vsprintf_s(logTempStr, format, args); vsprintf_s(logTempStr, format, args);
#else #else
vsprintf(logTempStr, format, args); vsprintf(logTempStr, format, args);
@ -226,7 +226,7 @@ void cafeLog_logW(uint32 type, const wchar_t* format, ...)
wchar_t logTempStr[2048]; wchar_t logTempStr[2048];
va_list(args); va_list(args);
va_start(args, format); va_start(args, format);
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
vswprintf_s(logTempStr, format, args); vswprintf_s(logTempStr, format, args);
#else #else
vswprintf(logTempStr, 2048, format, args); vswprintf(logTempStr, 2048, format, args);

View File

@ -628,7 +628,7 @@ public:
ppcAssembler_setError(assemblerCtx->ctx, fmt::format("\'{}\' does not end with valid memory register syntax. Memory operand must have the form offset(gpr). Example: 0x20(r3)", svOpText)); ppcAssembler_setError(assemblerCtx->ctx, fmt::format("\'{}\' does not end with valid memory register syntax. Memory operand must have the form offset(gpr). Example: 0x20(r3)", svOpText));
return false; return false;
} }
std::string_view svExpressionPart(startPtr, endPtr); std::string_view svExpressionPart(startPtr, endPtr - startPtr);
std::string_view svRegPart(memoryRegBegin, memoryRegEnd - memoryRegBegin); std::string_view svRegPart(memoryRegBegin, memoryRegEnd - memoryRegBegin);
sint32 memGpr = _parseRegIndex(svRegPart, "r"); sint32 memGpr = _parseRegIndex(svRegPart, "r");
//if (_ppcAssembler_parseRegister(svRegPart, "r", memGpr) == false || (memGpr < 0 || memGpr >= 32)) //if (_ppcAssembler_parseRegister(svRegPart, "r", memGpr) == false || (memGpr < 0 || memGpr >= 32))

View File

@ -5,7 +5,7 @@
#include "util/crypto/md5.h" #include "util/crypto/md5.h"
// for inet_pton: // for inet_pton:
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <WS2tcpip.h> #include <WS2tcpip.h>
#else #else
#include <arpa/inet.h> #include <arpa/inet.h>

View File

@ -529,7 +529,7 @@ prudpClient::prudpClient(uint32 dstIp, uint16 dstPort, const char* key) : prudpC
break; break;
} }
// set socket to non-blocking mode // set socket to non-blocking mode
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
u_long nonBlockingMode = 1; // 1 to enable non-blocking socket u_long nonBlockingMode = 1; // 1 to enable non-blocking socket
ioctlsocket(socketUdp, FIONBIO, &nonBlockingMode); ioctlsocket(socketUdp, FIONBIO, &nonBlockingMode);
#else #else

View File

@ -17,8 +17,8 @@ PRIVATE
else() else()
target_sources(CemuCommon target_sources(CemuCommon
PRIVATE PRIVATE
linux/platform.cpp unix/platform.cpp
linux/platform.h unix/platform.h
) )
endif() endif()

View File

@ -1,7 +1,7 @@
#include "Common/precompiled.h" #include "Common/precompiled.h"
#include "Cafe/CafeSystem.h" #include "Cafe/CafeSystem.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include <signal.h> #include <signal.h>
#include <execinfo.h> #include <execinfo.h>
#endif #endif

View File

@ -6,11 +6,12 @@
#if BOOST_OS_WINDOWS #if BOOST_OS_WINDOWS
#include "Common/windows/platform.h" #include "Common/windows/platform.h"
#elif BOOST_OS_LINUX #elif BOOST_OS_LINUX
#include "byteswap.h" #include <byteswap.h>
//#include <boost/core/enable_if.hpp> #include <X11/Xlib.h>
// #include <boost/type_traits.hpp> #include <X11/extensions/Xrender.h>
#include "Common/linux/platform.h" #include <X11/Xutil.h>
#include "Common/unix/platform.h"
#elif BOOST_OS_MACOS #elif BOOST_OS_MACOS
#include <libkern/OSByteOrder.h>
#include "Common/unix/platform.h"
#endif #endif

View File

@ -144,22 +144,32 @@ inline sint16 _swapEndianS16(sint16 v)
{ {
return (sint16)(((uint16)v >> 8) | ((uint16)v << 8)); return (sint16)(((uint16)v >> 8) | ((uint16)v << 8));
} }
#endif #else
#if BOOST_OS_LINUX
inline uint64 _swapEndianU64(uint64 v) inline uint64 _swapEndianU64(uint64 v)
{ {
#if BOOST_OS_MACOS
return OSSwapInt64(v);
#else
return bswap_64(v); return bswap_64(v);
#endif
} }
inline uint32 _swapEndianU32(uint32 v) inline uint32 _swapEndianU32(uint32 v)
{ {
#if BOOST_OS_MACOS
return OSSwapInt32(v);
#else
return bswap_32(v); return bswap_32(v);
#endif
} }
inline sint32 _swapEndianS32(sint32 v) inline sint32 _swapEndianS32(sint32 v)
{ {
#if BOOST_OS_MACOS
return (sint32)OSSwapInt32((uint32)v);
#else
return (sint32)bswap_32((uint32)v); return (sint32)bswap_32((uint32)v);
#endif
} }
inline uint16 _swapEndianU16(uint16 v) inline uint16 _swapEndianU16(uint16 v)

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <WinSock2.h> #include <WinSock2.h>
typedef int socklen_t; typedef int socklen_t;

View File

@ -32,9 +32,6 @@ inline uint32_t GetExceptionError()
return errno; return errno;
} }
#include <X11/Xlib.h>
#include <X11/extensions/Xrender.h>
#include <X11/Xutil.h>
#undef False #undef False
#undef True #undef True
#undef None #undef None

View File

@ -12,7 +12,11 @@ set_source_files_properties(x64util_masm.asm PROPERTIES LANGUAGE ASM_MASM)
ELSE() ELSE()
# NASM # NASM
IF (APPLE)
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f macho64 --prefix _ -o <OBJECT> <SOURCE>")
ELSE()
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f elf64 -o <OBJECT> <SOURCE>") set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> -g -Fdwarf -f elf64 -o <OBJECT> <SOURCE>")
ENDIF()
set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> -fPIC <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") set(CMAKE_ASM_NASM_LINK_EXECUTABLE "ld <FLAGS> <CMAKE_ASM_NASM_LINK_FLAGS> <LINK_FLAGS> -fPIC <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
enable_language(C ASM_NASM) enable_language(C ASM_NASM)
@ -22,7 +26,11 @@ x64util_nasm.asm
) )
set_source_files_properties(x64util_nasm.asm PROPERTIES LANGUAGE ASM_NASM) set_source_files_properties(x64util_nasm.asm PROPERTIES LANGUAGE ASM_NASM)
IF (APPLE)
set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT macho64)
ELSE()
set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT elf64) set_target_properties(CemuAsm PROPERTIES NASM_OBJ_FORMAT elf64)
ENDIF()
set_target_properties(CemuAsm PROPERTIES LINKER_LANGUAGE C) set_target_properties(CemuAsm PROPERTIES LINKER_LANGUAGE C)
ENDIF() ENDIF()

View File

@ -1,6 +1,6 @@
#include "IAudioAPI.h" #include "IAudioAPI.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include "XAudio2API.h" #include "XAudio2API.h"
#include "XAudio27API.h" #include "XAudio27API.h"
#include "DirectSoundAPI.h" #include "DirectSoundAPI.h"
@ -37,7 +37,7 @@ void IAudioAPI::PrintLogging()
void IAudioAPI::InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample) void IAudioAPI::InitWFX(sint32 samplerate, sint32 channels, sint32 bits_per_sample)
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
// move this to Windows-specific audio API implementations and use a cross-platform format here // move this to Windows-specific audio API implementations and use a cross-platform format here
m_wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; m_wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
m_wfx.Format.nChannels = channels; m_wfx.Format.nChannels = channels;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <mmreg.h> #include <mmreg.h>
#endif #endif
@ -64,7 +64,7 @@ public:
static std::vector<DeviceDescriptionPtr> GetDevices(AudioAPI api); static std::vector<DeviceDescriptionPtr> GetDevices(AudioAPI api);
protected: protected:
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
WAVEFORMATEXTENSIBLE m_wfx{}; WAVEFORMATEXTENSIBLE m_wfx{};
#endif #endif

View File

@ -406,7 +406,7 @@ public:
} }
FILE* file = nullptr; FILE* file = nullptr;
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
file = _wfopen(tmp_name.c_str(), L"wb"); file = _wfopen(tmp_name.c_str(), L"wb");
#else #else
file = fopen(boost::nowide::narrow(tmp_name).c_str(), "wb"); file = fopen(boost::nowide::narrow(tmp_name).c_str(), "wb");

View File

@ -150,7 +150,7 @@ bool CemuApp::OnInit()
int CemuApp::OnExit() int CemuApp::OnExit()
{ {
wxApp::OnExit(); wxApp::OnExit();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
ExitProcess(0); ExitProcess(0);
#else #else
exit(0); exit(0);
@ -306,7 +306,7 @@ void CemuApp::CreateDefaultFiles(bool first_start)
std::stringstream errorMsg; std::stringstream errorMsg;
errorMsg << fmt::format(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString(), ex.what(), boost::nowide::narrow(mlc)); errorMsg << fmt::format(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString(), ex.what(), boost::nowide::narrow(mlc));
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
const DWORD lastError = GetLastError(); const DWORD lastError = GetLastError();
if (lastError != ERROR_SUCCESS) if (lastError != ERROR_SUCCESS)
errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError));
@ -332,7 +332,7 @@ void CemuApp::CreateDefaultFiles(bool first_start)
std::stringstream errorMsg; std::stringstream errorMsg;
errorMsg << fmt::format(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString(), ex.what()); errorMsg << fmt::format(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString(), ex.what());
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
const DWORD lastError = GetLastError(); const DWORD lastError = GetLastError();
if (lastError != ERROR_SUCCESS) if (lastError != ERROR_SUCCESS)
errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError)); errorMsg << fmt::format("\n\n{}", GetSystemErrorMessage(lastError));

View File

@ -515,7 +515,7 @@ void CemuUpdateWindow::OnClose(wxCloseEvent& event)
{ {
event.Skip(); event.Skip();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
if (m_restart_required && !m_restart_file.empty() && fs::exists(m_restart_file)) if (m_restart_required && !m_restart_file.empty() && fs::exists(m_restart_file))
{ {
PROCESS_INFORMATION pi{}; PROCESS_INFORMATION pi{};

View File

@ -11,8 +11,8 @@
#include "gui/helpers/wxHelpers.h" #include "gui/helpers/wxHelpers.h"
#include "input/InputManager.h" #include "input/InputManager.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id) GameProfileWindow::GameProfileWindow(wxWindow* parent, uint64_t title_id)

View File

@ -16,7 +16,7 @@
#include "config/CemuConfig.h" #include "config/CemuConfig.h"
#include "audio/IAudioAPI.h" #include "audio/IAudioAPI.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include "audio/DirectSoundAPI.h" #include "audio/DirectSoundAPI.h"
#include "audio/XAudio27API.h" #include "audio/XAudio27API.h"
#endif #endif
@ -31,7 +31,7 @@
#include "gui/dialogs/CreateAccount/wxCreateAccountDialog.h" #include "gui/dialogs/CreateAccount/wxCreateAccountDialog.h"
#include "config/PermanentStorage.h" #include "config/PermanentStorage.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <VersionHelpers.h> #include <VersionHelpers.h>
#endif #endif
@ -39,8 +39,8 @@
#include "config/ActiveSettings.h" #include "config/ActiveSettings.h"
#include "gui/helpers/wxHelpers.h" #include "gui/helpers/wxHelpers.h"
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
#include "Cafe/CafeSystem.h" #include "Cafe/CafeSystem.h"
@ -649,7 +649,7 @@ wxPanel* GeneralSettings2::AddAccountPage(wxNotebook* notebook)
{ {
m_account_information = new wxCollapsiblePane(online_panel, wxID_ANY, _("Account information")); m_account_information = new wxCollapsiblePane(online_panel, wxID_ANY, _("Account information"));
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
m_account_information->GetControlWidget()->SetBackgroundColour(*wxWHITE); m_account_information->GetControlWidget()->SetBackgroundColour(*wxWHITE);
#endif #endif
auto win = m_account_information->GetPane(); auto win = m_account_information->GetPane();
@ -1063,7 +1063,7 @@ void GeneralSettings2::ResetAccountInformation()
// refresh pane size // refresh pane size
m_account_information->InvalidateBestSize(); m_account_information->InvalidateBestSize();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
m_account_information->OnStateChange(GetBestSize()); m_account_information->OnStateChange(GetBestSize());
#endif #endif
} }

View File

@ -15,8 +15,8 @@
#include "Cafe/TitleList/TitleList.h" #include "Cafe/TitleList/TitleList.h"
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
#include "wxHelper.h" #include "wxHelper.h"

View File

@ -10,8 +10,8 @@
#include "Cafe/CafeSystem.h" #include "Cafe/CafeSystem.h"
#include "Cafe/TitleList/TitleList.h" #include "Cafe/TitleList/TitleList.h"
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
// main.cpp // main.cpp

View File

@ -50,12 +50,12 @@
#include "gui/input/InputSettings2.h" #include "gui/input/InputSettings2.h"
#include "input/InputManager.h" #include "input/InputManager.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#define exit(__c) ExitProcess(__c) #define exit(__c) ExitProcess(__c)
#endif #endif
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
#include "Cafe/TitleList/TitleInfo.h" #include "Cafe/TitleList/TitleInfo.h"
@ -296,7 +296,7 @@ MainWindow::MainWindow()
SetClientSize(1280, 720); SetClientSize(1280, 720);
SetIcon(wxICON(M_WND_ICON128)); SetIcon(wxICON(M_WND_ICON128));
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
HICON hWindowIcon = (HICON)LoadImageA(NULL, "M_WND_ICON16", IMAGE_ICON, 16, 16, LR_LOADFROMFILE); HICON hWindowIcon = (HICON)LoadImageA(NULL, "M_WND_ICON16", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
SendMessage(this->GetHWND(), WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon); SendMessage(this->GetHWND(), WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon);
#endif #endif
@ -650,7 +650,7 @@ void MainWindow::OnInstallUpdate(wxCommandEvent& event)
break; break;
if (modalChoice == wxID_OK) if (modalChoice == wxID_OK)
{ {
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
fs::path dirPath((const char*)(openDirDialog.GetPath().fn_str())); fs::path dirPath((const char*)(openDirDialog.GetPath().fn_str()));
#else #else
fs::path dirPath(openDirDialog.GetPath().fn_str()); fs::path dirPath(openDirDialog.GetPath().fn_str());

View File

@ -13,8 +13,8 @@
#include "gui/helpers/wxHelpers.h" #include "gui/helpers/wxHelpers.h"
#include "input/InputManager.h" #include "input/InputManager.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
#include "wxHelper.h" #include "wxHelper.h"

View File

@ -42,8 +42,8 @@
#include "Cafe/TitleList/TitleList.h" #include "Cafe/TitleList/TitleList.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
#include "Cafe/TitleList/SaveList.h" #include "Cafe/TitleList/SaveList.h"

View File

@ -20,7 +20,7 @@
#include "util/helpers/helpers.h" #include "util/helpers/helpers.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
enum enum

View File

@ -159,9 +159,9 @@ typedef void GdkDisplay;
void gui_initHandleContextFromWxWidgetsWindow(WindowHandleInfo& handleInfoOut, class wxWindow* wxw) void gui_initHandleContextFromWxWidgetsWindow(WindowHandleInfo& handleInfoOut, class wxWindow* wxw)
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
handleInfoOut.hwnd = wxw->GetHWND(); handleInfoOut.hwnd = wxw->GetHWND();
#else #elif BOOST_OS_LINUX
/* dynamically retrieve GTK imports so we dont have to include and link the whole lib */ /* dynamically retrieve GTK imports so we dont have to include and link the whole lib */
void (*dyn_gtk_widget_realize)(GtkWidget *widget); void (*dyn_gtk_widget_realize)(GtkWidget *widget);
dyn_gtk_widget_realize = (void(*)(GtkWidget* widget))dlsym(RTLD_NEXT, "gtk_widget_realize"); dyn_gtk_widget_realize = (void(*)(GtkWidget* widget))dlsym(RTLD_NEXT, "gtk_widget_realize");

View File

@ -2,7 +2,7 @@
#include <atomic> #include <atomic>
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX
#include "xcb/xproto.h" #include "xcb/xproto.h"
#endif #endif

View File

@ -30,7 +30,7 @@
#include "util/EventService.h" #include "util/EventService.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX
#include "resource/linux/resources.h" #include "resource/embedded/resources.h"
#endif #endif
bool g_inputConfigWindowHasFocus = false; bool g_inputConfigWindowHasFocus = false;

View File

@ -28,14 +28,14 @@
#include "Cafe/OS/libs/vpad/vpad.h" #include "Cafe/OS/libs/vpad/vpad.h"
#include "audio/IAudioAPI.h" #include "audio/IAudioAPI.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#pragma comment(lib,"Dbghelp.lib") #pragma comment(lib,"Dbghelp.lib")
#endif #endif
#define SDL_MAIN_HANDLED #define SDL_MAIN_HANDLED
#include <SDL.h> #include <SDL.h>
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
#define _putenv(__s) putenv((char*)(__s)) #define _putenv(__s) putenv((char*)(__s))
#endif #endif
@ -61,7 +61,7 @@ bool IsCemuhookLoaded()
void checkForCemuhook() void checkForCemuhook()
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
// check if there is a dbghelp.dll in the current working directory // check if there is a dbghelp.dll in the current working directory
if (!fs::exists(ActiveSettings::GetPath("cemuhook.dll"))) if (!fs::exists(ActiveSettings::GetPath("cemuhook.dll")))
return; return;
@ -93,7 +93,7 @@ void checkForCemuhook()
void logCPUAndMemoryInfo() void logCPUAndMemoryInfo()
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
int CPUInfo[4] = { -1 }; int CPUInfo[4] = { -1 };
unsigned nExIds, i = 0; unsigned nExIds, i = 0;
char CPUBrandString[0x40]; char CPUBrandString[0x40];
@ -129,7 +129,7 @@ bool IsRunningInWine()
void checkForWine() void checkForWine()
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
const HMODULE hmodule = GetModuleHandleA("ntdll.dll"); const HMODULE hmodule = GetModuleHandleA("ntdll.dll");
if (!hmodule) if (!hmodule)
return; return;
@ -206,7 +206,7 @@ void reconfigureGLDrivers()
std::string nvCacheDirEnvOption("__GL_SHADER_DISK_CACHE_PATH="); std::string nvCacheDirEnvOption("__GL_SHADER_DISK_CACHE_PATH=");
nvCacheDirEnvOption.append(_utf8Wrapper(nvCacheDir)); nvCacheDirEnvOption.append(_utf8Wrapper(nvCacheDir));
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
std::wstring tmpW = boost::nowide::widen(nvCacheDirEnvOption); std::wstring tmpW = boost::nowide::widen(nvCacheDirEnvOption);
_wputenv(tmpW.c_str()); _wputenv(tmpW.c_str());
#else #else
@ -239,7 +239,7 @@ void mainEmulatorCommonInit()
__cpuidex(cpuInfo, 0x7, 0); __cpuidex(cpuInfo, 0x7, 0);
_cpuExtension_AVX2 = ((cpuInfo[1] >> 5) & 1) != 0; _cpuExtension_AVX2 = ((cpuInfo[1] >> 5) & 1) != 0;
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
executablePath.resize(4096); executablePath.resize(4096);
int i = GetModuleFileName(NULL, executablePath.data(), executablePath.size()); int i = GetModuleFileName(NULL, executablePath.data(), executablePath.size());
if(i >= 0) if(i >= 0)
@ -324,7 +324,7 @@ int mainEmulatorHLE()
bool isConsoleConnected = false; bool isConsoleConnected = false;
void requireConsole() void requireConsole()
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
if (isConsoleConnected) if (isConsoleConnected)
return; return;
@ -345,7 +345,7 @@ void HandlePostUpdate()
const auto filename = ActiveSettings::GetFullPath().replace_extension("exe.backup"); const auto filename = ActiveSettings::GetFullPath().replace_extension("exe.backup");
if (fs::exists(filename)) if (fs::exists(filename))
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
HANDLE lock; HANDLE lock;
do do
{ {
@ -374,7 +374,7 @@ void HandlePostUpdate()
void ToolShaderCacheMerger(); void ToolShaderCacheMerger();
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#ifndef PUBLIC_RELEASE #ifndef PUBLIC_RELEASE
#include <crtdbg.h> #include <crtdbg.h>
@ -411,7 +411,9 @@ int wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ L
#else #else
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if BOOST_OS_LINUX
XInitThreads(); XInitThreads();
#endif
if (!LaunchSettings::HandleCommandline(argc, argv)) if (!LaunchSettings::HandleCommandline(argc, argv))
return 0; return 0;
@ -440,7 +442,7 @@ __declspec(dllexport) uint64 gameMeta_getTitleId()
} }
/* Cemuhook loading */ /* Cemuhook loading */
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#pragma init_seg(".CRT$XCT") #pragma init_seg(".CRT$XCT")
HANDLE dbgLib; HANDLE dbgLib;

View File

@ -7,8 +7,8 @@ target_precompile_headers(CemuResource PRIVATE ../Common/precompiled.h)
# icon resources # icon resources
if(UNIX) if(UNIX)
target_sources(CemuResource PRIVATE target_sources(CemuResource PRIVATE
linux/resources.cpp embedded/resources.cpp
linux/resources.h embedded/resources.h
) )
endif() endif()

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#endif #endif

View File

@ -1,5 +1,6 @@
#include "Fiber.h" #include "Fiber.h"
#if BOOST_OS_LINUX #if BOOST_OS_LINUX || BOOST_OS_MACOS
#define _XOPEN_SOURCE
#include <ucontext.h> #include <ucontext.h>
thread_local Fiber* sCurrentFiber{}; thread_local Fiber* sCurrentFiber{};

View File

@ -1,6 +1,6 @@
#include "util/MemMapper/MemMapper.h" #include "util/MemMapper/MemMapper.h"
#if BOOST_OS_LINUX > 0 #if BOOST_OS_LINUX || BOOST_OS_MACOS
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>

View File

@ -1,6 +1,6 @@
#include "util/MemMapper/MemMapper.h" #include "util/MemMapper/MemMapper.h"
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#include <Windows.h> #include <Windows.h>

View File

@ -46,7 +46,7 @@ std::string_view& trim(std::string_view& str, const std::string& chars)
return ltrim(rtrim(str, chars), chars); return ltrim(rtrim(str, chars), chars);
} }
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
std::wstring GetSystemErrorMessageW() std::wstring GetSystemErrorMessageW()
{ {
@ -120,7 +120,7 @@ std::string GetSystemErrorMessage(const std::error_code& ec)
return fmt::format("{}\n{}",msg, ec.message()); return fmt::format("{}\n{}",msg, ec.message());
} }
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
const DWORD MS_VC_EXCEPTION = 0x406D1388; const DWORD MS_VC_EXCEPTION = 0x406D1388;
#pragma pack(push,8) #pragma pack(push,8)
typedef struct tagTHREADNAME_INFO typedef struct tagTHREADNAME_INFO
@ -135,7 +135,7 @@ typedef struct tagTHREADNAME_INFO
void SetThreadName(const char* name) void SetThreadName(const char* name)
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
#ifndef _PUBLIC_RELEASE #ifndef _PUBLIC_RELEASE
THREADNAME_INFO info; THREADNAME_INFO info;
@ -154,12 +154,14 @@ void SetThreadName(const char* name)
#endif #endif
#elif BOOST_OS_MACOS
pthread_setname_np(name);
#else #else
pthread_setname_np(pthread_self(), name); pthread_setname_np(pthread_self(), name);
#endif #endif
} }
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
std::pair<DWORD, DWORD> GetWindowsVersion() std::pair<DWORD, DWORD> GetWindowsVersion()
{ {
using RtlGetVersion_t = LONG(*)(POSVERSIONINFOEXW); using RtlGetVersion_t = LONG(*)(POSVERSIONINFOEXW);

View File

@ -8,7 +8,7 @@
#include "util/math/vector3.h" #include "util/math/vector3.h"
#ifdef __clang__ #ifdef __clang__
#include "Common/linux/fast_float.h" #include "Common/unix/fast_float.h"
#endif #endif
template <typename TType> template <typename TType>

View File

@ -60,7 +60,7 @@ void libusbWrapper::init()
libusbWrapper::~libusbWrapper() libusbWrapper::~libusbWrapper()
{ {
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
// destroy default context // destroy default context
if(p_libusb_exit) if(p_libusb_exit)
p_libusb_exit(nullptr); p_libusb_exit(nullptr);

View File

@ -41,7 +41,7 @@ public:
private: private:
#if BOOST_OS_WINDOWS > 0 #if BOOST_OS_WINDOWS
HMODULE m_module = nullptr; HMODULE m_module = nullptr;
bool m_isInitialized = false; bool m_isInitialized = false;
#endif #endif