]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
rework GDEF_OS macros
authorThomas Debesse <dev@illwieckz.net>
Sat, 27 Jan 2018 22:54:15 +0000 (23:54 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sat, 1 Jun 2019 15:09:21 +0000 (17:09 +0200)
24 files changed:
contrib/gtkgensurf/gensurf.h
libs/globaldefs.h
plugins/textool/StdAfx.h
radiant/environment.cpp
radiant/mainframe.cpp
radiant/server.cpp
tools/quake2/common/cmdlib.c
tools/quake2/common/path_init.c
tools/quake2/common/threads.c
tools/quake2/q2map/q2map.h
tools/quake2/qdata_heretic2/common/cmdlib.c
tools/quake2/qdata_heretic2/common/path_init.c
tools/quake2/qdata_heretic2/common/threads.c
tools/quake2/qdata_heretic2/tmix.c
tools/quake3/common/aselib.c
tools/quake3/common/cmdlib.c
tools/quake3/common/threads.c
tools/quake3/common/trilib.c
tools/quake3/common/vfs.h
tools/quake3/q3data/md3lib.c
tools/quake3/q3data/p3dlib.c
tools/quake3/q3data/q3data.c
tools/quake3/q3map2/path_init.c
tools/quake3/q3map2/q3map2.h

index 84a78cd6d0b4c448bafe329f81e9bc1f5bb0a95f..8ed2dd5305f32b5231429d6112281dd525901523 100644 (file)
@@ -57,7 +57,7 @@ extern _QERBrushTable __BRUSHTABLENAME;
 #define PLUGIN
 #define Q3RADIANT
 
-//#if GDEF_OS_LINUX || GDEF_OS_MACOS
+//#if !GDEF_OS_WINDOWS
 #if 1
 #include <algorithm>
 #else
index 146dd788b1c5d24209b3f89836f92bc21ae11636..5d170523e6eb2b717e54e6066eec0d760cb22dc2 100644 (file)
@@ -49,7 +49,6 @@
 #define GDEF_OS_LINUX 0
 #endif
 
-
 #define GDEF_OS_BSD 0
 
 #if defined(__FreeBSD__)
 #define GDEF_OS_BSD_DRAGONFLY 0
 #endif
 
+#if defined(__osf) || defined(__osf__) || defined(__OSF__)
+#define GDEF_OS_OSF1 1
+#else
+#define GDEF_OS_OSF1 0
+#endif
+
+#if defined(_MIPS_ISA)
+#define GDEF_OS_IRIX 1
+#else
+#define GDEF_OS_IRIX 0
+#endif
+
+#if defined(NeXT)
+#define GDEF_OS_NEXT 1
+#else
+#define GDEF_OS_NEXT 0
+#endif
+
+#if GDEF_OS_LINUX || GDEF_OS_BSD
+#define GDEF_OS_XDG 1
+#else
+#define GDEF_OS_XDG 0
+#endif
+
 // COMPILER
 
 #if defined(_MSC_VER)
 #endif
 #endif
 
-#endif
+#endif // !INCLUDED_LIBS_GLOBALDEFS
index 2ebd1b012c10209066a116a7a8db9778738bd6ab..aee23c538b6e938777239c077da82cfbbb966edb 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 
 #if !GDEF_OS_WINDOWS
-
 // Necessary for proper boolean type declaration
 #include "qertypes.h"
 
@@ -77,8 +76,7 @@ typedef struct tagRECT
        long right;
        long bottom;
 } RECT, *PRECT, *LPRECT;
-
-#endif // __linux__
+#endif // !GDEF_OS_WINDOWS
 
 // plugin
 // FIXME TTimo: drop this
index b38ef992a59a84654e54bb0d4936b9d37346f585..bc64964ab7e26cf4db3bdf9c4e31183cb54526cf 100644 (file)
@@ -139,8 +139,10 @@ void gamedetect(){
                        if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz.exe", buf, p - buf ) )
 #elif GDEF_OS_MACOS
                        if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "Nexuiz.app/Contents/Info.plist", buf, p - buf ) )
-#else
+#elif GDEF_OS_LINUX
                        if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz-linux-glx.sh", buf, p - buf ) )
+#else
+                       if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", NULL, buf, p - buf ) )
 #endif
                        { return; }
 
index 9a07e0612eddc4989aeda33ef4b6cd720d2ca762..a1c35919307495e42eba0a5a705d966e4b73bc1a 100644 (file)
@@ -213,9 +213,7 @@ void HomePaths_Realise(){
                        }
                        path.clear();
                        path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
