From 8482809f18ebf27c650db22f92eeedb6f02db951 Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 12 Jun 2023 01:14:36 -0500 Subject: [PATCH] Fix compilation on Haiku OS (#183) * add haiku defines in q_platform.h and sys_sdl.c * linuxisms in sys_sdl.c and sv_sys_unix.c * more linuxisms in sv_sys_unix.c --- engine/client/sys_sdl.c | 8 ++++---- engine/server/sv_sys_unix.c | 12 ++++++------ plugins/quake3/botlib/q_platform.h | 4 +++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/engine/client/sys_sdl.c b/engine/client/sys_sdl.c index a5c8a3be3..eda6a47c6 100644 --- a/engine/client/sys_sdl.c +++ b/engine/client/sys_sdl.c @@ -11,7 +11,7 @@ #ifndef WIN32 #include #include -#if defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) //apple make everything painful. +#if defined(__unix__) || defined(__unix) ||defined(__HAIKU__) || (defined(__APPLE__) && defined(__MACH__)) //apple make everything painful. #include #endif #else @@ -646,7 +646,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (QDECL *func)( strcat(fullmatch, match); return Sys_EnumerateFiles2(fullmatch, start, start, func, parm, spath); } -#elif defined(linux) || defined(__unix__) || defined(__MACH__) +#elif defined(linux) || defined(__unix__) || defined(__MACH__) || defined(__HAIKU__) #include #include static int Sys_EnumerateFiles2 (const char *truepath, int apathofs, const char *match, int (*func)(const char *, qofs_t, time_t modtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath) @@ -961,8 +961,8 @@ int QDECL main(int argc, char **argv) parms.manifest = CONFIG_MANIFEST_TEXT; #endif -#ifndef WIN32 - fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY); +#if !defined(WIN32) + fcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | O_NDELAY); #endif COM_InitArgv (parms.argc, parms.argv); diff --git a/engine/server/sv_sys_unix.c b/engine/server/sv_sys_unix.c index 3f4267946..66b6e7196 100644 --- a/engine/server/sv_sys_unix.c +++ b/engine/server/sv_sys_unix.c @@ -291,7 +291,7 @@ void Sys_Error (const char *error, ...) if (!noconinput) { tcsetattr(STDIN_FILENO, TCSADRAIN, &orig); - fcntl (STDIN_FILENO, F_SETFL, fcntl (STDIN_FILENO, F_GETFL, 0) & ~FNDELAY); + fcntl (STDIN_FILENO, F_SETFL, fcntl (STDIN_FILENO, F_GETFL, 0) & ~O_NDELAY); } //we used to fire sigsegv. this resulted in people reporting segfaults and not the error message that appeared above. resulting in wasted debugging. @@ -593,7 +593,7 @@ void Sys_Quit (void) if (!noconinput) { tcsetattr(STDIN_FILENO, TCSADRAIN, &orig); - fcntl (STDIN_FILENO, F_SETFL, fcntl (STDIN_FILENO, F_GETFL, 0) & ~FNDELAY); + fcntl (STDIN_FILENO, F_SETFL, fcntl (STDIN_FILENO, F_GETFL, 0) & ~O_NDELAY); } exit (0); // appkit isn't running } @@ -700,9 +700,9 @@ char *Sys_ConsoleInput (void) #if defined(__linux__) { int fl = fcntl (STDIN_FILENO, F_GETFL, 0); - if (!(fl & FNDELAY)) + if (!(fl & O_NDELAY)) { - fcntl(STDIN_FILENO, F_SETFL, fl | FNDELAY); + fcntl(STDIN_FILENO, F_SETFL, fl | O_NDELAY); // Sys_Printf(CON_WARNING "stdin flags became blocking - gdb bug?\n"); } } @@ -996,8 +996,8 @@ static int Sys_CheckChRoot(void) static void SigCont(int code) { //lets us know when we regained foreground focus. int fl = fcntl (STDIN_FILENO, F_GETFL, 0); - if (!(fl & FNDELAY)) - fcntl(STDIN_FILENO, F_SETFL, fl | FNDELAY); + if (!(fl & O_NDELAY)) + fcntl(STDIN_FILENO, F_SETFL, fl | O_NDELAY); noconinput &= ~2; } #endif diff --git a/plugins/quake3/botlib/q_platform.h b/plugins/quake3/botlib/q_platform.h index 75e9a144e..b6015132d 100644 --- a/plugins/quake3/botlib/q_platform.h +++ b/plugins/quake3/botlib/q_platform.h @@ -163,7 +163,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA //================================================================= LINUX === -#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(ANDROID) || defined(__ANDROID__) +#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(ANDROID) || defined(__ANDROID__) || defined(__HAIKU__) #include @@ -171,6 +171,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define OS_STRING "android" #elif defined(__linux__) #define OS_STRING "linux" +#elif defined(__HAIKU__) +#define OS_STRING "Haiku" #else #define OS_STRING "kFreeBSD" #endif