diff --git a/CMakeLists.txt b/CMakeLists.txt index c954cc5ae..b83c6472d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ ENDIF() # libepoll-shim needs to be installed on the BSDs and Mac OSX to get # some of the server code to compile and work correctly on those platforms - Brad -IF(UNIX AND NOT LINUX AND NOT CYGWIN) +IF(CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") INCLUDE(FetchContent) FetchContent_Declare( epoll-shim @@ -523,10 +523,11 @@ ELSEIF(UNIX AND NOT FTE_USE_SDL) #linux(ish) ENDIF() ENDIF() - IF(NOT LINUX AND NOT CYGWIN) + IF(CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") FIND_LIBRARY(epoll-shim REQUIRED) INCLUDE_DIRECTORIES(${EPOLL_INC_DIR}) SET(FTESV_LIBS ${FTESV_LIBS} epoll-shim) + SET(FTESV_DEFINES ${FTESV_DEFINES};HAVE_EPOLL) ENDIF() SET(FTESV_DEFINES ${FTESV_DEFINES};MULTITHREAD) @@ -1091,10 +1092,11 @@ ELSE() ${FTE_CLIENT_FILES} ${FTE_SERVER_FILES} ) - IF(UNIX AND NOT LINUX AND NOT CYGWIN) + IF(CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") FIND_LIBRARY(epoll-shim REQUIRED) SET(FTE_INCLUDES ${FTE_INCLUDES} "${EPOLL_INC_DIR}") SET(FTE_LIBS ${FTE_LIBS} epoll-shim) + SET(FTE_DEFINES ${FTE_DEFINES};HAVE_EPOLL) ENDIF() SET_TARGET_PROPERTIES(fteqw PROPERTIES COMPILE_DEFINITIONS "${FTE_LIB_DEFINES};${FTE_DEFINES};${FTE_REVISON}") TARGET_INCLUDE_DIRECTORIES(fteqw PUBLIC ${FTE_INCLUDES}) @@ -1198,13 +1200,14 @@ ELSE() SET_TARGET_PROPERTIES(qtv PROPERTIES COMPILE_DEFINITIONS "${FTE_REVISON};${FTE_LIB_DEFINES}") IF(WIN32) TARGET_LINK_LIBRARIES(qtv ws2_32 winmm ${SYS_LIBS} ${FTEQTV_LIBS}) - ELSEIF(LINUX) - TARGET_LINK_LIBRARIES(qtv ${SYS_LIBS} ${FTEQTV_LIBS}) - # Add Epoll-shim for the Unixes here - Brad - ELSE() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") + # Add Epoll-shim for the kqueue Unixes here - Brad FIND_LIBRARY(epoll-shim REQUIRED) TARGET_INCLUDE_DIRECTORIES(qtv PUBLIC "${EPOLL_INC_DIR}") TARGET_LINK_LIBRARIES(qtv epoll-shim ${SYS_LIBS} ${FTEQTV_LIBS}) + SET_TARGET_PROPERTIES(qtv PROPERTIES COMPILE_DEFINITIONS "${FTE_REVISON};${FTE_LIB_DEFINES};HAVE_EPOLL") + ELSE() + TARGET_LINK_LIBRARIES(qtv ${SYS_LIBS} ${FTEQTV_LIBS}) ENDIF() SET(INSTALLTARGS ${INSTALLTARGS} qtv) ENDIF() @@ -1247,10 +1250,11 @@ ELSE() SET_TARGET_PROPERTIES(httpserver PROPERTIES COMPILE_DEFINITIONS "WEBSERVER;WEBSVONLY;${FTE_REVISON}") IF(WIN32) TARGET_LINK_LIBRARIES(httpserver ws2_32) - ELSEIF(UNIX AND NOT LINUX AND NOT CYGWIN) + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "BSD" OR CMAKE_SYSTEM_NAME MATCHES "Darwin") FIND_LIBRARY(epoll-shim REQUIRED) TARGET_INCLUDE_DIRECTORIES(httpserver PUBLIC "${EPOLL_INC_DIR}") TARGET_LINK_LIBRARIES(httpserver epoll-shim) + SET_TARGET_PROPERTIES(httpserver PROPERTIES COMPILE_DEFINITIONS "WEBSERVER;WEBSVONLY;${FTE_REVISON};HAVE_EPOLL") ENDIF() #SET(INSTALLTARGS ${INSTALLTARGS} httpserver) ENDIF() @@ -1711,7 +1715,6 @@ IF(FTE_PLUG_CEF) ENDIF() ENDIF() -IF(NOT ANDROID) #libresolv issues. SET(FTE_PLUG_XMPP true CACHE BOOL "Compile xmpp/jabber instant-messenger plugin.") IF(FTE_PLUG_XMPP) #XMPP/jabber client plugin @@ -1726,14 +1729,16 @@ IF(FTE_PLUG_XMPP) plugins/emailnot/md5.c ) SET_TARGET_PROPERTIES(plug_xmpp PROPERTIES COMPILE_DEFINITIONS "FTEPLUGIN;${FTE_LIB_DEFINES}") - IF(${WIN32}) - ELSEIF(LINUX OR APPLE) + + #for SRV lookups, so we actually get the right server from account names/etc. + IF(ANDROID) #libresolv issues. + ELSEIF(${WIN32}) #softlinks a dll + ELSE() TARGET_LINK_LIBRARIES(plug_xmpp ${SYS_LIBS} resolv) ENDIF() EMBED_PLUGIN_META(xmpp "XMPP Plugin" "XMPP/Jabber instant messenger plugin for chatting without tabbing out.") ENDIF() -ENDIF() #android INSTALL(TARGETS ${INSTALLTARGS} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/${FTE_INSTALL_BINDIR}" diff --git a/engine/client/quakedef.h b/engine/client/quakedef.h index 17769d9b6..7afbf6268 100644 --- a/engine/client/quakedef.h +++ b/engine/client/quakedef.h @@ -53,21 +53,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #pragma warning(2:4032) // function arg has different type from declaration #pragma warning(2:4092) // 'sizeof' value too big #pragma warning(2:4132 4268)// const object not initialized -//#pragma warning(2:4152) // pointer conversion between function and data +//#pragma warning(2:4152) // pointer conversion between function and data #pragma warning(2:4239) // standard doesn't allow this conversion #pragma warning(2:4701) // local variable used without being initialized -//#pragma warning(2:4706) // if (a=b) instead of (if a==b) +//#pragma warning(2:4706) // if (a=b) instead of (if a==b) #pragma warning(2:4709) // comma in array subscript #pragma warning(3:4061) // not all enum values tested in switch statement #pragma warning(3:4710) // inline function was not inlined #pragma warning(3:4121) // space added for structure alignment #pragma warning(3:4505) // unreferenced local function removed #pragma warning(3:4019) // empty statement at global scope -//#pragma warning(3:4057) // pointers refer to different base types +//#pragma warning(3:4057) // pointers refer to different base types #pragma warning(3:4125) // decimal digit terminates octal escape #pragma warning(2:4131) // old-style function declarator #pragma warning(3:4211) // extern redefined as static -//#pragma warning(3:4213) // cast on left side of = is non-standard +//#pragma warning(3:4213) // cast on left side of = is non-standard #pragma warning(3:4222) // member function at file scope shouldn't be static #pragma warning(3:4234 4235)// keyword not supported or reserved for future #pragma warning(3:4504) // type ambiguous; simplify code @@ -132,10 +132,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #include -#if defined(__unix__) && !defined(__CYGWIN__) -#include -#endif - #ifdef USE_MSVCRT_DEBUG #define _CRTDBG_MAP_ALLOC #include @@ -408,7 +404,7 @@ void COM_AssertMainThread(const char *msg); #endif extern qboolean msg_suppress_1; // suppresses resolution and cache size console output - // an fullscreen DIB focus gain/loss + // an fullscreen DIB focus gain/loss #ifndef HAVE_CLIENT #define isDedicated true diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index a764cc665..f408c0663 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -66,10 +66,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #undef malloc -#if defined(__unix__) && !defined(__CYGWIN__) -#include -#endif - static int noconinput = 0; static int nostdout = 0; diff --git a/engine/common/console.h b/engine/common/console.h index f27ab1a6e..1d942d13f 100644 --- a/engine/common/console.h +++ b/engine/common/console.h @@ -21,13 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // console // -// undefine this to solve build issues with epoll-shim - Brad -#if defined(__unix__) && !defined(__linux__) && !defined(__CYGWIN__) -#ifdef close -#undef close -#endif -#endif - #define MAXCONCOLOURS 16 typedef struct { float fr, fg, fb; diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index 501477225..61f29b42b 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -26,10 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include //to delete the file/socket. #endif -#if defined(__unix__) && !defined(__linux__) && !defined(__APPLE__) && !defined(__CYGWIN__) -#include -#endif - extern ftemanifest_t *fs_manifest; // Eww, eww. This is hacky but so is netinc.h, so bite me @@ -10499,7 +10495,8 @@ NET_Init void NET_Init (void) { #ifdef HAVE_EPOLL - epoll_fd = epoll_create1(EPOLL_CLOEXEC); + if (epoll_fd < 0) + epoll_fd = epoll_create1(EPOLL_CLOEXEC); #endif Cvar_Register(&net_enabled, "networking"); @@ -10898,7 +10895,7 @@ void NET_Shutdown (void) #ifdef HAVE_EPOLL if (epoll_fd >= 0) - close(epoll_fd); + epoll_close(epoll_fd); epoll_fd = -1; stdin_epolling = false; #endif diff --git a/engine/common/netinc.h b/engine/common/netinc.h index d95aafa68..ee68ca429 100644 --- a/engine/common/netinc.h +++ b/engine/common/netinc.h @@ -140,7 +140,7 @@ #include #endif - #if defined(__unix__) && !defined(__CYGWIN__) + #if defined(__linux__) || defined(HAVE_EPOLL) //requires linux 2.6.27 up (and equivelent libc) //note that BSD does tend to support the api, but emulated. //this works around the select FD limit, and supposedly has better performance. @@ -149,6 +149,13 @@ #define HAVE_EPOLL //#else too old, probably android... #endif + #if defined(close) //epoll-shim? stop it from breaking shit + #undef close + #undef fcntl + #define epoll_close epoll_shim_close + #else + #define epoll_close close + #endif #endif #if defined(__MORPHOS__) && !defined(ixemul) diff --git a/engine/http/iweb.h b/engine/http/iweb.h index 79709d94e..12083878d 100644 --- a/engine/http/iweb.h +++ b/engine/http/iweb.h @@ -36,10 +36,6 @@ struct sockaddr; struct sockaddr_qstorage; int NetadrToSockadr (netadr_t *a, struct sockaddr_qstorage *s); -#if defined(__unix__) && !defined(__CYGWIN__) -#include -#endif - typedef qboolean iwboolean; typedef struct { diff --git a/engine/http/iwebiface.c b/engine/http/iwebiface.c index e372d1d63..cbb13527e 100644 --- a/engine/http/iwebiface.c +++ b/engine/http/iwebiface.c @@ -201,7 +201,7 @@ int COM_CheckParm(const char *parm) #include #endif -#ifndef _WIN32 +#ifdef HAVE_EPOLL struct stun_ctx { struct epollctx_s pub; @@ -338,7 +338,9 @@ int main(int argc, char **argv) WSADATA pointlesscrap; WSAStartup(2, &pointlesscrap); #else +#ifdef HAVE_EPOLL int ep = epoll_create1(0); +#endif signal(SIGPIPE, SIG_IGN); //so we don't crash out if a peer closes the socket half way through. #endif @@ -416,7 +418,7 @@ int main(int argc, char **argv) else printf("Server is read only\n"); -#ifdef _WIN32 +#ifndef HAVE_EPOLL while(1) { if (ftpport) @@ -430,7 +432,6 @@ int main(int argc, char **argv) #endif } #else - while (!HTTP_ServerInit(ep, httpport)) sleep(5); PrepareStun(ep, httpport); diff --git a/engine/qclib/pr_exec.c b/engine/qclib/pr_exec.c index 72289a290..a8b51ea13 100644 --- a/engine/qclib/pr_exec.c +++ b/engine/qclib/pr_exec.c @@ -369,9 +369,9 @@ static void PDECL PR_PrintRelevantLocals(progfuncs_t *progfuncs) else fdef = ED_FieldAtOfs(progfuncs, ((eval_t *)&pr_globals[st16[st].b])->_int); if (fdef) - externs->Printf(" %s.%s: %s\n", PR_StringToNative(&progfuncs->funcs, ent->s_name), PR_StringToNative(&progfuncs->funcs, fld->s_name), PR_ValueString(progfuncs, fdef->type, ptr, false)); + externs->Printf(" %s.%s: %s\n", PR_StringToNative(&progfuncs->funcs, ent->s_name), PR_StringToNative(&progfuncs->funcs, fld->s_name), PR_ValueString(progfuncs, fdef->type, ptr, false)); else - externs->Printf(" %s.%s: BAD FIELD DEF - %#x\n", PR_StringToNative(&progfuncs->funcs, ent->s_name), PR_StringToNative(&progfuncs->funcs, fld->s_name), ptr->_int); + externs->Printf(" %s.%s: BAD FIELD DEF - %#x\n", PR_StringToNative(&progfuncs->funcs, ent->s_name), PR_StringToNative(&progfuncs->funcs, fld->s_name), ptr->_int); } } } @@ -460,20 +460,20 @@ void PDECL PR_StackTrace (pubprogfuncs_t *ppf, int showlocals) { if (f->parm_size[arg] == 3) { //looks like a vector. print it as such - externs->Printf(" arg%i(%i): [%g, %g, %g]\n", arg, f->parm_start+ofs, *(float *)(globalbase+ofs), *(float *)(globalbase+ofs+1), *(float *)(globalbase+ofs+2)); + externs->Printf(" arg%i(%i): [%g, %g, %g]\n", arg, f->parm_start+ofs, *(float *)(globalbase+ofs), *(float *)(globalbase+ofs+1), *(float *)(globalbase+ofs+2)); ofs += 2; } else - externs->Printf(" arg%i(%i): %g===%i\n", arg, f->parm_start+ofs, *(float *)(globalbase+ofs), *(int *)(globalbase+ofs) ); + externs->Printf(" arg%i(%i): %g===%i\n", arg, f->parm_start+ofs, *(float *)(globalbase+ofs), *(int *)(globalbase+ofs) ); } else { - externs->Printf(" unk(%i): %g===%i\n", f->parm_start+ofs, *(float *)(globalbase+ofs), *(int *)(globalbase+ofs) ); + externs->Printf(" unk(%i): %g===%i\n", f->parm_start+ofs, *(float *)(globalbase+ofs), *(int *)(globalbase+ofs) ); } } else { - externs->Printf(" %s: %s\n", PR_StringToNative(ppf, local->s_name), PR_ValueString(progfuncs, local->type, (eval_t*)(globalbase+ofs), false)); + externs->Printf(" %s: %s\n", PR_StringToNative(ppf, local->s_name), PR_ValueString(progfuncs, local->type, (eval_t*)(globalbase+ofs), false)); if (local->type == ev_vector) ofs+=2; } diff --git a/plugins/plugin.h b/plugins/plugin.h index 970db9480..8af8cc2cb 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -47,12 +47,6 @@ # define strnicmp strncasecmp #endif -// Define these mostly for cod but could apply to other game tech -// Used this for guidance: https://github.com/xtnded/codextended - Brad -extern long xtn_LittleLong( long l ); -extern short xtn_LittleShort( short s ); -extern float xtn_LittleFloat( float f ); - #include #include #include