Haiku port of duckstation libretro core (#716)

* Haiku build 1st attempt

* fix load on Haiku

* Removed debugging flags

* Added a couple ifndef
This commit is contained in:
kwyxz
2020-08-21 20:20:37 -07:00
committed by GitHub
parent 8151594d60
commit 31695c4ff7
11 changed files with 44 additions and 16 deletions

View File

@ -4,7 +4,7 @@
#if defined(WIN32)
#include <malloc.h>
#include "windows_headers.h"
#elif defined(__linux__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
#include <fcntl.h>
#include <poll.h>
#include <unistd.h>
@ -61,7 +61,7 @@ void Event::WaitForMultiple(Event** events, u32 num_events)
WaitForMultipleObjects(num_events, event_handles, TRUE, INFINITE);
}
#elif defined(__linux__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
Event::Event(bool auto_reset /*= false*/) : m_auto_reset(auto_reset)
{

View File

@ -19,7 +19,7 @@ public:
private:
#ifdef WIN32
void* m_event_handle;
#elif defined(__linux__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
int m_pipe_fds[2];
bool m_auto_reset;
#else
@ -27,4 +27,4 @@ private:
#endif
};
} // namespace Common
} // namespace Common

View File

@ -1216,7 +1216,14 @@ static u32 RecursiveFindFiles(const char* OriginPath, const char* ParentPath, co
FILESYSTEM_FIND_DATA outData;
outData.Attributes = 0;
#ifdef __HAIKU__
struct stat sDir;
stat(pDirEnt->d_name, &sDir);
if (S_ISDIR(sDir.st_mode))
#else
if (pDirEnt->d_type == DT_DIR)
#endif
{
if (Flags & FILESYSTEM_FIND_RECURSIVE)
{
@ -1309,8 +1316,13 @@ bool StatFile(const char* Path, FILESYSTEM_STAT_DATA* pStatData)
return false;
// stat file
#ifdef __HAIKU__
struct stat sysStatData;
if (stat(Path, &sysStatData) < 0)
#else
struct stat64 sysStatData;
if (stat64(Path, &sysStatData) < 0)
#endif
return false;
// parse attributes
@ -1338,8 +1350,13 @@ bool FileExists(const char* Path)
return false;
// stat file
#ifdef __HAIKU__
struct stat sysStatData;
if (stat(Path, &sysStatData) < 0)
#else
struct stat64 sysStatData;
if (stat64(Path, &sysStatData) < 0)
#endif
return false;
if (S_ISDIR(sysStatData.st_mode))
@ -1355,8 +1372,13 @@ bool DirectoryExists(const char* Path)
return false;
// stat file
struct stat64 sysStatData;
if (stat64(Path, &sysStatData) < 0)
#ifdef __HAIKU__
struct stat sysStatData;
if (stat(Path, &sysStatData) < 0)
#else
struct stat64 sysStatData;
if (stat64(Path, &sysStatData) < 0)
#endif
return false;
if (S_ISDIR(sysStatData.st_mode))

View File

@ -37,7 +37,7 @@ bool JitCodeBuffer::Allocate(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__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__)
m_code_ptr = static_cast<u8*>(
mmap(nullptr, m_total_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
#else
@ -86,7 +86,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
m_code_ptr = static_cast<u8*>(buffer);
m_old_protection = static_cast<u32>(old_protect);
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__)
if (mprotect(buffer, size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
return false;
@ -128,7 +128,7 @@ void JitCodeBuffer::Destroy()
{
#if defined(WIN32)
VirtualFree(m_code_ptr, 0, MEM_RELEASE);
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__)
munmap(m_code_ptr, m_total_size);
#endif
}