mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 06:25:37 +00:00
Add macOS to some Linux/Android-only-isms
This commit is contained in:
parent
5aba89091e
commit
23c8a5588d
|
@ -12,7 +12,7 @@ target_include_directories(nativefiledialog INTERFACE "${CMAKE_CURRENT_SOURCE_DI
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_sources(nativefiledialog PRIVATE src/nfd_win.cpp)
|
target_sources(nativefiledialog PRIVATE src/nfd_win.cpp)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
target_sources(nativefiledialog PRIVATE src/nfd_coca.m)
|
target_sources(nativefiledialog PRIVATE src/nfd_cocoa.m)
|
||||||
else()
|
else()
|
||||||
find_package(GTK2 2.6 COMPONENTS gtk)
|
find_package(GTK2 2.6 COMPONENTS gtk)
|
||||||
if(GTK2_FOUND)
|
if(GTK2_FOUND)
|
||||||
|
|
|
@ -1161,7 +1161,7 @@ std::unique_ptr<ByteStream> ByteStream_OpenFileStream(const char* fileName, u32
|
||||||
std::snprintf(temporaryFileName, fileNameLength + 8, "%s.XXXXXX", fileName);
|
std::snprintf(temporaryFileName, fileNameLength + 8, "%s.XXXXXX", fileName);
|
||||||
|
|
||||||
// fill in random characters
|
// fill in random characters
|
||||||
#if defined(__linux__) || defined(__ANDROID__)
|
#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
|
||||||
mkstemp(temporaryFileName);
|
mkstemp(temporaryFileName);
|
||||||
#else
|
#else
|
||||||
mktemp(temporaryFileName);
|
mktemp(temporaryFileName);
|
||||||
|
|
|
@ -1389,10 +1389,10 @@ std::string GetProgramPath()
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
|
|
||||||
int curSize = PATH_MAX;
|
int curSize = PATH_MAX;
|
||||||
char* buffer = static_cast<char*>(std::realloc(nullptr, curSize + 1));
|
char* buffer = static_cast<char*>(std::realloc(nullptr, curSize));
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
uint32 nChars = PATH_MAX - 1;
|
uint32 nChars = curSize - 1;
|
||||||
int res = _NSGetExecutablePath(buffer, &nChars);
|
int res = _NSGetExecutablePath(buffer, &nChars);
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
|
@ -1410,12 +1410,6 @@ std::string GetProgramPath()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (curSize >= 1048576)
|
|
||||||
{
|
|
||||||
std::free(buffer);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
curSize *= 2;
|
curSize *= 2;
|
||||||
buffer = static_cast<char*>(std::realloc(buffer, curSize + 1));
|
buffer = static_cast<char*>(std::realloc(buffer, curSize + 1));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ JitCodeBuffer::JitCodeBuffer(u32 size /* = 64 * 1024 * 1024 */, u32 far_code_siz
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
m_code_ptr = static_cast<u8*>(VirtualAlloc(nullptr, m_total_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE));
|
m_code_ptr = static_cast<u8*>(VirtualAlloc(nullptr, m_total_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE));
|
||||||
#elif defined(__linux__) || defined(__ANDROID__)
|
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
|
||||||
m_code_ptr = static_cast<u8*>(
|
m_code_ptr = static_cast<u8*>(
|
||||||
mmap(nullptr, m_total_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
|
mmap(nullptr, m_total_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
|
||||||
#else
|
#else
|
||||||
|
@ -39,7 +39,7 @@ JitCodeBuffer::~JitCodeBuffer()
|
||||||
{
|
{
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
VirtualFree(m_code_ptr, 0, MEM_RELEASE);
|
VirtualFree(m_code_ptr, 0, MEM_RELEASE);
|
||||||
#elif defined(__linux__) || defined(__ANDROID__)
|
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
|
||||||
munmap(m_code_ptr, m_total_size);
|
munmap(m_code_ptr, m_total_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ constexpr bool SHIFTS_ARE_IMPLICITLY_MASKED = true;
|
||||||
// ABI selection
|
// ABI selection
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#define ABI_WIN64 1
|
#define ABI_WIN64 1
|
||||||
#elif defined(__linux__) || defined(__ANDROID__)
|
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
|
||||||
#define ABI_SYSV 1
|
#define ABI_SYSV 1
|
||||||
#else
|
#else
|
||||||
#error Unknown ABI.
|
#error Unknown ABI.
|
||||||
|
|
Loading…
Reference in a new issue