Haiku port

This commit is contained in:
Li
2026-04-19 22:38:38 +00:00
parent bc82f5c091
commit 1effcd1e6d
8 changed files with 167 additions and 80 deletions

View File

@@ -25,7 +25,7 @@
&m_threadID // pointer to receive thread ID
);
#endif
#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__)
#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) || defined(__HAIKU__)
mp_threadFunc = (pthread_fn)threadFunc;
pthread_attr_init(&m_attributes);
@@ -53,7 +53,7 @@
#ifdef WIN32
Sleep( millis );
#endif
#if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX)
#if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__HAIKU__)
usleep(millis * 1000);
#endif
}
@@ -63,7 +63,7 @@
#ifdef WIN32
TerminateThread(m_threadHandle, 0);
#endif
#if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX)
#if defined(LINUX) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__HAIKU__)
// Thread was created detached; pthread_join on a detached thread is undefined
// and causes SIGABRT when the pthread_t is no longer valid.
pthread_attr_destroy(&m_attributes);

View File

@@ -13,7 +13,7 @@
typedef void *( * pthread_fn )( void * );
#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__)
#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) || defined(__HAIKU__)
#include <pthread.h>
#include <unistd.h>
@@ -38,7 +38,7 @@ typedef void *( * pthread_fn )( void * );
DWORD m_threadID;
HANDLE m_threadHandle;
#endif
#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__)
#if defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(POSIX) || defined(__EMSCRIPTEN__) || defined(__HAIKU__)
pthread_fn mp_threadFunc;
pthread_t m_thread;
pthread_attr_t m_attributes;

View File

@@ -42,11 +42,10 @@ SocketLayerOverride *SocketLayer::slo=0;
#endif
#if defined(__HAIKU__)
#include <sys/types.h>
#include <ifaddrs.h>
#endif
@@ -1436,6 +1435,24 @@ RakNet::RakString SocketLayer::GetSubNetForSocketAndIp(SOCKET inSock, RakNet::Ra
}
}
return "";
#elif defined(__HAIKU__)
struct ifaddrs *ifap, *ifa;
getifaddrs (&ifap);
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr && ifa->ifa_addr->sa_family==AF_INET) {
sockaddr_in* sa = (sockaddr_in*)ifa->ifa_addr;
char* ip_addr = inet_ntoa(sa->sin_addr);
if (inIpString == ip_addr) {
sockaddr_in* sa = (sockaddr_in*)ifa->ifa_netmask;
char* netmask = inet_ntoa(sa->sin_addr);
freeifaddrs(ifap);
return netmask;
}
}
}
freeifaddrs(ifap);
return "";
#else
int fd,fd2;

View File

@@ -1,5 +1,9 @@
#include "UDPForwarder.h"
#if defined(__HAIKU__)
#include <sys/select.h>
#endif
#if _RAKNET_SUPPORT_UDPForwarder==1
#include "GetTime.h"

View File

@@ -9,6 +9,10 @@
#include <cstdio>
#include <sys/types.h>
#if defined(__HAIKU__)
#include <sys/stat.h>
#endif
#ifdef __APPLE__
#include "MoveFolder.h"
#endif
@@ -66,7 +70,7 @@ void ExternalFileLevelStorageSource::addLevelSummaryIfExists(LevelSummaryList& d
void ExternalFileLevelStorageSource::getLevelList(LevelSummaryList& dest)
{
#ifdef WIN32
#if defined(WIN32)
WIN32_FIND_DATAA fileData;
HANDLE hFind;
@@ -83,8 +87,6 @@ void ExternalFileLevelStorageSource::getLevelList(LevelSummaryList& dest)
} while (FindNextFileA(hFind, &fileData));
FindClose(hFind);
}
#else
DIR *dp;
struct dirent *dirp;
@@ -94,10 +96,20 @@ void ExternalFileLevelStorageSource::getLevelList(LevelSummaryList& dest)
}
while ((dirp = readdir(dp)) != NULL) {
#if defined(__HAIKU__)
struct stat st;
const auto fullPath = basePath + "/" + dirp->d_name;
if (!lstat(fullPath.c_str(), &st)) {
if(st.st_mode & S_IFDIR) {
addLevelSummaryIfExists(dest, dirp->d_name);
}
}
#else
if (dirp->d_type == DT_DIR)
{
addLevelSummaryIfExists(dest, dirp->d_name);
}
#endif
}
closedir(dp);
#endif