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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 44 additions and 16 deletions

View file

@ -3,7 +3,7 @@ set(SRCS
include/libcue/cdtext.h
include/libcue/libcue.h
include/libcue/rem.h
include/libcue/time.h
include/libcue/cuetime.h
src/cd.c
src/cdtext.c
src/cue_parser.c

View file

@ -5,8 +5,8 @@
* For license terms, see the file COPYING in this distribution.
*/
#ifndef TIME_H
#define TIME_H
#ifndef CUETIME_H
#define CUETIME_H
long time_msf_to_frame(int m, int s, int f);
void time_frame_to_msf(long frame, int *m, int *s, int *f);

View file

@ -88,7 +88,7 @@
#include <string.h>
#include "cd.h"
#include "time.h"
#include "cuetime.h"
#ifdef CUEPARSER_BUF_SIZE
#undef CUEPARSER_BUF_SIZE

View file

@ -10,7 +10,7 @@
#include <string.h>
#include "cd.h"
#include "time.h"
#include "cuetime.h"
#ifdef CUEPARSER_BUF_SIZE
#undef CUEPARSER_BUF_SIZE

View file

@ -5,7 +5,7 @@
* For license terms, see the file COPYING in this distribution.
*/
#include "time.h"
#include "cuetime.h"
#include <stdio.h>
#include <stdlib.h>

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
}

View file

@ -20,9 +20,11 @@ constexpr bool USE_BLOCK_LINKING = true;
#ifdef WITH_RECOMPILER
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 32 * 1024 * 1024;
static constexpr u32 RECOMPILER_FAR_CODE_CACHE_SIZE = 32 * 1024 * 1024;
#ifndef __HAIKU__
static constexpr u32 RECOMPILER_GUARD_SIZE = 4096;
alignas(Recompiler::CODE_STORAGE_ALIGNMENT) static u8
s_code_storage[RECOMPILER_CODE_CACHE_SIZE + RECOMPILER_FAR_CODE_CACHE_SIZE];
#endif
static JitCodeBuffer s_code_buffer;
enum : u32
@ -90,8 +92,12 @@ void Initialize(bool use_recompiler)
#ifdef WITH_RECOMPILER
s_use_recompiler = use_recompiler;
#ifndef __HAIKU__
if (!s_code_buffer.Initialize(s_code_storage, sizeof(s_code_storage), RECOMPILER_FAR_CODE_CACHE_SIZE,
RECOMPILER_GUARD_SIZE))
#else
if (!s_code_buffer.Allocate(RECOMPILER_CODE_CACHE_SIZE, RECOMPILER_FAR_CODE_CACHE_SIZE))
#endif
{
Panic("Failed to initialize code space");
}

View file

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