-#endif
-
-#if GDEF_OS_WINDOWS
+#elif GDEF_OS_WINDOWS
                        TCHAR mydocsdir[MAX_PATH + 1];
                        wchar_t *mydocsdirw;
                        HMODULE shfolder = LoadLibrary( "shfolder.dll" );
@@ -252,9 +250,7 @@ void HomePaths_Realise(){
                                        break;
                                }
                        }
-#endif
-
-#if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+#elif GDEF_OS_XDG
                        path.clear();
                        path << DirectoryCleaned( g_get_user_data_dir() ) << ( prefix + 1 ) << "/";
                        if ( file_exists( path.c_str() ) && file_is_directory( path.c_str() ) ) {
index c9e0778035cc4439b44aa3deeaa1287401b11e0f..879770c5e341f169e656f41d30d2a15ee199b43d 100644 (file)
@@ -178,9 +178,9 @@ FunctionPointer findSymbol( const char* symbol ){
 }
 };
 
-#else
+#else // !GDEF_OS_POSIX
 #error "unsupported platform"
-#endif
+#endif // !GDEF_OS_POSIX
 
 class DynamicLibraryModule
 {
index 02e0be87c39cbb3a610852ab6268a99a4911b7e1..5063f739e7a36b08a8f086574326919bbda0772e 100644 (file)
 #if GDEF_OS_WINDOWS
 #include <direct.h>
 #include <windows.h>
-#endif
-
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#else // !GDEF_OS_WINDOWS
 #include <unistd.h>
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 #ifdef NeXT
 #include <libc.h>
@@ -1177,8 +1175,7 @@ void QCopyFile( const char *from, const char *to ){
 void Sys_Sleep( int n ){
 #if GDEF_OS_WINDOWS
        Sleep( n );
-#endif
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#else // !GDEF_OS_WINDOWS
        usleep( n * 1000 );
-#endif
+#endif // !GDEF_OS_WINDOWS
 }
index cd413805b9acda86e4628818a07fb38720161730..766531418f792016ad074f88d838df39523ba60e 100644 (file)
    You should have received a copy of the GNU General Public License
    along with GtkRadiant; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
+/*
    Nurail: Swiped from Q3Map2
-
  */
 
 #include "globaldefs.h"
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-       #define Q_UNIX
-#endif
-
-#ifdef Q_UNIX
+#if !GDEF_OS_WINDOWS
        #include <unistd.h>
        #include <pwd.h>
        #include <limits.h>
-#endif
-
+#endif // !GDEF_OS_WINDOWS
 
 /* dependencies */
 #include "cmdlib.h"
 #include "inout.h"
 
-
-
 /* path support */
 #define MAX_BASE_PATHS  10
 #define MAX_GAME_PATHS  10
@@ -65,9 +59,9 @@ char                    *gamePaths[ MAX_GAME_PATHS ];
  */
 
 char *LokiGetHomeDir( void ){
-       #ifndef Q_UNIX
+       #if GDEF_OS_WINDOWS
        return NULL;
-       #else
+       #else // !GDEF_OS_WINDOWS
        char            *home;
        uid_t id;
        struct passwd   *pwd;
@@ -91,7 +85,7 @@ char *LokiGetHomeDir( void ){
 
        /* return it */
        return home;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
@@ -102,10 +96,10 @@ char *LokiGetHomeDir( void ){
  */
 
 void LokiInitPaths( char *argv0 ){
-       #ifndef Q_UNIX
+       #if GDEF_OS_WINDOWS
        /* this is kinda crap, but hey */
        strcpy( installPath, "../" );
-       #else
+       #else // !GDEF_OS_WINDOWS
        char temp[ MAX_OS_PATH ];
        char        *home;
        char        *path;
@@ -177,7 +171,7 @@ void LokiInitPaths( char *argv0 ){
 
        /* set home path */
        homePath = home;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
@@ -223,7 +217,7 @@ void AddBasePath( char *path ){
  */
 
 void AddHomeBasePath( char *path ){
-       #ifdef Q_UNIX
+       #if !GDEF_OS_WINDOWS
        int i;
        char temp[ MAX_OS_PATH ];
 
@@ -245,7 +239,7 @@ void AddHomeBasePath( char *path ){
        strcpy( basePaths[ 0 ], temp );
        CleanPath( basePaths[ 0 ] );
        numBasePaths++;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
index d648e99e490b07165e6117fdc484207eb97613f7..1d4e996b649c857636a30869d30dff3267ce8cb9 100644 (file)
@@ -25,8 +25,7 @@
 // The below define is necessary to use
 // pthreads extensions like pthread_mutexattr_settype
 #define _GNU_SOURCE
-#include <pthread.h>
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 #include "cmdlib.h"
 #include "mathlib.h"
@@ -101,6 +100,8 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 }
 
 
+#if GDEF_OS_WINDOWS
+
 /*
    ===================================================================
 
@@ -108,9 +109,6 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 
    ===================================================================
  */
-#if GDEF_OS_WINDOWS
-
-#define USED
 
 #include <windows.h>
 
@@ -212,7 +210,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
+#elif GDEF_OS_OSF1
 
 /*
    ===================================================================
@@ -222,9 +220,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    ===================================================================
  */
 
-#ifdef __osf__
-#define USED
-
 int numthreads = 4;
 
 void ThreadSetDefault( void ){
@@ -319,7 +314,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
+#elif GDEF_OS_IRIX
 
 /*
    ===================================================================
@@ -329,15 +324,11 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    ===================================================================
  */
 
-#ifdef _MIPS_ISA
-#define USED
-
 #include <task.h>
 #include <abi_mutex.h>
 #include <sys/types.h>
 #include <sys/prctl.h>
 
-
 int numthreads = -1;
 abilock_t lck;
 
@@ -406,8 +397,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
-
+#elif GDEF_OS_LINUX || GDEF_OS_BSD || GDEF_OS_MACOS
 
 /*
    =======================================================================
@@ -417,9 +407,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-#define USED
-
 // Setting default Threads to 1
 int numthreads = 1;
 
@@ -570,9 +557,10 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
                Sys_Printf( " (%i)\n", end - start );
        }
 }
-#endif // ifdef __linux__
 
 
+#else // UNKNOWN OS
+
 /*
    =======================================================================
 
@@ -581,8 +569,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#ifndef USED
-
 int numthreads = 1;
 
 void ThreadSetDefault( void ){
@@ -617,4 +603,4 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
        }
 }
 
-#endif
+#endif // UNKNOWN OS
index 644f7b9e88fda0a536d8eaaa01fef6c974823666..8f4ac8d3eaabea9b815d123f1743fda41bc0e023 100644 (file)
 #include "globaldefs.h"
 
 /* platform-specific */
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-       #define Q_UNIX
-#endif
-
-#ifdef Q_UNIX
+#if GDEF_OS_WINDOWS
+       #include <windows.h>
+#else // !GDEF_OS_WINDOWS
        #include <unistd.h>
        #include <pwd.h>
        #include <limits.h>
-#endif
-
-#if GDEF_OS_WINDOWS
-       #include <windows.h>
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 #include <stdlib.h>
 
index 7a49c52e8e26748d7430381cae21bbe58dc8e6ad..c45ff161bf0232491c73745c8b9e171ec925ff5b 100644 (file)
 #if GDEF_OS_WINDOWS
 #include <direct.h>
 #include <windows.h>
-#endif
-
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#elif GDEF_OS_NEXT
+#include <libc.h>
+#else // OTHER OSES
 #include <unistd.h>
-#endif
+#endif // OTHER OSES
 
-#ifdef NeXT
-#include <libc.h>
-#endif
+#if !GDEF_OS_WINDOWS
+#define strlwr strlower
+#endif // !GDEF_OS_WINDOWS
 
 #define BASEDIRNAME "h"
-#define PATHSEPERATOR   '/'
+#define PATHSEPERATOR '/'
 
 extern qboolean verbose;
 
@@ -73,7 +73,7 @@ void *safe_malloc_info( size_t size, char* info ){
 
        return p;
 }
-#endif
+#endif // !SAFE_MALLOC
 
 void *SafeMalloc( size_t n, char *desc ){
        void *p;
@@ -85,16 +85,6 @@ void *SafeMalloc( size_t n, char *desc ){
        return p;
 }
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-void strlwr( char *conv_str ){
-       int i;
-
-       for ( i = 0; i < strlen( conv_str ); i++ )
-               conv_str[i] = tolower( conv_str[i] );
-}
-#endif
-
-
 // set these before calling CheckParm
 int myargc;
 char **myargv;
@@ -114,8 +104,10 @@ char archivedir[1024];
    ===================
  */
 #define MAX_EX_ARGC 1024
+
 int ex_argc;
 char    *ex_argv[MAX_EX_ARGC];
+
 #if GDEF_OS_WINDOWS
 #include "io.h"
 void ExpandWildcards( int *argc, char ***argv ){
@@ -155,10 +147,10 @@ void ExpandWildcards( int *argc, char ***argv ){
        *argc = ex_argc;
        *argv = ex_argv;
 }
-#else
+#else // !GDEF_OS_WINDOWS
 void ExpandWildcards( int *argc, char ***argv ){
 }
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 /*
 
@@ -346,11 +338,11 @@ void Q_getwd( char *out ){
 #if GDEF_OS_WINDOWS
        _getcwd( out, 256 );
        strcat( out, "\\" );
-#else
+#else // !GDEF_OS_WINDOWS
        // Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow
        getcwd( out, 256 );
        strcat( out, "/" );
-#endif
+#endif // !GDEF_OS_WINDOWS
        while ( out[i] != 0 )
        {
                if ( out[i] == '\\' ) {
@@ -366,11 +358,11 @@ void Q_mkdir( const char *path ){
        if ( _mkdir( path ) != -1 ) {
                return;
        }
-#else
+#else // !GDEF_OS_WINDOWS
        if ( mkdir( path, 0777 ) != -1 ) {
                return;
        }
-#endif
+#endif // !GDEF_OS_WINDOWS
        if ( errno != EEXIST ) {
                Error( "mkdir %s: %s",path, strerror( errno ) );
        }
@@ -800,6 +792,7 @@ void    StripExtension( char *path ){
    Extract file parts
    ====================
  */
+
 // FIXME: should include the slash, otherwise
 // backing to an empty path will be wrong when appending a slash
 void ExtractFilePath( const char *path, char *dest ){
@@ -1014,7 +1007,7 @@ float   BigFloat( float l ){
 }
 
 
-#else
+#else // !GDEF_ARCH_ENDIAN_BIG
 
 
 short   BigShort( short l ){
@@ -1062,8 +1055,7 @@ float   LittleFloat( float l ){
        return l;
 }
 
-
-#endif
+#endif // ! GDEF_ARCH_ENDIAN_BIG
 
 
 //=======================================================
@@ -1144,7 +1136,7 @@ void    CreatePath( const char *path ){
                olddrive = _getdrive();
                _chdrive( toupper( path[0] ) - 'A' + 1 );
        }
-#endif
+#endif // !GDEF_OS_WINDOWS
 
        if ( path[1] == ':' ) {
                path += 2;
@@ -1164,7 +1156,7 @@ void    CreatePath( const char *path ){
        if ( olddrive != -1 ) {
                _chdrive( olddrive );
        }
-#endif
+#endif // !GDEF_OS_WINDOWS
 }
 
 
@@ -1188,8 +1180,7 @@ void QCopyFile( const char *from, const char *to ){
 void Sys_Sleep( int n ){
 #if GDEF_OS_WINDOWS
        Sleep( n );
-#endif
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#else // !GDEF_OS_WINDOWS
        usleep( n * 1000 );
-#endif
+#endif // !GDEF_OS_WINDOWS
 }
index 1447037759aec6699c8b3d3516156c17c38b0a3d..254977bca43accb580cbb8f8cb9ab2887d2b16c0 100644 (file)
 
 #include "globaldefs.h"
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-       #define Q_UNIX
-#endif
-
-#ifdef Q_UNIX
+#if !GDEF_OS_WINDOWS
        #include <unistd.h>
        #include <pwd.h>
        #include <limits.h>
-#endif
-
+#endif // !GDEF_OS_WINDOWS
 
 /* dependencies */
 #include "cmdlib.h"
 #include "inout.h"
 
-
-
 /* path support */
 #define MAX_BASE_PATHS  10
 #define MAX_GAME_PATHS  10
@@ -66,9 +59,9 @@ char                    *gamePaths[ MAX_GAME_PATHS ];
  */
 
 char *LokiGetHomeDir( void ){
-       #ifndef Q_UNIX
+       #if GDEF_OS_WINDOWS
        return NULL;
-       #else
+       #else // !GDEF_OS_WINDOWS
        char            *home;
        uid_t id;
        struct passwd   *pwd;
@@ -92,7 +85,7 @@ char *LokiGetHomeDir( void ){
 
        /* return it */
        return home;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
@@ -103,10 +96,10 @@ char *LokiGetHomeDir( void ){
  */
 
 void LokiInitPaths( char *argv0 ){
-       #ifndef Q_UNIX
+       #if GDEF_OS_WINDOWS
        /* this is kinda crap, but hey */
        strcpy( installPath, "../" );
-       #else
+       #else // !GDEF_OS_WINDOWS
        char temp[ MAX_OS_PATH ];
        char        *home;
        char        *path;
@@ -178,7 +171,7 @@ void LokiInitPaths( char *argv0 ){
 
        /* set home path */
        homePath = home;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
@@ -224,7 +217,7 @@ void AddBasePath( char *path ){
  */
 
 void AddHomeBasePath( char *path ){
-       #ifdef Q_UNIX
+       #if !GDEF_OS_WINDOWS
        int i;
        char temp[ MAX_OS_PATH ];
 
@@ -246,7 +239,7 @@ void AddHomeBasePath( char *path ){
        strcpy( basePaths[ 0 ], temp );
        CleanPath( basePaths[ 0 ] );
        numBasePaths++;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
index 0ee1e2d5203b1409338b992a5c84717cf4970368..5fe2894098480d6320f54b6b35c6ce91c0e7c62b 100644 (file)
@@ -25,8 +25,7 @@
 // The below define is necessary to use
 // pthreads extensions like pthread_mutexattr_settype
 #define _GNU_SOURCE
-#include <pthread.h>
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 #include "cmdlib.h"
 #include "mathlib.h"
@@ -101,6 +100,8 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 }
 
 
+#if GDEF_OS_WINDOWS
+
 /*
    ===================================================================
 
@@ -108,9 +109,6 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 
    ===================================================================
  */
-#if GDEF_OS_WINDOWS
-
-#define USED
 
 #include <windows.h>
 
@@ -211,7 +209,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
+#elif GDEF_OS_OSF1
 
 /*
    ===================================================================
@@ -221,9 +219,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    ===================================================================
  */
 
-#ifdef __osf__
-#define USED
-
 int numthreads = 4;
 
 void ThreadSetDefault( void ){
@@ -232,7 +227,6 @@ void ThreadSetDefault( void ){
        }
 }
 
-
 #include <pthread.h>
 
 pthread_mutex_t *my_mutex;
@@ -318,7 +312,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
+#elif GDEF_OS_IRIX
 
 /*
    ===================================================================
@@ -328,15 +322,11 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    ===================================================================
  */
 
-#ifdef _MIPS_ISA
-#define USED
-
 #include <task.h>
 #include <abi_mutex.h>
 #include <sys/types.h>
 #include <sys/prctl.h>
 
-
 int numthreads = -1;
 abilock_t lck;
 
@@ -405,8 +395,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
-
+#elif GDEF_OS_LINUX || GDEF_OS_BSD || GDEF_OS_MACOS
 
 /*
    =======================================================================
@@ -416,9 +405,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#if GDEF_OS_LINUX
-#define USED
-
 int numthreads = 4;
 
 void ThreadSetDefault( void ){
@@ -571,9 +557,10 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
                Sys_Printf( " (%i)\n", end - start );
        }
 }
-#endif // ifdef __linux__
 
 
+#else // UNKNOWN OS
+
 /*
    =======================================================================
 
@@ -582,8 +569,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#ifndef USED
-
 int numthreads = 1;
 
 void ThreadSetDefault( void ){
@@ -618,4 +603,4 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
        }
 }
 
-#endif
+#endif // UNKNOWN OS
index 58cc369f1ffe85e9edf644219dfc367fc4d72cb2..936cd6e525906bb8a8e21a6dca623dc028ad37f6 100644 (file)
 
 #define     MAXFILES    2048
 
+#if !GDEF_OS_WINDOWS
+#define strlwr strlower
+#endif // !GDEF_OS_WINDOWS
+
 typedef struct
 {
        int x;
index bb3be0ea50b1ce99bda7178dc50e3c0b6d9a993d..78549ad098774268925da2b903367c4c771f0b86 100644 (file)
 
 #define VERBOSE( x ) { if ( ase.verbose ) { Sys_Printf x ; } }
 
+#if !GDEF_OS_WINDOWS
+#define strlwr strlower
+#endif // !GDEF_OS_WINDOWS
+
 typedef struct
 {
        float x, y, z;
@@ -114,22 +118,6 @@ static char gl_filename[1024];
 static void ASE_Process( void );
 static void ASE_FreeGeomObject( int ndx );
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-
-static char* strlwr( char* string ){
-       char *cp;
-       for ( cp = string; *cp; ++cp )
-       {
-               if ( 'A' <= *cp && *cp <= 'Z' ) {
-                       *cp += 'a' - 'A';
-               }
-       }
-
-       return string;
-}
-
-#endif
-
 /*
 ** ASE_Load
 */
index b74c7b3362ba47b5bfeaa1edfff692bf8fbf5c63..90174e36b6cf18f8d74ea26a0ec5158d262cd7f5 100644 (file)
 #if GDEF_OS_WINDOWS
 #include <direct.h>
 #include <windows.h>
-#endif
-
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-#include <unistd.h>
-#endif
-
-#ifdef NeXT
+#elif GDEF_OS_NEXT
 #include <libc.h>
-#endif
+#else // OTHER OS
+#include <unistd.h>
+#endif // OTHER OS
 
-#define BASEDIRNAME "quake"     // assumed to have a 2 or 3 following
-#define PATHSEPERATOR   '/'
+#define BASEDIRNAME "quake" // assumed to have a 2 or 3 following
+#define PATHSEPERATOR '/'
 
 #ifdef SAFE_MALLOC
 void *safe_malloc( size_t size ){
@@ -73,7 +69,7 @@ void *safe_malloc_info( size_t size, char* info ){
 
        return p;
 }
-#endif
+#endif // !SAFE_MALLOC
 
 // set these before calling CheckParm
 int myargc;
@@ -96,6 +92,7 @@ char archivedir[1024];
 #define MAX_EX_ARGC 1024
 int ex_argc;
 char    *ex_argv[MAX_EX_ARGC];
+
 #if GDEF_OS_WINDOWS
 #include "io.h"
 void ExpandWildcards( int *argc, char ***argv ){
@@ -135,10 +132,10 @@ void ExpandWildcards( int *argc, char ***argv ){
        *argc = ex_argc;
        *argv = ex_argv;
 }
-#else
+#else // !GDEF_OS_WINDOWS
 void ExpandWildcards( int *argc, char ***argv ){
 }
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 /*
 
@@ -296,13 +293,13 @@ void Q_getwd( char *out ){
 #if GDEF_OS_WINDOWS
        _getcwd( out, 256 );
        strcat( out, "\\" );
-#else
+#else // !GDEF_OS_WINDOWS
        // Gef: Changed from getwd() to getcwd() to avoid potential buffer overflow
        if ( !getcwd( out, 256 ) ) {
                *out = 0;
        }
        strcat( out, "/" );
-#endif
+#endif // !GDEF_OS_WINDOWS
        while ( out[i] != 0 )
        {
                if ( out[i] == '\\' ) {
@@ -331,14 +328,14 @@ void Q_mkdir( const char *path ){
                                p = q;
                        }
                }
-#else
+#else // !GDEF_OS_WINDOWS
                if ( mkdir( path, 0777 ) != -1 ) {
                        return;
                }
                if ( errno == ENOENT ) {
                        p = strrchr( path, '/' );
                }
-#endif
+#endif // !GDEF_OS_WINDOWS
                if ( p ) {
                        strncpy( parentbuf, path, sizeof( parentbuf ) );
                        if ( (int) ( p - path ) < (int) sizeof( parentbuf ) ) {
@@ -931,9 +928,7 @@ float   BigFloat( float l ){
        return l;
 }
 
-
-#else
-
+#else // !GDEF_ARCH_ENDIAN_BIG
 
 short   BigShort( short l ){
        byte b1,b2;
@@ -980,8 +975,7 @@ float   LittleFloat( float l ){
        return l;
 }
 
-
-#endif
+#endif // !GDEF_ARCH_ENDIAN_BIG
 
 
 //=======================================================
@@ -1062,7 +1056,7 @@ void    CreatePath( const char *path ){
                olddrive = _getdrive();
                _chdrive( toupper( path[0] ) - 'A' + 1 );
        }
-#endif
+#endif // !GDEF_OS_WINDOWS
 
        if ( path[1] == ':' ) {
                path += 2;
@@ -1082,7 +1076,7 @@ void    CreatePath( const char *path ){
        if ( olddrive != -1 ) {
                _chdrive( olddrive );
        }
-#endif
+#endif // !>GDEF_OS_WINDOWS
 }
 
 
@@ -1106,8 +1100,7 @@ void QCopyFile( const char *from, const char *to ){
 void Sys_Sleep( int n ){
 #if GDEF_OS_WINDOWS
        Sleep( n );
-#endif
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#else // !GDEF_OS_WINDOWS
        usleep( n * 1000 );
-#endif
+#endif // !GDEF_OS_WINDOWS
 }
index 4cb3e4fee061a7f70e28ca20db843c4eaef32989..5d81cf5eded55ca542f7db18e90a69e1bf8385f7 100644 (file)
 
 #include "globaldefs.h"
 #include <stdint.h>
+
 #if !GDEF_OS_WINDOWS
 // The below define is necessary to use
 // pthreads extensions like pthread_mutexattr_settype
 #define _GNU_SOURCE
-#include <pthread.h>
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 #include "cmdlib.h"
 #include "mathlib.h"
@@ -111,6 +111,8 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 }
 
 
+#if GDEF_OS_WINDOWS
+
 /*
    ===================================================================
 
@@ -118,9 +120,6 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )(
 
    ===================================================================
  */
-#if GDEF_OS_WINDOWS
-
-#define USED
 
 #include <windows.h>
 
@@ -221,7 +220,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
+#elif GDEF_OS_OSF1
 
 /*
    ===================================================================
@@ -231,9 +230,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    ===================================================================
  */
 
-#ifdef __osf__
-#define USED
-
 int numthreads = 4;
 
 void ThreadSetDefault( void ){
@@ -242,7 +238,6 @@ void ThreadSetDefault( void ){
        }
 }
 
-
 #include <pthread.h>
 
 pthread_mutex_t *my_mutex;
@@ -328,7 +323,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
+#elif GDEF_OS_IRIX
 
 /*
    ===================================================================
@@ -338,7 +333,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    ===================================================================
  */
 
-#ifdef _MIPS_ISA
 #define USED
 
 #include <task.h>
@@ -346,7 +340,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 #include <sys/types.h>
 #include <sys/prctl.h>
 
-
 int numthreads = -1;
 abilock_t lck;
 
@@ -415,8 +408,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
 }
 
 
-#endif
-
+#elif GDEF_OS_LINUX || GDEF_OS_BSD || GDEF_OS_MACOS
 
 /*
    =======================================================================
@@ -426,9 +418,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-#define USED
-
 #include <unistd.h>
 
 int numthreads = -1;
@@ -597,9 +586,10 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
                Sys_Printf( " (%i)\n", end - start );
        }
 }
-#endif // ifdef __linux__
 
 
+#else // UNKNOWN OS
+
 /*
    =======================================================================
 
@@ -608,8 +598,6 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
    =======================================================================
  */
 
-#ifndef USED
-
 int numthreads = 1;
 
 void ThreadSetDefault( void ){
@@ -643,4 +631,4 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){
        }
 }
 
-#endif
+#endif // UNKNOWN OS
index 5f403418ff449077f8c7a2f1a83d5451ac0b4278..72dd5f3c4f71f886e886df5cf8701e22910e82cb 100644 (file)
 #define FLOAT_END   -FLOAT_START
 #define MAGIC       123322
 
-//#define NOISY 1
+// #define NOISY 1
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#if !GDEF_OS_WINDOWS
 #define strlwr strlower
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 typedef struct {
        float v[3];
index 9026a29691506bd782d76dd46ad5bb4af745c7fa..310d67c56a3120956e0f96921e31f8dc122aba8f 100644 (file)
 
 // to get PATH_MAX
 #include <stdio.h>
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-#include <dirent.h>
-#include <unistd.h>
-#else
+
+#if GDEF_OS_WINDOWS
 #include <wtypes.h>
 #include <io.h>
 #define S_ISDIR( mode ) ( mode & _S_IFDIR )
 #define PATH_MAX 260
-#endif
+#else // !GDEF_OS_WINDOWS
+#include <dirent.h>
+#include <unistd.h>
+#endif // !GDEF_OS_WINDOWS
 
 #define VFS_MAXDIRS 64
 
index 93b1dfe0028787d2a015149839f62ca7788c54df..2bc7e09a7f03c59f07539a5e3e496af2f0347d05 100644 (file)
 
 #include "globaldefs.h"
 #include <assert.h>
+
 #if GDEF_OS_WINDOWS
 #include <io.h>
-#endif
+#endif // GDEF_OS_WINDOWS
+
 #include "md3lib.h"
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
-#define filelength(f) Q_filelength(f)
-#else
+#if GDEF_OS_WINDOWS
 #define filelength(f) filelength(fileno(f))
-#endif
+#else // !GDEF_OS_WINDOWS
+#define filelength(f) Q_filelength(f)
+#endif // ! GDEF_OS_WINDOWS
 
 /*
 ** MD3_ComputeTagFromTri
index 97cc3f6a229510eda76ba7932e1773e94575113f..ea59bb4d1eeafe2e62ae729aa13a7a3d9c1d1823 100644 (file)
 
 #if GDEF_OS_WINDOWS
 #include <io.h>
-#endif
+#endif // GDEF_OS_WINDOWS
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 
 #define MAX_POLYSETS 64
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#if GDEF_OS_WINDOWS
+       #define filelength(f) filelength(fileno(f))
+#else // !GDEF_OS_WINDOWS
        #include "cmdlib.h"
        #define _strcmpi Q_stricmp
        #define strlwr strlower
        #define filelength(f) Q_filelength(f)
-#else
-       #define filelength(f) filelength(fileno(f))
-#endif
+#endif // !GDEF_OS_WINDOWS
+
 typedef struct
 {
        long len;
index 331f6138c352448d04e97fc5bcef5c2940b898ea..0b75861e5712c62d26d7bc36a878cac1811874ad 100644 (file)
  */
 
 #include "globaldefs.h"
+
 #if GDEF_OS_WINDOWS
 #include <io.h>
-#endif
+#endif // GDEF_OS_WINDOWS
+
 #include "q3data.h"
 #include "md3lib.h"
 
@@ -41,9 +43,9 @@ char *moddir = NULL;
 // some old defined that was in cmdlib lost during merge
 char writedir[1024];
 
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
+#if !GDEF_OS_WINDOWS
 #define strlwr strlower
-#endif
+#endif // !GDEF_OS_WINDOWS
 
 /*
    =======================================================
index 96b33fcbae6d39cfd9decb777018d76d94f5845a..9c3047de17357778bd7b64880b29edf7744a2bff 100644 (file)
 
    ------------------------------------------------------------------------------- */
 
-
-
 /* marker */
 #define PATH_INIT_C
 
-
-
 /* dependencies */
 #include "q3map2.h"
 
-
-
 /* path support */
 #define MAX_BASE_PATHS  10
 #define MAX_GAME_PATHS  10
@@ -48,11 +42,9 @@ char                    *homePath;
 
 #if GDEF_OS_MACOS
 char                                   *macLibraryApplicationSupportPath;
-#endif
-
-#if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+#elif GDEF_OS_XDG
 char                    *xdgDataHomePath;
-#endif // (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+#endif // GDEF_OS_XDG
 
 char installPath[ MAX_OS_PATH ];
 
@@ -96,7 +88,7 @@ char *LokiGetHomeDir( void ){
 
        /* return it */
        return home;
-       #endif
+       #endif // !GDEF_OS_WINDOWS
 }
 
 
@@ -124,12 +116,10 @@ void LokiInitPaths( char *argv0 ){
        }
 
        #if GDEF_OS_MACOS
-               char *subPath = "/Library/Application Support";
-               macLibraryApplicationSupportPath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) );
-               sprintf( macLibraryApplicationSupportPath, "%s%s", home, subPath );
-       #endif // GDEF_OS_MACOS
-
-       #if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+       char *subPath = "/Library/Application Support";
+       macLibraryApplicationSupportPath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) );
+       sprintf( macLibraryApplicationSupportPath, "%s%s", home, subPath );
+       #elif GDEF_OS_XDG
        xdgDataHomePath = getenv( "XDG_DATA_HOME" );
 
        if ( xdgDataHomePath == NULL ) {
@@ -137,7 +127,7 @@ void LokiInitPaths( char *argv0 ){
                xdgDataHomePath = safe_malloc( sizeof( char ) * ( strlen( home ) + strlen( subPath ) ) );
                sprintf( xdgDataHomePath, "%s%s", home, subPath );
        }
-       #endif // (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+       #endif // GDEF_OS_XDG
 
        #if GDEF_OS_WINDOWS
        /* this is kinda crap, but hey */
@@ -350,9 +340,7 @@ void AddHomeBasePath( char *path ){
                */
                tempHomePath = macLibraryApplicationSupportPath;
                path = path + 1;
-               #endif // GDEF_OS_MACOS
-
-               #if (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+               #elif GDEF_OS_XDG
                /*
                   on Linux, check if game uses ${XDG_DATA_HOME}/prefix instead of ${HOME}/.prefix
                   if yes and home path is not user supplied
@@ -375,7 +363,7 @@ void AddHomeBasePath( char *path ){
                        }
                        path = path + 1;
                }
-               #endif // (GDEF_OS_POSIX && !GDEF_OS_MACOS)
+               #endif // GDEF_OS_XDG
 
                /* concatenate home dir and path */
                sprintf( temp, "%s/%s", tempHomePath, path );
index ce37d76c2deabee2311ee478ca0cdc501a34b489..0d70d39d296ce981ae20e1794094bd025d83cd74 100644 (file)
 
    ------------------------------------------------------------------------------- */
 
-#if 1
-       #if GDEF_OS_WINDOWS
-               #define Q_stricmp           stricmp
-               #define Q_strncasecmp       strnicmp
-       #else
-               #define Q_stricmp           strcasecmp
-               #define Q_strncasecmp       strncasecmp
-       #endif
+#if GDEF_OS_WINDOWS
+       #define Q_stricmp           stricmp
+       #define Q_strncasecmp       strnicmp
+#else
+       #define Q_stricmp           strcasecmp
+       #define Q_strncasecmp       strncasecmp
 #endif
 
 /* macro version */