mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-02-16 19:05:39 +00:00
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:
parent
8151594d60
commit
31695c4ff7
|
@ -3,7 +3,7 @@ set(SRCS
|
||||||
include/libcue/cdtext.h
|
include/libcue/cdtext.h
|
||||||
include/libcue/libcue.h
|
include/libcue/libcue.h
|
||||||
include/libcue/rem.h
|
include/libcue/rem.h
|
||||||
include/libcue/time.h
|
include/libcue/cuetime.h
|
||||||
src/cd.c
|
src/cd.c
|
||||||
src/cdtext.c
|
src/cdtext.c
|
||||||
src/cue_parser.c
|
src/cue_parser.c
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* For license terms, see the file COPYING in this distribution.
|
* For license terms, see the file COPYING in this distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TIME_H
|
#ifndef CUETIME_H
|
||||||
#define TIME_H
|
#define CUETIME_H
|
||||||
|
|
||||||
long time_msf_to_frame(int m, int s, int f);
|
long time_msf_to_frame(int m, int s, int f);
|
||||||
void time_frame_to_msf(long frame, int *m, int *s, int *f);
|
void time_frame_to_msf(long frame, int *m, int *s, int *f);
|
|
@ -88,7 +88,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "cd.h"
|
#include "cd.h"
|
||||||
#include "time.h"
|
#include "cuetime.h"
|
||||||
|
|
||||||
#ifdef CUEPARSER_BUF_SIZE
|
#ifdef CUEPARSER_BUF_SIZE
|
||||||
#undef CUEPARSER_BUF_SIZE
|
#undef CUEPARSER_BUF_SIZE
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "cd.h"
|
#include "cd.h"
|
||||||
#include "time.h"
|
#include "cuetime.h"
|
||||||
|
|
||||||
#ifdef CUEPARSER_BUF_SIZE
|
#ifdef CUEPARSER_BUF_SIZE
|
||||||
#undef CUEPARSER_BUF_SIZE
|
#undef CUEPARSER_BUF_SIZE
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* For license terms, see the file COPYING in this distribution.
|
* For license terms, see the file COPYING in this distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "time.h"
|
#include "cuetime.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include "windows_headers.h"
|
#include "windows_headers.h"
|
||||||
#elif defined(__linux__) || defined(__APPLE__)
|
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -61,7 +61,7 @@ void Event::WaitForMultiple(Event** events, u32 num_events)
|
||||||
WaitForMultipleObjects(num_events, event_handles, TRUE, INFINITE);
|
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)
|
Event::Event(bool auto_reset /*= false*/) : m_auto_reset(auto_reset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
private:
|
private:
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
void* m_event_handle;
|
void* m_event_handle;
|
||||||
#elif defined(__linux__) || defined(__APPLE__)
|
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
|
||||||
int m_pipe_fds[2];
|
int m_pipe_fds[2];
|
||||||
bool m_auto_reset;
|
bool m_auto_reset;
|
||||||
#else
|
#else
|
||||||
|
@ -27,4 +27,4 @@ private:
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
|
@ -1216,7 +1216,14 @@ static u32 RecursiveFindFiles(const char* OriginPath, const char* ParentPath, co
|
||||||
FILESYSTEM_FIND_DATA outData;
|
FILESYSTEM_FIND_DATA outData;
|
||||||
outData.Attributes = 0;
|
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)
|
if (pDirEnt->d_type == DT_DIR)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (Flags & FILESYSTEM_FIND_RECURSIVE)
|
if (Flags & FILESYSTEM_FIND_RECURSIVE)
|
||||||
{
|
{
|
||||||
|
@ -1309,8 +1316,13 @@ bool StatFile(const char* Path, FILESYSTEM_STAT_DATA* pStatData)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
struct stat sysStatData;
|
||||||
|
if (stat(Path, &sysStatData) < 0)
|
||||||
|
#else
|
||||||
struct stat64 sysStatData;
|
struct stat64 sysStatData;
|
||||||
if (stat64(Path, &sysStatData) < 0)
|
if (stat64(Path, &sysStatData) < 0)
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// parse attributes
|
// parse attributes
|
||||||
|
@ -1338,8 +1350,13 @@ bool FileExists(const char* Path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
struct stat sysStatData;
|
||||||
|
if (stat(Path, &sysStatData) < 0)
|
||||||
|
#else
|
||||||
struct stat64 sysStatData;
|
struct stat64 sysStatData;
|
||||||
if (stat64(Path, &sysStatData) < 0)
|
if (stat64(Path, &sysStatData) < 0)
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (S_ISDIR(sysStatData.st_mode))
|
if (S_ISDIR(sysStatData.st_mode))
|
||||||
|
@ -1355,8 +1372,13 @@ bool DirectoryExists(const char* Path)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// stat file
|
// stat file
|
||||||
struct stat64 sysStatData;
|
#ifdef __HAIKU__
|
||||||
if (stat64(Path, &sysStatData) < 0)
|
struct stat sysStatData;
|
||||||
|
if (stat(Path, &sysStatData) < 0)
|
||||||
|
#else
|
||||||
|
struct stat64 sysStatData;
|
||||||
|
if (stat64(Path, &sysStatData) < 0)
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (S_ISDIR(sysStatData.st_mode))
|
if (S_ISDIR(sysStatData.st_mode))
|
||||||
|
|
|
@ -37,7 +37,7 @@ bool JitCodeBuffer::Allocate(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__) || defined(__APPLE__)
|
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__)
|
||||||
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
|
||||||
|
@ -86,7 +86,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
|
||||||
|
|
||||||
m_code_ptr = static_cast<u8*>(buffer);
|
m_code_ptr = static_cast<u8*>(buffer);
|
||||||
m_old_protection = static_cast<u32>(old_protect);
|
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)
|
if (mprotect(buffer, size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ void JitCodeBuffer::Destroy()
|
||||||
{
|
{
|
||||||
#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__) || defined(__APPLE__)
|
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__)
|
||||||
munmap(m_code_ptr, m_total_size);
|
munmap(m_code_ptr, m_total_size);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,11 @@ constexpr bool USE_BLOCK_LINKING = true;
|
||||||
#ifdef WITH_RECOMPILER
|
#ifdef WITH_RECOMPILER
|
||||||
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 32 * 1024 * 1024;
|
static constexpr u32 RECOMPILER_CODE_CACHE_SIZE = 32 * 1024 * 1024;
|
||||||
static constexpr u32 RECOMPILER_FAR_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;
|
static constexpr u32 RECOMPILER_GUARD_SIZE = 4096;
|
||||||
alignas(Recompiler::CODE_STORAGE_ALIGNMENT) static u8
|
alignas(Recompiler::CODE_STORAGE_ALIGNMENT) static u8
|
||||||
s_code_storage[RECOMPILER_CODE_CACHE_SIZE + RECOMPILER_FAR_CODE_CACHE_SIZE];
|
s_code_storage[RECOMPILER_CODE_CACHE_SIZE + RECOMPILER_FAR_CODE_CACHE_SIZE];
|
||||||
|
#endif
|
||||||
static JitCodeBuffer s_code_buffer;
|
static JitCodeBuffer s_code_buffer;
|
||||||
|
|
||||||
enum : u32
|
enum : u32
|
||||||
|
@ -90,8 +92,12 @@ void Initialize(bool use_recompiler)
|
||||||
|
|
||||||
#ifdef WITH_RECOMPILER
|
#ifdef WITH_RECOMPILER
|
||||||
s_use_recompiler = use_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,
|
if (!s_code_buffer.Initialize(s_code_storage, sizeof(s_code_storage), RECOMPILER_FAR_CODE_CACHE_SIZE,
|
||||||
RECOMPILER_GUARD_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");
|
Panic("Failed to initialize code space");
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ constexpr u32 CODE_STORAGE_ALIGNMENT = 4096;
|
||||||
// ABI selection
|
// ABI selection
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#define ABI_WIN64 1
|
#define ABI_WIN64 1
|
||||||
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
|
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__)
|
||||||
#define ABI_SYSV 1
|
#define ABI_SYSV 1
|
||||||
#else
|
#else
|
||||||
#error Unknown ABI.
|
#error Unknown ABI.
|
||||||
|
|
Loading…
Reference in a new issue