Add macOS to some Linux/Android-only-isms

This commit is contained in:
Connor McLaughlin 2020-02-14 22:58:10 +09:00
parent 5aba89091e
commit 23c8a5588d
5 changed files with 7 additions and 13 deletions

View File

@ -12,7 +12,7 @@ target_include_directories(nativefiledialog INTERFACE "${CMAKE_CURRENT_SOURCE_DI
if(WIN32)
target_sources(nativefiledialog PRIVATE src/nfd_win.cpp)
elseif(APPLE)
target_sources(nativefiledialog PRIVATE src/nfd_coca.m)
target_sources(nativefiledialog PRIVATE src/nfd_cocoa.m)
else()
find_package(GTK2 2.6 COMPONENTS gtk)
if(GTK2_FOUND)

View File

@ -1161,7 +1161,7 @@ std::unique_ptr<ByteStream> ByteStream_OpenFileStream(const char* fileName, u32
std::snprintf(temporaryFileName, fileNameLength + 8, "%s.XXXXXX", fileName);
// fill in random characters
#if defined(__linux__) || defined(__ANDROID__)
#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
mkstemp(temporaryFileName);
#else
mktemp(temporaryFileName);

View File

@ -1389,10 +1389,10 @@ std::string GetProgramPath()
#elif defined(__APPLE__)
int curSize = PATH_MAX;
char* buffer = static_cast<char*>(std::realloc(nullptr, curSize + 1));
char* buffer = static_cast<char*>(std::realloc(nullptr, curSize));
for (;;)
{
uint32 nChars = PATH_MAX - 1;
uint32 nChars = curSize - 1;
int res = _NSGetExecutablePath(buffer, &nChars);
if (res == 0)
{
@ -1410,12 +1410,6 @@ std::string GetProgramPath()
return ret;
}
if (curSize >= 1048576)
{
std::free(buffer);
return {};
}
curSize *= 2;
buffer = static_cast<char*>(std::realloc(buffer, curSize + 1));
}

View File

@ -16,7 +16,7 @@ JitCodeBuffer::JitCodeBuffer(u32 size /* = 64 * 1024 * 1024 */, u32 far_code_siz
#if defined(WIN32)
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*>(
mmap(nullptr, m_total_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
#else
@ -39,7 +39,7 @@ JitCodeBuffer::~JitCodeBuffer()
{
#if defined(WIN32)
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);
#endif
}

View File

@ -80,7 +80,7 @@ constexpr bool SHIFTS_ARE_IMPLICITLY_MASKED = true;
// ABI selection
#if defined(WIN32)
#define ABI_WIN64 1
#elif defined(__linux__) || defined(__ANDROID__)
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
#define ABI_SYSV 1
#else
#error Unknown ABI.