From: TimePath Date: Fri, 29 Dec 2017 07:16:48 +0000 (+1100) Subject: Centralise compile checks X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0f2e4b773715b05595f1c149d99fcc4795e01948;p=xonotic%2Fnetradiant.git Centralise compile checks --- diff --git a/contrib/bobtoolz/DBrush.cpp b/contrib/bobtoolz/DBrush.cpp index 4a2b9c09..6e650807 100644 --- a/contrib/bobtoolz/DBrush.cpp +++ b/contrib/bobtoolz/DBrush.cpp @@ -22,8 +22,9 @@ ////////////////////////////////////////////////////////////////////// #include "DBrush.h" +#include "globaldefs.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4786) #endif @@ -68,7 +69,7 @@ DBrush::~DBrush(){ ////////////////////////////////////////////////////////////////////// DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, const _QERFaceData* texData ){ -#ifdef _DEBUG +#if GDEF_DEBUG // Sys_Printf("(%f %f %f) (%f %f %f) (%f %f %f)\n", va[0], va[1], va[2], vb[0], vb[1], vb[2], vc[0], vc[1], vc[2]); #endif bBoundsBuilt = false; @@ -117,7 +118,7 @@ int DBrush::BuildPoints(){ } } -#ifdef _DEBUG +#if GDEF_DEBUG // Sys_Printf("%i points on brush\n", pointList.size()); #endif diff --git a/contrib/bobtoolz/DEntity.cpp b/contrib/bobtoolz/DEntity.cpp index 38ab47f4..9fccf6b7 100644 --- a/contrib/bobtoolz/DEntity.cpp +++ b/contrib/bobtoolz/DEntity.cpp @@ -22,8 +22,9 @@ ////////////////////////////////////////////////////////////////////// #include "DEntity.h" +#include "globaldefs.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4786) #endif diff --git a/contrib/bobtoolz/bsploader.cpp b/contrib/bobtoolz/bsploader.cpp index 0fb93c57..0c442e16 100644 --- a/contrib/bobtoolz/bsploader.cpp +++ b/contrib/bobtoolz/bsploader.cpp @@ -1,3 +1,4 @@ +#include #include "bsploader.h" #include "dialogs/dialogs-gtk.h" #include "cmdlib.h" @@ -71,16 +72,16 @@ bool LoadFile( const char *filename, byte **bufferptr ){ } int LittleLong( int l ){ -#if defined( __BIG_ENDIAN__ ) - std::reverse( reinterpret_cast( &l ), reinterpret_cast( &l ) + sizeof( int ) ); -#endif + if (GDEF_ARCH_ENDIAN_BIG) { + std::reverse(reinterpret_cast( &l ), reinterpret_cast( &l ) + sizeof(int)); + } return l; } float LittleFloat( float l ){ -#if defined( __BIG_ENDIAN__ ) - std::reverse( reinterpret_cast( &l ), reinterpret_cast( &l ) + sizeof( float ) ); -#endif + if (GDEF_ARCH_ENDIAN_BIG) { + std::reverse( reinterpret_cast( &l ), reinterpret_cast( &l ) + sizeof( float ) ); + } return l; } diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index aa8e6478..b07bf328 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -18,8 +18,9 @@ */ #include "funchandlers.h" +#include "globaldefs.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4786) #endif diff --git a/contrib/bobtoolz/lists.cpp b/contrib/bobtoolz/lists.cpp index 96aff197..38ec080e 100644 --- a/contrib/bobtoolz/lists.cpp +++ b/contrib/bobtoolz/lists.cpp @@ -18,8 +18,9 @@ */ #include "lists.h" +#include "globaldefs.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4786) #endif diff --git a/contrib/bobtoolz/misc.cpp b/contrib/bobtoolz/misc.cpp index 202065fc..f73c9787 100644 --- a/contrib/bobtoolz/misc.cpp +++ b/contrib/bobtoolz/misc.cpp @@ -18,6 +18,7 @@ */ #include "misc.h" +#include "globaldefs.h" #include #include "str.h" @@ -31,7 +32,7 @@ #include "funchandlers.h" -#if defined ( POSIX ) +#if GDEF_OS_POSIX #include #include #endif @@ -146,7 +147,7 @@ char* TranslateString( char *buf ){ char* UnixToDosPath( char* path ){ -#ifndef WIN32 +#if !GDEF_OS_WINDOWS return path; #else for ( char* p = path; *p; p++ ) @@ -182,7 +183,7 @@ extern char* PLUGIN_NAME; return buffer; }*/ -#if defined ( POSIX ) +#if GDEF_OS_POSIX // the bCreateConsole parameter is ignored on linux .. bool Q_Exec( const char *pCmd, bool bCreateConsole ){ switch ( fork() ) @@ -192,7 +193,7 @@ bool Q_Exec( const char *pCmd, bool bCreateConsole ){ // Error ("CreateProcess failed"); break; case 0: -#ifdef _DEBUG +#if GDEF_DEBUG printf( "Running system...\n" ); printf( "Command: %s\n", pCmd ); #endif @@ -208,7 +209,7 @@ bool Q_Exec( const char *pCmd, bool bCreateConsole ){ } #endif -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include diff --git a/contrib/brushexport/export.cpp b/contrib/brushexport/export.cpp index 09720d8d..cbc4abf6 100644 --- a/contrib/brushexport/export.cpp +++ b/contrib/brushexport/export.cpp @@ -1,4 +1,5 @@ #include "export.h" +#include "globaldefs.h" #include "debugging/debugging.h" #include "ibrush.h" #include "iscenegraph.h" @@ -126,7 +127,7 @@ void ExportData::AddBrushFace( Face& f ){ // add face to current group current->faces.push_back( &f ); -#ifdef _DEBUG +#if GDEF_DEBUG globalOutputStream() << "Added Face to group " << current->name.c_str() << "\n"; #endif } @@ -143,7 +144,7 @@ void ExportData::GetShaderNameFromShaderPath( const char* path, std::string& nam name = tmp.substr( last_slash + 1, tmp.length() - last_slash ); } -#ifdef _DEBUG +#if GDEF_DEBUG globalOutputStream() << "Last: " << (const unsigned int) last_slash << " " << "length: " << (const unsigned int)tmp.length() << "Name: " << name.c_str() << "\n"; #endif } diff --git a/contrib/camera/funchandlers.cpp b/contrib/camera/funchandlers.cpp index 4134a889..f3be8e3b 100644 --- a/contrib/camera/funchandlers.cpp +++ b/contrib/camera/funchandlers.cpp @@ -25,13 +25,14 @@ */ #include "camera.h" +#include "globaldefs.h" extern GtkWidget *g_pEditModeAddRadioButton; char* Q_realpath( const char *path, char *resolved_path, size_t size ){ -#if defined( POSIX ) +#if GDEF_OS_POSIX return realpath( path, resolved_path ); -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS return _fullpath( resolved_path, path, size ); #else #error "unsupported platform" diff --git a/contrib/camera/misc.cpp b/contrib/camera/misc.cpp index 372dc7bc..88207af7 100644 --- a/contrib/camera/misc.cpp +++ b/contrib/camera/misc.cpp @@ -25,6 +25,7 @@ */ #include "camera.h" +#include "globaldefs.h" void Sys_ERROR( char* text, ... ){ va_list argptr; @@ -38,7 +39,7 @@ void Sys_ERROR( char* text, ... ){ } char* UnixToDosPath( char* path ){ -#ifndef WIN32 +#if !GDEF_OS_WINDOWS return path; #else for ( char* p = path; *p; p++ ) @@ -132,7 +133,7 @@ void CDECL Com_Printf( const char* msg, ... ){ } void CDECL Com_DPrintf( const char* msg, ... ){ -#ifdef _DEBUG +#if GDEF_DEBUG va_list argptr; char buf[32768]; @@ -156,7 +157,7 @@ void Com_Dealloc( void *ptr ) { // Filesystem // -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4311) #pragma warning(disable : 4312) #endif diff --git a/contrib/camera/misc.h b/contrib/camera/misc.h index 6e226d33..9b3f71b7 100644 --- a/contrib/camera/misc.h +++ b/contrib/camera/misc.h @@ -24,6 +24,8 @@ Copyright (C) 2002 Splash Damage Ltd. */ +#include "globaldefs.h" + void Sys_ERROR( char* text, ... ); char* UnixToDosPath( char* path ); void ExtractFilePath( const char *path, char *dest ); @@ -40,7 +42,7 @@ void Cbuf_Execute( void ); // common #ifndef CDECL -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define CDECL __cdecl #else #define CDECL diff --git a/contrib/gtkgensurf/gensurf.h b/contrib/gtkgensurf/gensurf.h index cb4a2d55..7a90cb64 100644 --- a/contrib/gtkgensurf/gensurf.h +++ b/contrib/gtkgensurf/gensurf.h @@ -20,6 +20,7 @@ #ifndef _GENSURF_H_ #define _GENSURF_H_ +#include "globaldefs.h" #include #include "qertypes.h" #include @@ -56,7 +57,7 @@ extern _QERBrushTable __BRUSHTABLENAME; #define PLUGIN #define Q3RADIANT -//#if defined(__linux__) || defined(__APPLE__) +//#if GDEF_OS_LINUX || GDEF_OS_MACOS #if 1 #include #else diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index efc8d505..7a2d99d1 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -18,9 +18,10 @@ */ #include "portals.h" +#include "globaldefs.h" #include #include -#ifndef __APPLE__ +#if !GDEF_OS_MACOS #include #endif #include diff --git a/contrib/sunplug/sunplug.cpp b/contrib/sunplug/sunplug.cpp index a6928537..afa4b20d 100644 --- a/contrib/sunplug/sunplug.cpp +++ b/contrib/sunplug/sunplug.cpp @@ -19,6 +19,7 @@ */ #include "sunplug.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -39,7 +40,7 @@ void about_plugin_window(); void MapCoordinator(); -#ifndef _WIN32 +#if !GDEF_OS_WINDOWS // linux itoa implementation char* itoa( int value, char* result, int base ){ // check that the base if valid diff --git a/contrib/ufoaiplug/ufoai_filters.cpp b/contrib/ufoaiplug/ufoai_filters.cpp index 84a96652..c40de733 100644 --- a/contrib/ufoaiplug/ufoai_filters.cpp +++ b/contrib/ufoaiplug/ufoai_filters.cpp @@ -17,6 +17,7 @@ */ #include "ufoai_filters.h" +#include "globaldefs.h" #include "ibrush.h" #include "ientity.h" @@ -100,7 +101,7 @@ ForEachFace( Brush& brush ) } void visit( Face& face ) const { -#if _DEBUG +#if GDEF_DEBUG if ( m_surfaceFlagsVis < 0 ) { m_surfaceFlagsVis = face.getShader().m_flags.m_surfaceFlags; } @@ -215,7 +216,7 @@ void filter_level( int flag ){ GlobalSceneGraph().traverse( EntityFindByName( "misc_model", entities, level, true ) ); GlobalSceneGraph().traverse( EntityFindByName( "misc_particle", entities, level, true ) ); -#ifdef _DEBUG +#if GDEF_DEBUG if ( brushes.empty() ) { globalOutputStream() << "UFO:AI: No brushes.\n"; } @@ -264,7 +265,7 @@ void filter_nodraw( void ){ brushlist_t brushes; GlobalSceneGraph().traverse( BrushGetLevel( brushes, SURF_NODRAW, false, false, nodraw_active ) ); -#ifdef _DEBUG +#if GDEF_DEBUG if ( brushes.empty() ) { globalOutputStream() << "UFO:AI: No brushes.\n"; } @@ -285,7 +286,7 @@ void filter_actorclip( void ){ brushlist_t brushes; GlobalSceneGraph().traverse( BrushGetLevel( brushes, CONTENTS_ACTORCLIP, true, false, actorclip_active ) ); -#ifdef _DEBUG +#if GDEF_DEBUG if ( brushes.empty() ) { globalOutputStream() << "UFO:AI: No brushes.\n"; } @@ -306,7 +307,7 @@ void filter_weaponclip( void ){ brushlist_t brushes; GlobalSceneGraph().traverse( BrushGetLevel( brushes, CONTENTS_WEAPONCLIP, true, false, weaponclip_active ) ); -#ifdef _DEBUG +#if GDEF_DEBUG if ( brushes.empty() ) { globalOutputStream() << "UFO:AI: No brushes.\n"; } diff --git a/include/igl.h b/include/igl.h index eca09ae7..cb7b66d1 100644 --- a/include/igl.h +++ b/include/igl.h @@ -22,11 +22,12 @@ #if !defined( INCLUDED_IGL_H ) #define INCLUDED_IGL_H +#include "globaldefs.h" #include #include #include "generic/constant.h" -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define QGL_DLLEXPORT __stdcall #else #define QGL_DLLEXPORT @@ -2805,7 +2806,7 @@ inline OpenGLBinding& GlobalOpenGL(){ return GlobalOpenGLModule::getTable(); } -#if defined( _DEBUG ) +#if GDEF_DEBUG #define GlobalOpenGL_debugAssertNoErrors() GlobalOpenGL().assertNoErrors( __FILE__, __LINE__ ) #else #define GlobalOpenGL_debugAssertNoErrors() diff --git a/include/ipatch.h b/include/ipatch.h index 81cba69a..bf26e8b4 100644 --- a/include/ipatch.h +++ b/include/ipatch.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_IPATCH_H ) #define INCLUDED_IPATCH_H +#include "globaldefs.h" #include "debugging/debugging.h" #include "generic/constant.h" #include "generic/vector.h" @@ -62,13 +63,13 @@ const_iterator end() const { } value_type& operator[]( std::size_t index ){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( index < size(), "array index out of bounds" ); #endif return m_data[index]; } const value_type& operator[]( std::size_t index ) const { -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( index < size(), "array index out of bounds" ); #endif return m_data[index]; @@ -167,25 +168,25 @@ const_iterator end() const { } value_type& operator[]( std::size_t index ){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( index < size(), "array index out of bounds" ); #endif return m_data[index]; } const value_type& operator[]( std::size_t index ) const { -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( index < size(), "array index out of bounds" ); #endif return m_data[index]; } value_type& operator()( std::size_t x, std::size_t y ){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" ); #endif return m_data[x * m_y + y]; } const value_type& operator()( std::size_t x, std::size_t y ) const { -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( x < m_x && y < m_y, "array index out of bounds" ); #endif return m_data[x * m_y + y]; diff --git a/include/modulesystem.h b/include/modulesystem.h index b8c83489..f7d46564 100644 --- a/include/modulesystem.h +++ b/include/modulesystem.h @@ -22,10 +22,11 @@ #if !defined( INCLUDED_MODULESYSTEM_H ) #define INCLUDED_MODULESYSTEM_H +#include "globaldefs.h" #include "generic/static.h" #include "debugging/debugging.h" -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define RADIANT_DLLEXPORT __declspec(dllexport) #define RADIANT_DLLIMPORT __declspec(dllimport) #else @@ -145,7 +146,7 @@ ModuleRef( const char* name ) : m_table( 0 ){ } } Type* getTable(){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( m_table != 0, "ModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" ); #endif return m_table; @@ -176,7 +177,7 @@ void initialise( const char* name ){ } Type* getTable(){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( m_table != 0, "SingletonModuleRef::getTable: type=" << makeQuoted( typename Type::Name() ) << " version=" << makeQuoted( typename Type::Version() ) << " - module-reference used without being initialised" ); #endif return m_table; diff --git a/include/warnings.h b/include/warnings.h index e067fd11..ebbd4f88 100644 --- a/include/warnings.h +++ b/include/warnings.h @@ -22,7 +22,9 @@ #if !defined ( INCLUDED_WARNINGS_H ) #define INCLUDED_WARNINGS_H -#if _MSC_VER > 1000 && defined( WIN32 ) +#include "globaldefs.h" + +#if GDEF_COMPILER_MSVC && _MSC_VER > 1000 #pragma warning(disable:4355) // 'this' : used in base member initializer list #pragma warning(disable:4503) // '[symbol]' : decorated name length exceeded, name was truncated #endif diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 03347d71..9094354e 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -37,6 +37,7 @@ add_library(libs entityxml.h fs_filesystem.h fs_path.h + globaldefs.h imagelib.h instancelib.h maplib.h diff --git a/libs/bytestreamutils.h b/libs/bytestreamutils.h index 90a9048a..69ec3755 100644 --- a/libs/bytestreamutils.h +++ b/libs/bytestreamutils.h @@ -22,7 +22,9 @@ #if !defined( INCLUDED_BYTESTREAMUTILS_H ) #define INCLUDED_BYTESTREAMUTILS_H -#if defined( __GNUC__ ) +#include "globaldefs.h" + +#if GDEF_COMPILER_GNU #define _ISOC9X_SOURCE 1 #define _ISOC99_SOURCE 1 @@ -55,18 +57,20 @@ typedef unsigned int uint32_t; template inline void istream_read_little_endian( InputStreamType& istream, Type& value ){ - istream.read( reinterpret_cast( &value ), sizeof( Type ) ); -#if defined( __BIG_ENDIAN__ ) - std::reverse( reinterpret_cast( &value ), reinterpret_cast( &value ) + sizeof( Type ) ); -#endif + istream.read(reinterpret_cast( &value ), sizeof(Type)); + if (GDEF_ARCH_ENDIAN_BIG) { + std::reverse(reinterpret_cast( &value ), + reinterpret_cast( &value ) + sizeof(Type)); + } } template inline void istream_read_big_endian( InputStreamType& istream, Type& value ){ - istream.read( reinterpret_cast( &value ), sizeof( Type ) ); -#if !defined( __BIG_ENDIAN__ ) - std::reverse( reinterpret_cast( &value ), reinterpret_cast( &value ) + sizeof( Type ) ); -#endif + istream.read(reinterpret_cast( &value ), sizeof(Type)); + if (!GDEF_ARCH_ENDIAN_BIG) { + std::reverse(reinterpret_cast( &value ), + reinterpret_cast( &value ) + sizeof(Type)); + } } template diff --git a/libs/cmdlib.h b/libs/cmdlib.h index 843dee76..abdc15a6 100644 --- a/libs/cmdlib.h +++ b/libs/cmdlib.h @@ -26,6 +26,7 @@ #ifndef __CMDLIB__ #define __CMDLIB__ +#include "globaldefs.h" #include @@ -78,7 +79,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *execdir, bool bCreateCo // Q_mkdir // returns true if succeeded in creating directory -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include inline bool Q_mkdir( const char* name ){ return _mkdir( name ) != -1; diff --git a/libs/cmdlib/cmdlib.cpp b/libs/cmdlib/cmdlib.cpp index 2a9ab55a..9bfd2436 100644 --- a/libs/cmdlib/cmdlib.cpp +++ b/libs/cmdlib/cmdlib.cpp @@ -24,6 +24,7 @@ // #include "cmdlib.h" +#include "globaldefs.h" #include #include @@ -33,7 +34,7 @@ #include "container/array.h" -#if defined ( POSIX ) +#if GDEF_OS_POSIX #include #include @@ -43,7 +44,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){ char fullcmd[2048]; char *pCmd; pid_t pid; -#ifdef _DEBUG +#if GDEF_DEBUG printf( "Q_Exec damnit\n" ); #endif switch ( ( pid = fork() ) ) @@ -71,12 +72,12 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){ pCmd = fullcmd; while ( *pCmd == ' ' ) pCmd++; -#ifdef _DEBUG +#if GDEF_DEBUG printf( "Running system...\n" ); printf( "Command: %s\n", pCmd ); #endif system( pCmd ); -#ifdef _DEBUG +#if GDEF_DEBUG printf( "system() returned\n" ); #endif _exit( 0 ); @@ -85,7 +86,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){ return true; } -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS #include diff --git a/libs/container/array.h b/libs/container/array.h index 390282a7..5de4fe82 100644 --- a/libs/container/array.h +++ b/libs/container/array.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_CONTAINER_ARRAY_H ) #define INCLUDED_CONTAINER_ARRAY_H +#include "globaldefs.h" #include #include @@ -119,13 +120,13 @@ const_iterator end() const { } value_type& operator[]( std::size_t index ){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( index < size(), "array index out of bounds" ); #endif return m_data[index]; } const value_type& operator[]( std::size_t index ) const { -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( index < size(), "array index out of bounds" ); #endif return m_data[index]; diff --git a/libs/container/hashtable.cpp b/libs/container/hashtable.cpp index edcaff63..f2e66022 100644 --- a/libs/container/hashtable.cpp +++ b/libs/container/hashtable.cpp @@ -20,8 +20,9 @@ */ #include "hashtable.h" +#include "globaldefs.h" -#if defined( _DEBUG ) || defined( DOXYGEN ) +#if GDEF_DEBUG || defined( DOXYGEN ) #include "hashfunc.h" diff --git a/libs/ddslib/ddslib.c b/libs/ddslib/ddslib.c index 26ccf2e9..15dbef80 100644 --- a/libs/ddslib/ddslib.c +++ b/libs/ddslib/ddslib.c @@ -37,8 +37,7 @@ /* dependencies */ #include "ddslib.h" - - +#include "globaldefs.h" /* endian tomfoolery */ typedef union @@ -48,15 +47,7 @@ typedef union } floatSwapUnion; - -#ifndef __BIG_ENDIAN__ - #ifdef _SGI_SOURCE - #define __BIG_ENDIAN__ - #endif -#endif - - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG int DDSBigLong( int src ) { return src; } short DDSBigShort( short src ) { return src; } diff --git a/libs/debugging/debugging.h b/libs/debugging/debugging.h index 0e008b61..405131d2 100644 --- a/libs/debugging/debugging.h +++ b/libs/debugging/debugging.h @@ -25,13 +25,14 @@ /// \file /// \brief Debugging macros for fatal error/assert messages. +#include "globaldefs.h" #include "stream/textstream.h" #include "warnings.h" #include "generic/static.h" -#if defined( _MSC_VER ) && ( defined( _M_IX86 ) || defined( _M_AMD64 ) ) +#if GDEF_COMPILER_MSVC && ( defined( _M_IX86 ) || defined( _M_AMD64 ) ) #define DEBUGGER_BREAKPOINT() __asm { int 3 } -#elif ( defined ( __i386__ ) || defined ( __x86_64__ ) ) && defined ( __GNUC__ ) && __GNUC__ >= 2 +#elif GDEF_COMPILER_GNU && __GNUC__ >= 2 && ( defined ( __i386__ ) || defined ( __x86_64__ ) ) #define DEBUGGER_BREAKPOINT() __asm__ __volatile__ ( "int $03" ) #else #include @@ -43,9 +44,7 @@ #define STR2( x ) STR( x ) #define FILE_LINE __FILE__ ":" STR2( __LINE__ ) -#if defined( _DEBUG ) || 1 #define DEBUG_ASSERTS -#endif class DebugMessageHandler { @@ -72,7 +71,7 @@ virtual TextOutputStream& getOutputStream(){ return globalErrorStream(); } virtual bool handleMessage(){ -#if defined( _DEBUG ) +#if GDEF_DEBUG return false; // send debug-break #else return true; diff --git a/libs/generic/callback.cpp b/libs/generic/callback.cpp index c4fefb8e..74fe6ee0 100644 --- a/libs/generic/callback.cpp +++ b/libs/generic/callback.cpp @@ -20,8 +20,9 @@ */ #include "callback.h" +#include "globaldefs.h" -#if defined( _DEBUG ) || defined( DOXYGEN ) +#if GDEF_DEBUG || defined( DOXYGEN ) namespace ExampleMemberCaller { diff --git a/libs/generic/constant.cpp b/libs/generic/constant.cpp index 7c3c2fa6..bcf9b4e5 100644 --- a/libs/generic/constant.cpp +++ b/libs/generic/constant.cpp @@ -20,8 +20,9 @@ */ #include "constant.h" +#include "globaldefs.h" -#if defined( _DEBUG ) || defined( DOXYGEN ) +#if GDEF_DEBUG || defined( DOXYGEN ) namespace ExampleConstant { diff --git a/libs/generic/object.h b/libs/generic/object.h index 5677a0e3..084f760c 100644 --- a/libs/generic/object.h +++ b/libs/generic/object.h @@ -22,12 +22,14 @@ #if !defined( INCLUDED_GENERIC_OBJECT_H ) #define INCLUDED_GENERIC_OBJECT_H +#include "globaldefs.h" + /// \file /// \brief Convenience functions (syntactic sugar) to wrap explicit constructor (aka in-place 'new') and destructor calls. /// /// Use makeReference() to wrap non-const-reference constructor parameters. -#if _MSC_VER > 1000 && defined( WIN32 ) +#if GDEF_COMPILER_MSVC && _MSC_VER > 1000 #pragma warning(disable:4345) // behavior change: an object of POD type constructed with an initializer of the form () will be default-initialized #endif diff --git a/libs/generic/static.cpp b/libs/generic/static.cpp index b32972de..a92246bb 100644 --- a/libs/generic/static.cpp +++ b/libs/generic/static.cpp @@ -20,8 +20,9 @@ */ #include "static.h" +#include "globaldefs.h" -#if defined( _DEBUG ) || defined( DOXYGEN ) +#if GDEF_DEBUG || defined( DOXYGEN ) namespace ExampleStatic { diff --git a/libs/globaldefs.h b/libs/globaldefs.h new file mode 100644 index 00000000..146dd788 --- /dev/null +++ b/libs/globaldefs.h @@ -0,0 +1,125 @@ +#ifndef INCLUDED_LIBS_GLOBALDEFS +#define INCLUDED_LIBS_GLOBALDEFS + +// ARCH_ENDIAN + +#if defined(__BIG_ENDIAN__) || defined(_SGI_SOURCE) +#define GDEF_ARCH_ENDIAN_BIG 1 +#else +#define GDEF_ARCH_ENDIAN_BIG 0 +#endif + +// ARCH_BITS + +#if defined(__i386__) || defined(_M_IX86) +#define GDEF_ARCH_BITS_32 1 +#else +#define GDEF_ARCH_BITS_32 0 +#endif + +#if defined(__LP64__) || defined(_M_X64) || defined(_M_AMD64) || defined(_WIN64) +#define GDEF_ARCH_BITS_64 1 +#else +#define GDEF_ARCH_BITS_64 0 +#endif + +// OS + +#if defined(POSIX) +#define GDEF_OS_POSIX 1 +#else +#define GDEF_OS_POSIX 0 +#endif + +#if defined(WIN32) || defined(_WIN32) || defined(_WIN64) +#define GDEF_OS_WINDOWS 1 +#else +#define GDEF_OS_WINDOWS 0 +#endif + +#if defined(__APPLE__) +#define GDEF_OS_MACOS 1 +#else +#define GDEF_OS_MACOS 0 +#endif + +#if defined(__linux__) +#define GDEF_OS_LINUX 1 +#else +#define GDEF_OS_LINUX 0 +#endif + + +#define GDEF_OS_BSD 0 + +#if defined(__FreeBSD__) +#undef GDEF_OS_BSD +#define GDEF_OS_BSD 1 +#define GDEF_OS_BSD_FREE 1 +#else +#define GDEF_OS_BSD_FREE 0 +#endif + +#if defined(__NetBSD__) +#undef GDEF_OS_BSD +#define GDEF_OS_BSD 1 +#define GDEF_OS_BSD_NET 1 +#else +#define GDEF_OS_BSD_NET 0 +#endif + +#if defined(__OpenBSD__) +#undef GDEF_OS_BSD +#define GDEF_OS_BSD 1 +#define GDEF_OS_BSD_OPEN 1 +#else +#define GDEF_OS_BSD_OPEN 0 +#endif + +#if defined(__DragonFly__) +#undef GDEF_OS_BSD +#define GDEF_OS_BSD 1 +#define GDEF_OS_BSD_DRAGONFLY 1 +#else +#define GDEF_OS_BSD_DRAGONFLY 0 +#endif + +// COMPILER + +#if defined(_MSC_VER) +#define GDEF_COMPILER_MSVC 1 +#else +#define GDEF_COMPILER_MSVC 0 +#endif + +#if defined(__GNUC__) +#define GDEF_COMPILER_GNU 1 +#else +#define GDEF_COMPILER_GNU 0 +#endif + +// ATTRIBUTE + +#if GDEF_COMPILER_GNU +#define GDEF_ATTRIBUTE_NORETURN __attribute__((noreturn)) +#else +#define GDEF_ATTRIBUTE_NORETURN +#endif + +#ifdef GDEF_COMPILER_MSVC +#define GDEF_ATTRIBUTE_INLINE __inline +#else +#define GDEF_ATTRIBUTE_INLINE inline +#endif + +// MISC + +#define GDEF_DEBUG 0 +#if defined(_DEBUG) +#if _DEBUG +#undef GDEF_DEBUG +#define GDEF_DEBUG 1 +#endif +#endif + +#endif diff --git a/libs/gtkutil/clipboard.cpp b/libs/gtkutil/clipboard.cpp index 7d45bd1a..fd36f39e 100644 --- a/libs/gtkutil/clipboard.cpp +++ b/libs/gtkutil/clipboard.cpp @@ -21,6 +21,7 @@ #include "clipboard.h" +#include "globaldefs.h" #include "stream/memstream.h" #include "stream/textstream.h" @@ -28,7 +29,7 @@ /// \file /// \brief Platform-independent GTK clipboard support. /// \todo Using GDK_SELECTION_CLIPBOARD fails on win32, so we use the win32 API directly for now. -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS const char* c_clipboard_format = "RadiantClippings"; diff --git a/libs/gtkutil/glfont.cpp b/libs/gtkutil/glfont.cpp index e0d7f3ee..afe8546e 100644 --- a/libs/gtkutil/glfont.cpp +++ b/libs/gtkutil/glfont.cpp @@ -20,6 +20,7 @@ */ #include "glfont.h" +#include "globaldefs.h" #include "igl.h" // generic string printing with call lists @@ -50,7 +51,7 @@ virtual int getPixelHeight() const { } }; -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include #endif #include "debugging/debugging.h" diff --git a/libs/l_net/l_net.c b/libs/l_net/l_net.c index fa7b31f4..18727224 100644 --- a/libs/l_net/l_net.c +++ b/libs/l_net/l_net.c @@ -29,6 +29,7 @@ // Notes: //==================================================================== +#include "globaldefs.h" #include #include #include @@ -36,7 +37,7 @@ #include "l_net.h" #include "l_net_wins.h" -#ifdef _DEBUG +#if GDEF_DEBUG void WinPrint( const char *str, ... ){ va_list argptr; char text[4096]; @@ -72,7 +73,7 @@ void Net_SetAddressPort( address_t *address, int port ){ // Changes Globals: - //=========================================================================== int Net_AddressCompare( address_t *addr1, address_t *addr2 ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS return _stricmp( addr1->ip, addr2->ip ); #else return strcasecmp( addr1->ip, addr2->ip ); @@ -163,7 +164,7 @@ int Net_Receive( socket_t *sock, netmessage_t *msg ){ return msg->size - 4; } //end if //the message has not been completely read yet -#ifdef _DEBUG +#if GDEF_DEBUG printf( "++timo TODO: debug the Net_Receive on big size messages\n" ); #endif return 0; diff --git a/libs/math/vector.h b/libs/math/vector.h index 9ec5159f..9bb3ef51 100644 --- a/libs/math/vector.h +++ b/libs/math/vector.h @@ -26,8 +26,9 @@ /// \brief Vector data types and related operations. #include "generic/vector.h" +#include "globaldefs.h" -#if defined ( _MSC_VER ) +#if GDEF_COMPILER_MSVC inline int lrint( double flt ){ int i; @@ -45,7 +46,7 @@ inline __int64 llrint( double f ){ return static_cast<__int64>( f + 0.5 ); } -#elif defined( __FreeBSD__ ) +#elif GDEF_OS_BSD inline long lrint( double f ){ return static_cast( f + 0.5 ); @@ -55,7 +56,7 @@ inline long long llrint( double f ){ return static_cast( f + 0.5 ); } -#elif defined( __GNUC__ ) +#elif GDEF_COMPILER_GNU // lrint is part of ISO C99 #define _ISOC9X_SOURCE 1 diff --git a/libs/md5lib/md5lib.c b/libs/md5lib/md5lib.c index eb047824..897e524f 100644 --- a/libs/md5lib/md5lib.c +++ b/libs/md5lib/md5lib.c @@ -54,14 +54,10 @@ */ #include "md5lib.h" /* ydnar */ +#include "globaldefs.h" #include -/* ydnar: gtkradiant endian picking */ -#ifdef _SGI_SOURCE -#define __BIG_ENDIAN__ -#endif - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG #define ARCH_IS_BIG_ENDIAN 1 #else #define ARCH_IS_BIG_ENDIAN 0 @@ -69,11 +65,7 @@ /* ydnar: end */ #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ -#ifdef ARCH_IS_BIG_ENDIAN #define BYTE_ORDER ( ARCH_IS_BIG_ENDIAN ? 1 : -1 ) -#else -#define BYTE_ORDER 0 -#endif #define T_MASK ( ( md5_word_t ) ~0 ) #define T1 /* 0xd76aa478 */ ( T_MASK ^ 0x28955b87 ) diff --git a/libs/os/file.h b/libs/os/file.h index 140be78c..144627e6 100644 --- a/libs/os/file.h +++ b/libs/os/file.h @@ -22,10 +22,12 @@ #if !defined( INCLUDED_OS_FILE_H ) #define INCLUDED_OS_FILE_H +#include "globaldefs.h" + /// \file /// \brief OS file-system querying and manipulation. -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define S_ISDIR( mode ) ( mode & _S_IFDIR ) #include // _access() #define access( path, mode ) _access( path, mode ) diff --git a/libs/os/path.h b/libs/os/path.h index e3329a75..a3db167c 100644 --- a/libs/os/path.h +++ b/libs/os/path.h @@ -22,6 +22,8 @@ #if !defined ( INCLUDED_OS_PATH_H ) #define INCLUDED_OS_PATH_H +#include "globaldefs.h" + /// \file /// \brief OS file-system path comparison, decomposition and manipulation. /// @@ -33,7 +35,7 @@ #include "string/string.h" -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define OS_CASE_INSENSITIVE #endif @@ -85,10 +87,10 @@ inline bool path_equal_n( const char* path, const char* other, std::size_t n ){ /// \brief Returns true if \p path is a fully qualified file-system path. /// O(1) inline bool path_is_absolute( const char* path ){ -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS return path[0] == '/' || ( path[0] != '\0' && path[1] == ':' ); // local drive -#elif defined( POSIX ) +#elif GDEF_OS_POSIX return path[0] == '/'; #endif } diff --git a/libs/picomodel/lwo/lwio.c b/libs/picomodel/lwo/lwio.c index 824a693f..e825a340 100644 --- a/libs/picomodel/lwo/lwio.c +++ b/libs/picomodel/lwo/lwio.c @@ -10,6 +10,7 @@ #include "../picointernal.h" #include "lwo2.h" #include +#include "globaldefs.h" /* @@ -32,7 +33,7 @@ void set_flen( int i ) { flen = i; } int get_flen( void ) { return flen; } -#ifndef __BIG_ENDIAN__ +#if !GDEF_ARCH_ENDIAN_BIG /* ===================================================================== revbytes() diff --git a/libs/picomodel/lwo/lwo2.c b/libs/picomodel/lwo/lwo2.c index 5299d297..fd367e4f 100644 --- a/libs/picomodel/lwo/lwo2.c +++ b/libs/picomodel/lwo/lwo2.c @@ -9,9 +9,10 @@ #include "../picointernal.h" #include "lwo2.h" +#include "globaldefs.h" /* disable warnings */ -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning( disable:4018 ) /* signed/unsigned mismatch */ #endif diff --git a/libs/picomodel/lwo/lwo2.h b/libs/picomodel/lwo/lwo2.h index d055c13e..b1dc7470 100644 --- a/libs/picomodel/lwo/lwo2.h +++ b/libs/picomodel/lwo/lwo2.h @@ -10,6 +10,8 @@ #ifndef LWO2_H #define LWO2_H +#include "globaldefs.h" + /* chunk and subchunk IDs */ #define LWID_( a,b,c,d ) ( ( ( a ) << 24 ) | ( ( b ) << 16 ) | ( ( c ) << 8 ) | ( d ) ) @@ -642,7 +644,7 @@ int sgetVX( unsigned char **bp ); float sgetF4( unsigned char **bp ); char *sgetS0( unsigned char **bp ); -#ifndef __BIG_ENDIAN__ +#if !GDEF_ARCH_ENDIAN_BIG void revbytes( void *bp, int elsize, int elcount ); #else #define revbytes( b, s, c ) diff --git a/libs/picomodel/lwo/lwob.c b/libs/picomodel/lwo/lwob.c index e0256c09..459c6560 100644 --- a/libs/picomodel/lwo/lwob.c +++ b/libs/picomodel/lwo/lwob.c @@ -10,9 +10,10 @@ #include "../picointernal.h" #include "lwo2.h" +#include "globaldefs.h" /* disable warnings */ -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning( disable:4018 ) /* signed/unsigned mismatch */ #endif diff --git a/libs/picomodel/picointernal.c b/libs/picomodel/picointernal.c index e5e9238b..4e45fb6f 100644 --- a/libs/picomodel/picointernal.c +++ b/libs/picomodel/picointernal.c @@ -39,6 +39,7 @@ /* dependencies */ #include #include "picointernal.h" +#include "globaldefs.h" @@ -476,7 +477,7 @@ void _pico_copy_color( picoColor_t src, picoColor_t dest ){ dest[ 3 ] = src[ 3 ]; } -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG int _pico_big_long( int src ) { return src; } short _pico_big_short( short src ) { return src; } diff --git a/libs/picomodel/picointernal.h b/libs/picomodel/picointernal.h index 07c24cb5..f3935236 100644 --- a/libs/picomodel/picointernal.h +++ b/libs/picomodel/picointernal.h @@ -38,6 +38,8 @@ #ifndef PICOINTERNAL_H #define PICOINTERNAL_H +#include "globaldefs.h" + #ifdef __cplusplus extern "C" { @@ -56,7 +58,7 @@ extern "C" /* os dependent replacements */ -#if WIN32 || _WIN32 +#if GDEF_OS_WINDOWS #define _pico_stricmp stricmp #define _pico_strnicmp strnicmp #else diff --git a/libs/picomodel/pm_ms3d.c b/libs/picomodel/pm_ms3d.c index c0c3987f..378265f3 100644 --- a/libs/picomodel/pm_ms3d.c +++ b/libs/picomodel/pm_ms3d.c @@ -34,9 +34,10 @@ /* dependencies */ #include "picointernal.h" +#include "globaldefs.h" /* disable warnings */ -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning( disable:4100 ) /* unref param */ #endif diff --git a/libs/picomodel/pm_obj.c b/libs/picomodel/pm_obj.c index a97cf526..24f3ee8a 100644 --- a/libs/picomodel/pm_obj.c +++ b/libs/picomodel/pm_obj.c @@ -34,9 +34,10 @@ /* dependencies */ #include "picointernal.h" +#include "globaldefs.h" /* disable warnings */ -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma warning( disable:4100 ) /* unref param */ #endif diff --git a/libs/scenelib.h b/libs/scenelib.h index 29402065..7488186d 100644 --- a/libs/scenelib.h +++ b/libs/scenelib.h @@ -22,6 +22,7 @@ #if !defined ( INCLUDED_SCENELIB_H ) #define INCLUDED_SCENELIB_H +#include "globaldefs.h" #include "iscenegraph.h" #include "iselection.h" @@ -108,7 +109,7 @@ void initialise(){ } typedef MemberCaller, &NodeType::initialise> InitialiseCaller; TypeId getTypeId(){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( m_typeId != NODETYPEID_NONE, "node-type " << makeQuoted( Name() ) << " used before being initialised" ); #endif return m_typeId; @@ -443,7 +444,7 @@ void initialise(){ } typedef MemberCaller, &InstanceType::initialise> InitialiseCaller; TypeId getTypeId(){ -#if defined( _DEBUG ) +#if GDEF_DEBUG ASSERT_MESSAGE( m_typeId != INSTANCETYPEID_NONE, "instance-type " << makeQuoted( Name() ) << " used before being initialised" ); #endif return m_typeId; diff --git a/libs/splines/math_matrix.h b/libs/splines/math_matrix.h index 306b9bc9..b4427dcd 100644 --- a/libs/splines/math_matrix.h +++ b/libs/splines/math_matrix.h @@ -25,14 +25,6 @@ #include #include "math_vector.h" -#ifndef ID_INLINE -#ifdef _WIN32 -#define ID_INLINE __inline -#else -#define ID_INLINE inline -#endif -#endif - class quat_t; class angles_t; diff --git a/libs/splines/math_vector.h b/libs/splines/math_vector.h index dde07257..4fbe8d9d 100644 --- a/libs/splines/math_vector.h +++ b/libs/splines/math_vector.h @@ -22,7 +22,9 @@ #ifndef __MATH_VECTOR_H__ #define __MATH_VECTOR_H__ -#ifdef WIN32 +#include "globaldefs.h" + +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4244) #endif @@ -64,11 +66,7 @@ float Q_fabs( float f ); #ifndef ID_INLINE -#ifdef _WIN32 -#define ID_INLINE __inline -#else -#define ID_INLINE inline -#endif +#define ID_INLINE GDEF_ATTRIBUTE_INLINE #endif // if this is defined, vec3 will take four elements, which may allow @@ -98,7 +96,7 @@ static inline float idSqrt( float x ) { } B = x; -#ifdef __GNUC__ +#if GDEF_COMPILER_GNU asm ( "frsqrte %0,%1" : "=f" ( y0 ) : "f" ( B ) ); #else y0 = __frsqrte( B ); diff --git a/libs/splines/q_shared.h b/libs/splines/q_shared.h index 95c0cc5a..10a75625 100644 --- a/libs/splines/q_shared.h +++ b/libs/splines/q_shared.h @@ -22,6 +22,8 @@ #ifndef __Q_SHARED_H #define __Q_SHARED_H +#include "globaldefs.h" + // q_shared.h -- included first by ALL program modules. // these are the definitions that have no dependance on // central system services, and can be used by any part @@ -35,7 +37,7 @@ #define ALIGN_ON #define ALIGN_OFF -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4018) // signed/unsigned mismatch #pragma warning(disable : 4032) @@ -67,10 +69,10 @@ #include #include -#ifdef WIN32 // mac doesn't have malloc.h +#if GDEF_OS_WINDOWS // mac doesn't have malloc.h #include // for _alloca() #endif -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC //#pragma intrinsic( memset, memcpy ) @@ -78,7 +80,7 @@ // this is the define for determining if we have an asm version of a C function -#if ( defined _M_IX86 || defined __i386__ ) && !defined __sun__ && !defined __LCC__ +#if GDEF_ARCH_BITS_32 && !defined __sun__ && !defined __LCC__ #define id386 1 #else #define id386 0 @@ -90,7 +92,7 @@ //======================= WIN32 DEFINES ================================= -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define MAC_STATIC @@ -99,13 +101,13 @@ // buildstring will be incorporated into the version string #ifdef NDEBUG -#ifdef _M_IX86 +#if GDEF_ARCH_BITS_32 #define CPUSTRING "win-x86" #elif defined _M_ALPHA #define CPUSTRING "win-AXP" #endif #else -#ifdef _M_IX86 +#if GDEF_ARCH_BITS_32 #define CPUSTRING "win-x86-debug" #elif defined _M_ALPHA #define CPUSTRING "win-AXP-debug" @@ -119,13 +121,13 @@ //======================= MAC OS X SERVER DEFINES ===================== -#if defined( __MACH__ ) && defined( __APPLE__ ) +#if GDEF_OS_MACOS && defined( __MACH__ ) #define MAC_STATIC #ifdef __ppc__ #define CPUSTRING "MacOSXS-ppc" -#elif defined __i386__ +#elif GDEF_ARCH_BITS_32 #define CPUSTRING "MacOSXS-i386" #else #define CPUSTRING "MacOSXS-other" @@ -190,11 +192,11 @@ void Sys_PumpEvents( void ); // the mac compiler can't handle >32k of locals, so we // just waste space and make big arrays static... -#ifdef __linux__ +#if GDEF_OS_LINUX #define MAC_STATIC -#ifdef __i386__ +#if GDEF_ARCH_BITS_32 #define CPUSTRING "linux-i386" #elif defined __axp__ #define CPUSTRING "linux-alpha" diff --git a/libs/splines/util_str.cpp b/libs/splines/util_str.cpp index 2c5e4945..c64ca73b 100644 --- a/libs/splines/util_str.cpp +++ b/libs/splines/util_str.cpp @@ -27,7 +27,7 @@ #include #include -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data #pragma warning(disable : 4710) // function 'blah' not inlined #endif @@ -455,7 +455,7 @@ void idStr::snprintf strncpy( dst, buffer, size - 1 ); } -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4189) // local variable is initialized but not referenced #endif @@ -571,7 +571,7 @@ void TestStringClass a[1] = '1'; // a.data = "t1st", b.data = "test" } -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(default : 4189) // local variable is initialized but not referenced #pragma warning(disable : 4514) // unreferenced inline function has been removed #endif diff --git a/libs/splines/util_str.h b/libs/splines/util_str.h index 57f05b5a..02240ced 100644 --- a/libs/splines/util_str.h +++ b/libs/splines/util_str.h @@ -28,7 +28,7 @@ #include #include -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4710) // function 'blah' not inlined #endif diff --git a/libs/str.h b/libs/str.h index 47be309d..e7ef600e 100644 --- a/libs/str.h +++ b/libs/str.h @@ -31,6 +31,8 @@ #ifndef __STR__ #define __STR__ +#include "globaldefs.h" + // // class Str // loose replacement for CString from MFC @@ -44,7 +46,7 @@ #include -#ifdef _MSC_VER +#if GDEF_COMPILER_MSVC #define strcasecmp strcmpi #if _MSC_VER < 1400 #define vsnprintf std::vsnprintf @@ -67,7 +69,7 @@ inline char* Q_StrDup( const char* pStr ){ return strcpy( new char[strlen( pStr ) + 1], pStr ); } -#if !defined( WIN32 ) +#if !GDEF_OS_WINDOWS #define strcmpi strcasecmp #define stricmp strcasecmp #define strnicmp strncasecmp diff --git a/libs/stream/textstream.h b/libs/stream/textstream.h index 7f8be898..25f3d1ad 100644 --- a/libs/stream/textstream.h +++ b/libs/stream/textstream.h @@ -22,6 +22,8 @@ #if !defined( INCLUDED_STREAM_TEXTSTREAM_H ) #define INCLUDED_STREAM_TEXTSTREAM_H +#include "globaldefs.h" + /// \file /// \brief Text-output-formatting. @@ -48,7 +50,7 @@ inline char* write_unsigned_nonzero_decimal_backward( char* ptr, unsigned int de return ptr; } - #if defined ( _WIN64 ) || defined ( __LP64__ ) + #if GDEF_ARCH_BITS_64 inline char* write_size_t_nonzero_decimal_backward( char* ptr, size_t decimal ){ for (; decimal != 0; decimal /= 10 ) { @@ -78,7 +80,7 @@ inline char* write_unsigned_nonzero_decimal_backward( char* ptr, unsigned int de return ptr; } - #if defined ( _WIN64 ) || defined ( __LP64__ ) + #if GDEF_ARCH_BITS_64 inline char* write_size_t_nonzero_decimal_backward( char* ptr, size_t decimal, bool show_positive ){ ptr = write_size_t_nonzero_decimal_backward( ptr, decimal ); if ( show_positive ) { @@ -110,7 +112,7 @@ inline char* write_unsigned_decimal_backward( char* ptr, unsigned int decimal, b return ptr; } - #if defined ( _WIN64 ) || defined ( __LP64__ ) + #if GDEF_ARCH_BITS_64 inline char* write_size_t_decimal_backward( char* ptr, size_t decimal, bool show_positive ){ if ( decimal == 0 ) { *--ptr = '0'; @@ -125,7 +127,7 @@ inline char* write_size_t_decimal_backward( char* ptr, size_t decimal, bool show } -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define snprintf _snprintf #endif @@ -186,7 +188,7 @@ inline TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const return ostream; } -#if defined ( _WIN64 ) || defined ( __LP64__ ) +#if GDEF_ARCH_BITS_64 /// \brief Writes a size_t \p i to \p ostream in decimal form. template diff --git a/libs/string/pooledstring.cpp b/libs/string/pooledstring.cpp index 96cb298d..d4386331 100644 --- a/libs/string/pooledstring.cpp +++ b/libs/string/pooledstring.cpp @@ -1,8 +1,9 @@ #include "pooledstring.h" +#include "globaldefs.h" #include "generic/static.h" -#if defined( _DEBUG ) +#if GDEF_DEBUG namespace ExamplePooledString { @@ -21,4 +22,4 @@ struct Always } always; } -#endif \ No newline at end of file +#endif diff --git a/libs/string/string.h b/libs/string/string.h index c9ef2c4d..ff7dc453 100644 --- a/libs/string/string.h +++ b/libs/string/string.h @@ -22,6 +22,8 @@ #if !defined( INCLUDED_STRING_STRING_H ) #define INCLUDED_STRING_STRING_H +#include "globaldefs.h" + /// \file /// C-style null-terminated-character-array string library. @@ -81,7 +83,7 @@ inline bool string_greater( const char* string, const char* other ){ /// Returns 0 if \p string is lexicographically equal to \p other after converting both to lower-case. /// O(n) inline int string_compare_nocase( const char* string, const char* other ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS return _stricmp( string, other ); #else return strcasecmp( string, other ); @@ -94,7 +96,7 @@ inline int string_compare_nocase( const char* string, const char* other ){ /// Treats all ascii characters as lower-case during comparisons. /// O(n) inline int string_compare_nocase_n( const char* string, const char* other, std::size_t n ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS return _strnicmp( string, other, n ); #else return strncasecmp( string, other, n ); diff --git a/plugins/md3model/model.h b/plugins/md3model/model.h index ee760064..946ee198 100644 --- a/plugins/md3model/model.h +++ b/plugins/md3model/model.h @@ -22,6 +22,7 @@ #if !defined( INCLUDED_MODEL_H ) #define INCLUDED_MODEL_H +#include "globaldefs.h" #include "cullable.h" #include "renderable.h" #include "selectable.h" @@ -180,7 +181,7 @@ void render( RenderStateFlags state ) const { glEnd(); #endif -#if defined( _DEBUG ) +#if GDEF_DEBUG glBegin( GL_LINES ); for ( VertexBuffer::const_iterator i = m_vertices.begin(); i != m_vertices.end(); ++i ) diff --git a/plugins/model/model.cpp b/plugins/model/model.cpp index defa472a..aad851cf 100644 --- a/plugins/model/model.cpp +++ b/plugins/model/model.cpp @@ -20,6 +20,7 @@ */ #include "model.h" +#include "globaldefs.h" #include "picomodel.h" @@ -113,7 +114,7 @@ void render( RenderStateFlags state ) const { glVertexPointer( 3, GL_FLOAT, sizeof( ArbitraryMeshVertex ), &m_vertices.data()->vertex ); glDrawElements( GL_TRIANGLES, GLsizei( m_indices.size() ), RenderIndexTypeID, m_indices.data() ); -#if defined( _DEBUG ) +#if GDEF_DEBUG GLfloat modelview[16]; glGetFloatv( GL_MODELVIEW_MATRIX, modelview ); // I know this is slow as hell, but hey - we're in _DEBUG Matrix4 modelview_inv( diff --git a/plugins/shaders/shaders.cpp b/plugins/shaders/shaders.cpp index a7a3078d..656c1d84 100644 --- a/plugins/shaders/shaders.cpp +++ b/plugins/shaders/shaders.cpp @@ -35,6 +35,7 @@ // #include "shaders.h" +#include "globaldefs.h" #include #include @@ -1369,7 +1370,7 @@ void ParseShaderFile( Tokeniser& tokeniser, const char* filename ){ if ( result ) { // do we already have this shader? if ( !g_shaderDefinitions.insert( ShaderDefinitionMap::value_type( shaderTemplate->getName(), ShaderDefinition( shaderTemplate.get(), ShaderArguments(), filename ) ) ).second ) { - #ifdef _DEBUG + #if GDEF_DEBUG globalOutputStream() << "WARNING: shader " << shaderTemplate->getName() << " is already in memory, definition in " << filename << " ignored.\n"; #endif } diff --git a/plugins/textool/StdAfx.h b/plugins/textool/StdAfx.h index f884c53e..2ebd1b01 100644 --- a/plugins/textool/StdAfx.h +++ b/plugins/textool/StdAfx.h @@ -22,11 +22,13 @@ // stdafx.h // precompiled headers +#include "globaldefs.h" + // standard headers #include #include -#if !defined( WIN32 ) +#if !GDEF_OS_WINDOWS // Necessary for proper boolean type declaration #include "qertypes.h" diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index 8776ad3b..1cd50a31 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -42,6 +42,7 @@ // #include "vfs.h" +#include "globaldefs.h" #include #include @@ -64,7 +65,7 @@ ArchiveModules& FileSystemQ3API_getArchiveModules(); const int VFS_MAXDIRS = 64; -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define PATH_MAX 260 #endif diff --git a/radiant/autosave.cpp b/radiant/autosave.cpp index b9f9b824..8b3de4f7 100644 --- a/radiant/autosave.cpp +++ b/radiant/autosave.cpp @@ -21,6 +21,7 @@ #include #include "autosave.h" +#include "globaldefs.h" #include "os/file.h" #include "os/path.h" @@ -36,7 +37,7 @@ #include "preferences.h" -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define PATH_MAX 260 #endif diff --git a/radiant/brush_primit.cpp b/radiant/brush_primit.cpp index 066adfcd..2b11807e 100644 --- a/radiant/brush_primit.cpp +++ b/radiant/brush_primit.cpp @@ -20,6 +20,7 @@ */ #include "brush_primit.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -397,11 +398,11 @@ inline BasicVector3 vector3_inverse( const BasicVector3& self void BPMatMul( float A[2][3], float B[2][3], float C[2][3] ); // apply a rotation (degrees) void BPMatRotate( float A[2][3], float theta ); -#ifdef _DEBUG +#if GDEF_DEBUG void BPMatDump( float A[2][3] ); #endif -#ifdef _DEBUG +#if GDEF_DEBUG //#define DBG_BP #endif diff --git a/radiant/environment.cpp b/radiant/environment.cpp index 7b87bc9f..1c297f03 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -20,6 +20,7 @@ */ #include "environment.h" +#include "globaldefs.h" #include "stream/textstream.h" #include "string/string.h" @@ -127,9 +128,9 @@ void gamedetect(){ // TODO add more games to this // try to detect Nexuiz installs -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz.exe", buf, p - buf ) ) -#elif defined( __APPLE__ ) +#elif GDEF_OS_MACOS if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "Nexuiz.app/Contents/Info.plist", buf, p - buf ) ) #else if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz-linux-glx.sh", buf, p - buf ) ) @@ -179,7 +180,7 @@ bool portable_app_setup(){ return false; } -#if defined( POSIX ) +#if GDEF_OS_POSIX #include #include @@ -188,7 +189,7 @@ bool portable_app_setup(){ #include const char* LINK_NAME = -#if defined ( __linux__ ) +#if GDEF_OS_LINUX "/proc/self/exe" #else // FreeBSD and OSX "/proc/curproc/file" @@ -252,7 +253,7 @@ void environment_init( int argc, char const* argv[] ){ gamedetect(); } -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS #include diff --git a/radiant/error.cpp b/radiant/error.cpp index fda7f79f..50a08964 100644 --- a/radiant/error.cpp +++ b/radiant/error.cpp @@ -20,6 +20,7 @@ */ #include "error.h" +#include "globaldefs.h" #include "debugging/debugging.h" #include "igl.h" @@ -29,7 +30,7 @@ #include "preferences.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define UNICODE #include #else @@ -63,7 +64,7 @@ void Error( const char *error, ... ){ strcat( text, "\n" ); -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( GetLastError() != 0 ) { LPVOID lpMsgBuf; FormatMessage( diff --git a/radiant/groupdialog.cpp b/radiant/groupdialog.cpp index eae85380..1eeb35b2 100644 --- a/radiant/groupdialog.cpp +++ b/radiant/groupdialog.cpp @@ -27,6 +27,7 @@ // #include "groupdialog.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -101,7 +102,7 @@ void GroupDlg::Create( ui::Window parent ){ m_window = window; -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( g_multimon_globals.m_bStartOnPrimMon ) { WindowPosition pos( m_position_tracker.getPosition() ); PositionWindowOnPrimaryScreen( pos ); diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 3d65f8a6..278edab1 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -35,6 +35,7 @@ // #include "gtkdlgs.h" +#include "globaldefs.h" #include @@ -822,7 +823,7 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos ){ // trying to show later text_editor.show(); -#ifdef WIN32 +#if GDEF_OS_WINDOWS ui::process(); #endif @@ -837,7 +838,7 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos ){ gtk_text_buffer_place_cursor( text_buffer, &text_iter ); } -#ifdef WIN32 +#if GDEF_OS_WINDOWS gtk_widget_queue_draw( text_widget ); #endif @@ -1030,11 +1031,11 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif -#ifdef WIN32 +#if GDEF_OS_WINDOWS // use the file associations to open files instead of builtin Gtk editor bool g_TextEditor_useWin32Editor = true; #else @@ -1044,7 +1045,7 @@ CopiedString g_TextEditor_editorCommand( "" ); #endif void DoTextEditor( const char* filename, int cursorpos ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( g_TextEditor_useWin32Editor ) { globalOutputStream() << "opening file '" << filename << "' (line " << cursorpos << " info ignored)\n"; ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "open", filename, 0, 0, SW_SHOW ); diff --git a/radiant/gtkdlgs.h b/radiant/gtkdlgs.h index 05f8b8b9..0dad793a 100644 --- a/radiant/gtkdlgs.h +++ b/radiant/gtkdlgs.h @@ -31,6 +31,7 @@ #if !defined( INCLUDED_GTKDLGS_H ) #define INCLUDED_GTKDLGS_H +#include "globaldefs.h" #include "qerplugin.h" #include "string/string.h" @@ -47,7 +48,7 @@ void DoSides( int type, int axis ); void DoAbout(); -#ifdef WIN32 +#if GDEF_OS_WINDOWS extern bool g_TextEditor_useWin32Editor; #else #include "string/stringfwd.h" diff --git a/radiant/main.cpp b/radiant/main.cpp index d80fd0b4..4fa42d27 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -62,6 +62,7 @@ */ #include "main.h" +#include "globaldefs.h" #include "version.h" @@ -89,7 +90,7 @@ #include "referencecache.h" #include "stacktrace.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif @@ -213,12 +214,12 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar } } -#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER ) +#if GDEF_COMPILER_MSVC && GDEF_DEBUG #include "crtdbg.h" #endif void crt_init(){ -#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER ) +#if GDEF_COMPILER_MSVC && GDEF_DEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif } @@ -301,7 +302,7 @@ bool handleMessage(){ globalErrorStream() << m_buffer.c_str(); if ( !m_lock.locked() ) { ScopedLock lock( m_lock ); -#if defined _DEBUG +#if GDEF_DEBUG m_buffer << "Break into the debugger?\n"; bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO; m_buffer.clear(); @@ -367,7 +368,7 @@ bool check_version(){ // make something idiot proof and someone will make better idiots, this may be overkill // let's leave it disabled in debug mode in any case // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=431 -#ifndef _DEBUG +#if !GDEF_DEBUG #define CHECK_VERSION #endif #ifdef CHECK_VERSION @@ -421,7 +422,7 @@ void create_global_pid(){ } // in debug, never prompt to clean registry, turn console logging auto after a failed start -#if !defined( _DEBUG ) +#if !GDEF_DEBUG StringOutputStream msg( 256 ); msg << "Radiant failed to start properly the last time it was run.\n" "The failure may be related to current global preferences.\n" @@ -480,7 +481,7 @@ void create_local_pid(){ } // in debug, never prompt to clean registry, turn console logging auto after a failed start -#if !defined( _DEBUG ) +#if !GDEF_DEBUG StringOutputStream msg; msg << "Radiant failed to start properly the last time it was run.\n" "The failure may be caused by current preferences.\n" @@ -539,7 +540,7 @@ int main( int argc, char* argv[] ){ streams_init(); -#ifdef WIN32 +#if GDEF_OS_WINDOWS HMODULE lib; lib = LoadLibrary( "dwmapi.dll" ); if ( lib != 0 ) { diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index b54ff827..5868e288 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -26,6 +26,7 @@ // #include "mainframe.h" +#include "globaldefs.h" #include @@ -180,7 +181,7 @@ void VFS_Destroy(){ // Home Paths -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}}; @@ -197,7 +198,7 @@ void HomePaths_Realise(){ if ( !string_empty( prefix ) ) { StringOutputStream path( 256 ); -#if defined( __APPLE__ ) +#if GDEF_OS_MACOS path.clear(); path << DirectoryCleaned( g_get_home_dir() ) << "Library/Application Support" << ( prefix + 1 ) << "/"; if ( file_is_directory( path.c_str() ) ) { @@ -208,7 +209,7 @@ void HomePaths_Realise(){ path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/"; #endif -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS TCHAR mydocsdir[MAX_PATH + 1]; wchar_t *mydocsdirw; HMODULE shfolder = LoadLibrary( "shfolder.dll" ); @@ -247,7 +248,7 @@ void HomePaths_Realise(){ } #endif -#if defined( POSIX ) +#if GDEF_OS_POSIX path.clear(); path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/"; g_qeglobals.m_userEnginePath = path.c_str(); @@ -539,11 +540,11 @@ void operator()( const char* name ) const { const char* const c_library_extension = #if defined( CMAKE_SHARED_MODULE_SUFFIX ) CMAKE_SHARED_MODULE_SUFFIX -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS "dll" -#elif defined ( __APPLE__ ) +#elif GDEF_OS_MACOS "dylib" -#elif defined( __linux__ ) || defined ( __FreeBSD__ ) +#elif GDEF_OS_LINUX || GDEF_OS_BSD "so" #endif ; @@ -2602,7 +2603,7 @@ void MainFrame::CreateContexts(){ #endif } -#ifdef _DEBUG +#if GDEF_DEBUG //#define DBG_SLEEP #endif @@ -2711,7 +2712,7 @@ void MainFrame::Create(){ gtk_window_set_transient_for( splash_screen, window ); -#if !defined( WIN32 ) +#if !GDEF_OS_WINDOWS { GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" ); if ( pixbuf != 0 ) { @@ -2767,7 +2768,7 @@ void MainFrame::Create(){ g_page_console = GroupDialog_addPage( "Console", Console_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Console" ) ); } -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( g_multimon_globals.m_bStartOnPrimMon ) { PositionWindowOnPrimaryScreen( g_layout_globals.m_position ); window_set_position( window, g_layout_globals.m_position ); @@ -3107,7 +3108,7 @@ void GlobalGL_sharedContextCreated(){ GlobalShaderCache().realise(); Textures_Realise(); -#ifdef WIN32 +#if GDEF_OS_WINDOWS /* win32 is dodgy here, just use courier new then */ g_font = glfont_create( "arial 9" ); #else @@ -3313,11 +3314,11 @@ void MainFrame_Construct(){ { const char* ENGINEPATH_ATTRIBUTE = -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS "enginepath_win32" -#elif defined( __APPLE__ ) +#elif GDEF_OS_MACOS "enginepath_macos" -#elif defined( __linux__ ) || defined ( __FreeBSD__ ) +#elif GDEF_OS_LINUX || GDEF_OS_BSD "enginepath_linux" #else #error "unknown platform" diff --git a/radiant/multimon.h b/radiant/multimon.h index a81220e7..c51bb9d0 100644 --- a/radiant/multimon.h +++ b/radiant/multimon.h @@ -22,6 +22,8 @@ #if !defined( INCLUDED_MULTIMON_H ) #define INCLUDED_MULTIMON_H +#include "globaldefs.h" + struct WindowPosition; void PositionWindowOnPrimaryScreen( WindowPosition& position ); @@ -37,7 +39,7 @@ struct multimon_globals_t extern multimon_globals_t g_multimon_globals; -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS void MultiMon_Construct(); void MultiMon_Destroy(); #else diff --git a/radiant/patch.h b/radiant/patch.h index a1f1d272..96c9b76e 100644 --- a/radiant/patch.h +++ b/radiant/patch.h @@ -30,7 +30,7 @@ /// The surface is recursively tesselated until the angle between each triangle /// edge is smaller than a specified tolerance. - +#include "globaldefs.h" #include "nameable.h" #include "ifilter.h" #include "imap.h" @@ -317,7 +317,7 @@ void render( RenderStateFlags state ) const { } } -#if defined( _DEBUG ) +#if GDEF_DEBUG RenderNormals(); #endif } diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 523408eb..d67bd40c 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -26,6 +26,7 @@ // #include "preferences.h" +#include "globaldefs.h" #include #include "environment.h" @@ -57,7 +58,7 @@ void Global_constructPreferences( PreferencesPage& page ){ } void Interface_constructPreferences( PreferencesPage& page ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS page.appendCheckBox( "", "Default Text Editor", g_TextEditor_useWin32Editor ); #else { @@ -949,7 +950,7 @@ typedef FreeCaller1 GameMode void RegisterPreferences( PreferenceSystem& preferences ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useWin32Editor ), BoolExportStringCaller( g_TextEditor_useWin32Editor ) ); #else preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useCustomEditor ), BoolExportStringCaller( g_TextEditor_useCustomEditor ) ); diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 7d685bae..b2b61791 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -33,6 +33,7 @@ // #include "qe3.h" +#include "globaldefs.h" #include @@ -66,7 +67,7 @@ QEGlobals_t g_qeglobals; -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define PATH_MAX 260 #endif @@ -281,10 +282,10 @@ void RunBSP( const char* name ){ strcat( junkpath, "junk.txt" ); char batpath[PATH_MAX]; -#if defined( POSIX ) +#if GDEF_OS_POSIX strcpy( batpath, SettingsPath_get() ); strcat( batpath, "qe3bsp.sh" ); -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS strcpy( batpath, SettingsPath_get() ); strcat( batpath, "qe3bsp.bat" ); #else @@ -294,7 +295,7 @@ void RunBSP( const char* name ){ { TextFileOutputStream batchFile( batpath ); if ( !batchFile.failed() ) { -#if defined ( POSIX ) +#if GDEF_OS_POSIX batchFile << "#!/bin/sh \n\n"; #endif BatchCommandListener listener( batchFile, junkpath ); @@ -303,7 +304,7 @@ void RunBSP( const char* name ){ } } if ( written ) { -#if defined ( POSIX ) +#if GDEF_OS_POSIX chmod( batpath, 0744 ); #endif globalOutputStream() << "Writing the compile script to '" << batpath << "'\n"; diff --git a/radiant/qgl.cpp b/radiant/qgl.cpp index a352b8d0..d64b7a5f 100644 --- a/radiant/qgl.cpp +++ b/radiant/qgl.cpp @@ -21,6 +21,7 @@ #include "qgl.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -28,18 +29,18 @@ #include #include -#if defined( _WIN32 ) +#if GDEF_OS_WINDOWS #define WINGDIAPI __declspec( dllimport ) #define APIENTRY __stdcall #endif -#if defined( __APPLE__ ) && !defined( XWINDOWS ) +#if GDEF_OS_MACOS && !defined( XWINDOWS ) #include #else #include #endif -#if defined( _WIN32 ) +#if GDEF_OS_WINDOWS #undef WINGDIAPI #undef APIENTRY #endif @@ -49,7 +50,7 @@ -#if defined( _WIN32 ) +#if GDEF_OS_WINDOWS #include @@ -64,7 +65,7 @@ Bool ( *qglXQueryExtension )( Display *dpy, int *errorb, int *event ); void* ( *qglXGetProcAddressARB )( const GLubyte * procName ); typedef void* ( *glXGetProcAddressARBProc )( const GLubyte *procName ); -#elif defined(__APPLE__) +#elif GDEF_OS_MACOS #include #include #include @@ -76,12 +77,12 @@ typedef void* ( *glXGetProcAddressARBProc )( const GLubyte *procName ); void QGL_Shutdown( OpenGLBinding& table ){ globalOutputStream() << "Shutting down OpenGL module..."; -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS qwglGetProcAddress = 0; #elif defined( XWINDOWS ) qglXQueryExtension = glXQueryExtension; qglXGetProcAddressARB = 0; -#elif defined(__APPLE__) +#elif GDEF_OS_MACOS #else #error "unsupported platform" #endif @@ -138,7 +139,7 @@ bool QGL_ExtensionSupported( const char* extension ){ } extensions = GlobalOpenGL().m_glGetString( GL_EXTENSIONS ); -#ifndef __APPLE__ +#if !GDEF_OS_MACOS if ( !extensions ) { return false; } @@ -179,7 +180,7 @@ QGLFunctionPointer QGL_getExtensionFunc( const char* symbol ){ { return (QGLFunctionPointer) qglXGetProcAddressARB( reinterpret_cast( symbol ) ); } -#elif defined(__APPLE__) +#elif GDEF_OS_MACOS // Prepend a '_' for the Unix C symbol mangling convention char *symbolName = (char *) malloc(strlen(symbol) + 2); strcpy(symbolName + 1, symbol); @@ -188,7 +189,7 @@ QGLFunctionPointer QGL_getExtensionFunc( const char* symbol ){ if (NSIsSymbolNameDefined(symbolName)) nssymbol = NSLookupAndBindSymbol(symbolName); free(symbolName); return nssymbol ? reinterpret_cast(NSAddressOfSymbol(nssymbol)) : reinterpret_cast(glInvalidFunction); -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS ASSERT_NOTNULL( qwglGetProcAddress ); return (QGLFunctionPointer) qwglGetProcAddress( symbol ); #else @@ -550,14 +551,14 @@ void QGL_clear( OpenGLBinding& table ){ int QGL_Init( OpenGLBinding& table ){ QGL_clear( table ); -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS qwglGetProcAddress = wglGetProcAddress; #elif defined( XWINDOWS ) qglXGetProcAddressARB = (glXGetProcAddressARBProc)dlsym( RTLD_DEFAULT, "glXGetProcAddressARB" ); if ( ( qglXQueryExtension == 0 ) || ( qglXQueryExtension(XOpenDisplay(nullptr), 0, 0) != True ) ) { return 0; } -#elif defined (__APPLE__) +#elif GDEF_OS_MACOS #else #error "unsupported platform" #endif diff --git a/radiant/referencecache.cpp b/radiant/referencecache.cpp index ee3ab806..8cd9eb20 100644 --- a/radiant/referencecache.cpp +++ b/radiant/referencecache.cpp @@ -20,6 +20,7 @@ */ #include "referencecache.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -206,7 +207,7 @@ NodeSmartReference ModelResource_load( ModelLoader* loader, const char* name ){ inline hash_t path_hash( const char* path, hash_t previous = 0 ){ -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS return string_hash_nocase( path, previous ); #else // UNIX return string_hash( path, previous ); diff --git a/radiant/selection.cpp b/radiant/selection.cpp index e2631917..e04fd91c 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -20,6 +20,7 @@ */ #include "selection.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -156,7 +157,7 @@ inline float angle_between( const Vector3& a, const Vector3& b ){ } -#if defined( _DEBUG ) +#if GDEF_DEBUG class test_quat { public: @@ -466,7 +467,7 @@ void add_one(){ } }; -#if defined( _DEBUG ) +#if GDEF_DEBUG #define DEBUG_SELECTION #endif diff --git a/radiant/server.cpp b/radiant/server.cpp index 21d95c20..fde6f86d 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -20,6 +20,7 @@ */ #include "server.h" +#include "globaldefs.h" #include "debugging/debugging.h" #include "warnings.h" @@ -89,7 +90,7 @@ void foreachModule( const char* type, int version, const Visitor& visitor ){ }; -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #include @@ -140,7 +141,7 @@ FunctionPointer findSymbol( const char* symbol ){ } }; -#elif defined( POSIX ) +#elif GDEF_OS_POSIX #include diff --git a/radiant/sockets.cpp b/radiant/sockets.cpp index d95663d1..d2a27d7e 100644 --- a/radiant/sockets.cpp +++ b/radiant/sockets.cpp @@ -1,25 +1,25 @@ - #include "sockets.h" +#include "globaldefs.h" -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #include -#elif defined ( POSIX ) +#elif GDEF_OS_POSIX #include const int SOCKET_ERROR = -1; #else #error "unsupported platform" #endif -#ifdef __APPLE__ +#if GDEF_OS_MACOS #include #endif int Net_Wait( socket_t *sock, long sec, long usec ){ // used for select() -#ifdef WIN32 +#if GDEF_OS_WINDOWS TIMEVAL tout = { sec, usec }; #endif -#if defined ( POSIX ) +#if GDEF_OS_POSIX timeval tout; tout.tv_sec = sec; tout.tv_usec = usec; diff --git a/radiant/stacktrace.cpp b/radiant/stacktrace.cpp index 51ef5038..5e638574 100644 --- a/radiant/stacktrace.cpp +++ b/radiant/stacktrace.cpp @@ -20,11 +20,13 @@ */ #include "stacktrace.h" +#include "globaldefs.h" + #include "stream/textstream.h" #include "environment.h" -#ifdef __linux__ +#if GDEF_OS_LINUX #include void write_stack_trace( TextOutputStream& outputStream ){ @@ -48,7 +50,7 @@ void write_stack_trace( TextOutputStream& outputStream ){ free( symbol_names ); } } -#elif defined ( WIN32 ) && defined ( _MSC_VER ) +#elif GDEF_COMPILER_MSVC #include "windows.h" #include "winnt.h" @@ -288,7 +290,7 @@ void write_stack_trace( TextOutputStream& outputStream ){ } } -#elif defined ( WIN32 ) +#elif GDEF_OS_WINDOWS void write_stack_trace( TextOutputStream& outputStream ){ outputStream << "\nStacktrace is disabled on this compiler\n"; } diff --git a/radiant/timer.cpp b/radiant/timer.cpp index 1c55d930..8d10b82b 100644 --- a/radiant/timer.cpp +++ b/radiant/timer.cpp @@ -20,9 +20,10 @@ */ #include "timer.h" +#include "globaldefs.h" -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #include @@ -62,7 +63,7 @@ public: -#elif defined( POSIX ) +#elif GDEF_OS_POSIX #include #include "sys/time.h" diff --git a/radiant/treemodel.cpp b/radiant/treemodel.cpp index d5a7a54a..97d02265 100644 --- a/radiant/treemodel.cpp +++ b/radiant/treemodel.cpp @@ -20,6 +20,7 @@ */ #include "treemodel.h" +#include "globaldefs.h" #include "debugging/debugging.h" @@ -465,7 +466,7 @@ static void graph_tree_model_tree_model_init( GtkTreeModelIface *iface ){ } static gboolean graph_tree_model_row_draggable( GtkTreeDragSource *drag_source, GtkTreePath *path ){ -#ifdef _DEBUG +#if GDEF_DEBUG gint depth = gtk_tree_path_get_depth( path ); #endif return gtk_tree_path_get_depth( path ) > 1; diff --git a/radiant/url.cpp b/radiant/url.cpp index e92d1ba1..425948f8 100644 --- a/radiant/url.cpp +++ b/radiant/url.cpp @@ -20,11 +20,12 @@ */ #include "url.h" +#include "globaldefs.h" #include "mainframe.h" #include "gtkutil/messagebox.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #include @@ -33,7 +34,7 @@ bool open_url( const char* url ){ } #endif -#if defined( __linux__ ) || defined( __FreeBSD__ ) +#if GDEF_OS_LINUX || GDEF_OS_BSD #include bool open_url( const char* url ){ char command[2 * PATH_MAX]; @@ -43,7 +44,7 @@ bool open_url( const char* url ){ } #endif -#ifdef __APPLE__ +#if GDEF_OS_MACOS #include bool open_url( const char* url ){ char command[2 * PATH_MAX]; diff --git a/radiant/view.h b/radiant/view.h index 7e8cdf95..ad322d5d 100644 --- a/radiant/view.h +++ b/radiant/view.h @@ -22,11 +22,12 @@ #if !defined( INCLUDED_VIEW_H ) #define INCLUDED_VIEW_H +#include "globaldefs.h" #include "cullable.h" #include "math/frustum.h" -#if defined( _DEBUG ) +#if GDEF_DEBUG #define DEBUG_CULLING #endif diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index cddc0a5c..ada5eb43 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -34,6 +34,7 @@ // monitoring window for running BSP processes (and possibly various other stuff) #include "watchbsp.h" +#include "globaldefs.h" #include @@ -343,7 +344,7 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){ } if ( data->recurse == data->stop_depth ) { message_flush( data ); -#ifdef _DEBUG +#if GDEF_DEBUG globalOutputStream() << "Received error msg .. shutting down..\n"; #endif GetWatchBSP()->EndMonitoringLoop(); @@ -494,7 +495,7 @@ void CWatchBSP::Reset(){ } bool CWatchBSP::SetupListening(){ -#ifdef _DEBUG +#if GDEF_DEBUG if ( m_pListenSocket ) { globalOutputStream() << "ERROR: m_pListenSocket != NULL in CWatchBSP::SetupListening\n"; return false; @@ -545,13 +546,13 @@ void CWatchBSP::DoEBeginStep(){ } -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS const char *ENGINE_ATTRIBUTE = "engine_win32"; const char *MP_ENGINE_ATTRIBUTE = "mp_engine_win32"; -#elif defined( __linux__ ) || defined ( __FreeBSD__ ) +#elif GDEF_OS_LINUX || GDEF_OS_BSD const char *ENGINE_ATTRIBUTE = "engine_linux"; const char *MP_ENGINE_ATTRIBUTE = "mp_engine_linux"; -#elif defined( __APPLE__ ) +#elif GDEF_OS_MACOS const char *ENGINE_ATTRIBUTE = "engine_macos"; const char *MP_ENGINE_ATTRIBUTE = "mp_engine_macos"; #else @@ -622,7 +623,7 @@ void CWatchBSP::RoutineProcessing(){ #endif return; } -#ifdef _DEBUG +#if GDEF_DEBUG // some debug checks if ( !m_pListenSocket ) { globalErrorStream() << "ERROR: m_pListenSocket == NULL in CWatchBSP::RoutineProcessing EBeginStep state\n"; @@ -642,7 +643,7 @@ void CWatchBSP::RoutineProcessing(){ break; case EWatching: { -#ifdef _DEBUG +#if GDEF_DEBUG // some debug checks if ( !m_pInSocket ) { globalErrorStream() << "ERROR: m_pInSocket == NULL in CWatchBSP::RoutineProcessing EWatching state\n"; diff --git a/tools/quake2/common/cmdlib.c b/tools/quake2/common/cmdlib.c index db6e2418..a2eaaf15 100644 --- a/tools/quake2/common/cmdlib.c +++ b/tools/quake2/common/cmdlib.c @@ -22,17 +22,19 @@ // Nurail: Swiped from quake3/common #include "cmdlib.h" +#include "globaldefs.h" + #include "mathlib.h" #include "inout.h" #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #endif -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #include #endif @@ -93,7 +95,7 @@ char archivedir[1024]; #define MAX_EX_ARGC 1024 int ex_argc; char *ex_argv[MAX_EX_ARGC]; -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void ExpandWildcards( int *argc, char ***argv ){ struct _finddata_t fileinfo; @@ -328,7 +330,7 @@ double I_FloatTime( void ){ void Q_getwd( char *out ){ int i = 0; -#ifdef WIN32 +#if GDEF_OS_WINDOWS _getcwd( out, 256 ); strcat( out, "\\" ); #else @@ -347,7 +349,7 @@ void Q_getwd( char *out ){ void Q_mkdir( const char *path ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( _mkdir( path ) != -1 ) { return; } @@ -952,11 +954,7 @@ int ParseNum( const char *str ){ ============================================================================ */ -#ifdef _SGI_SOURCE -#define __BIG_ENDIAN__ -#endif - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG short LittleShort( short l ){ byte b1,b2; @@ -1128,7 +1126,7 @@ void CreatePath( const char *path ){ char c; char dir[1024]; -#ifdef WIN32 +#if GDEF_OS_WINDOWS int olddrive = -1; if ( path[1] == ':' ) { @@ -1151,7 +1149,7 @@ void CreatePath( const char *path ){ } } -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( olddrive != -1 ) { _chdrive( olddrive ); } @@ -1177,10 +1175,10 @@ void QCopyFile( const char *from, const char *to ){ } void Sys_Sleep( int n ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS Sleep( n ); #endif -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS usleep( n * 1000 ); #endif } diff --git a/tools/quake2/common/cmdlib.h b/tools/quake2/common/cmdlib.h index 2955d53f..25860c77 100644 --- a/tools/quake2/common/cmdlib.h +++ b/tools/quake2/common/cmdlib.h @@ -24,6 +24,8 @@ #ifndef __CMDLIB__ #define __CMDLIB__ +#include "globaldefs.h" + #include #include #include @@ -32,7 +34,7 @@ #include #include -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float @@ -40,7 +42,7 @@ #endif #endif -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #pragma intrinsic( memset, memcpy ) #endif diff --git a/tools/quake2/common/inout.c b/tools/quake2/common/inout.c index 30ae39df..165390de 100644 --- a/tools/quake2/common/inout.c +++ b/tools/quake2/common/inout.c @@ -26,6 +26,7 @@ // deal with in/out tasks, for either stdin/stdout or network/XML stream // +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "polylib.h" @@ -33,7 +34,7 @@ #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #endif @@ -42,7 +43,7 @@ #include "l_net/l_net.h" #include "libxml/tree.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS HWND hwndOut = NULL; qboolean lookedForServer = false; UINT wm_BroadcastCommand = -1; diff --git a/tools/quake2/common/inout.h b/tools/quake2/common/inout.h index be0bd9a4..80bf1527 100644 --- a/tools/quake2/common/inout.h +++ b/tools/quake2/common/inout.h @@ -22,6 +22,7 @@ #ifndef __INOUT__ #define __INOUT__ +#include "globaldefs.h" // inout is the only stuff relying on xml, include the headers there #include "libxml/tree.h" #include "mathlib.h" @@ -52,7 +53,7 @@ void Sys_Printf( const char *text, ... ); void Sys_FPrintf( int flag, const char *text, ... ); void Error( const char *error, ... ); -#ifdef _DEBUG +#if GDEF_DEBUG #define DBG_XML 1 #endif diff --git a/tools/quake2/common/path_init.c b/tools/quake2/common/path_init.c index 5d729f24..71687a03 100644 --- a/tools/quake2/common/path_init.c +++ b/tools/quake2/common/path_init.c @@ -23,12 +23,9 @@ */ +#include "globaldefs.h" - -/* marker */ -#define PATH_INIT_C - -#if defined( __linux__ ) || defined( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define Q_UNIX #endif diff --git a/tools/quake2/common/qfiles.h b/tools/quake2/common/qfiles.h index d2b6f106..39b646af 100644 --- a/tools/quake2/common/qfiles.h +++ b/tools/quake2/common/qfiles.h @@ -32,7 +32,8 @@ ======================================================================== */ -#ifdef WIN32 +#include "globaldefs.h" +#if GDEF_COMPILER_MSVC #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/common/threads.c b/tools/quake2/common/threads.c index 0b5f4ece..f45e1855 100644 --- a/tools/quake2/common/threads.c +++ b/tools/quake2/common/threads.c @@ -19,7 +19,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef WIN32 +#include "globaldefs.h" + +#if !GDEF_OS_WINDOWS // The below define is necessary to use // pthreads extensions like pthread_mutexattr_settype #define _GNU_SOURCE @@ -106,7 +108,7 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( =================================================================== */ -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define USED @@ -415,7 +417,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){ ======================================================================= */ -#if defined( __linux__ ) || defined( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define USED // Setting default Threads to 1 diff --git a/tools/quake2/extra/bsp/qrad3/qrad.h b/tools/quake2/extra/bsp/qrad3/qrad.h index 67025460..5311e8eb 100644 --- a/tools/quake2/extra/bsp/qrad3/qrad.h +++ b/tools/quake2/extra/bsp/qrad3/qrad.h @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "bspfile.h" @@ -27,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "threads.h" #include "lbmlib.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif diff --git a/tools/quake2/extra/common/cmdlib.c b/tools/quake2/extra/common/cmdlib.c index 60f615a0..79269079 100644 --- a/tools/quake2/extra/common/cmdlib.c +++ b/tools/quake2/extra/common/cmdlib.c @@ -23,10 +23,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // cmdlib.c #include "cmdlib.h" +#include "globaldefs.h" + #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif @@ -58,7 +60,7 @@ Mimic unix command line expansion #define MAX_EX_ARGC 1024 int ex_argc; char *ex_argv[MAX_EX_ARGC]; -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void ExpandWildcards (int *argc, char ***argv) { @@ -305,7 +307,7 @@ double I_FloatTime (void) void Q_getwd (char *out) { -#ifdef WIN32 +#if GDEF_OS_WINDOWS _getcwd (out, 256); strcat (out, "\\"); #else @@ -317,7 +319,7 @@ void Q_getwd (char *out) void Q_mkdir (char *path) { -#ifdef WIN32 +#if GDEF_OS_WINDOWS if (_mkdir (path) != -1) return; #else @@ -830,11 +832,7 @@ int ParseNum (char *str) ============================================================================ */ -#ifdef _SGI_SOURCE -#define __BIG_ENDIAN__ -#endif - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG short LittleShort (short l) { diff --git a/tools/quake2/extra/common/cmdlib.h b/tools/quake2/extra/common/cmdlib.h index 0045a09d..0821ce51 100644 --- a/tools/quake2/extra/common/cmdlib.h +++ b/tools/quake2/extra/common/cmdlib.h @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __CMDLIB__ #define __CMDLIB__ -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4244) // MIPS #pragma warning(disable : 4136) // X86 #pragma warning(disable : 4051) // ALPHA diff --git a/tools/quake2/extra/common/threads.c b/tools/quake2/extra/common/threads.c index 25a87c78..24dc5561 100644 --- a/tools/quake2/extra/common/threads.c +++ b/tools/quake2/extra/common/threads.c @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cmdlib.h" #include "threads.h" +#include "globaldefs.h" #define MAX_THREADS 64 @@ -99,7 +100,7 @@ WIN32 =================================================================== */ -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define USED diff --git a/tools/quake2/extra/qdata/qdata.c b/tools/quake2/extra/qdata/qdata.c index 2f93b728..16c65c71 100644 --- a/tools/quake2/extra/qdata/qdata.c +++ b/tools/quake2/extra/qdata/qdata.c @@ -211,7 +211,7 @@ PackDirectory_r =============== */ -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void PackDirectory_r (char *dir) { diff --git a/tools/quake2/extra/qe4/cmdlib.c b/tools/quake2/extra/qe4/cmdlib.c index 87565490..aebd6fb4 100644 --- a/tools/quake2/extra/qe4/cmdlib.c +++ b/tools/quake2/extra/qe4/cmdlib.c @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // cmdlib.c #include "cmdlib.h" +#include "globaldefs.h" #define PATHSEPERATOR '/' @@ -567,11 +568,7 @@ int ParseNum (char *str) ============================================================================ */ -#ifdef _SGI_SOURCE -#define __BIG_ENDIAN__ -#endif - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG short LittleShort (short l) { diff --git a/tools/quake2/extra/qe4/mru.c b/tools/quake2/extra/qe4/mru.c index 84a5a3eb..d6ac83a5 100644 --- a/tools/quake2/extra/qe4/mru.c +++ b/tools/quake2/extra/qe4/mru.c @@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // //************************************************************* +#include "globaldefs.h" #include #include #include @@ -505,7 +506,7 @@ WORD i; return TRUE; } -#ifdef WIN32 +#if GDEF_OS_WINDOWS BOOL IsWin395OrHigher(void) { diff --git a/tools/quake2/extra/qe4/mru.h b/tools/quake2/extra/qe4/mru.h index b78b986c..052a6e9a 100644 --- a/tools/quake2/extra/qe4/mru.h +++ b/tools/quake2/extra/qe4/mru.h @@ -36,6 +36,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __MRU_H__ #define __MRU_H__ +#include "globaldefs.h" + #define NBMRUMENUSHOW 6 // Default number of MRU showed in the menu File #define NBMRUMENU 9 // Default number of MRU stored #define IDMRU 8000 // Default First ID of MRU @@ -83,7 +85,7 @@ void PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem); BOOL SaveMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile); BOOL LoadMruInIni (LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile); -#ifdef WIN32 +#if GDEF_OS_WINDOWS BOOL SaveMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey); BOOL LoadMruInReg (LPMRUMENU lpMruMenu,LPSTR lpszKey); diff --git a/tools/quake2/extra/qe4/qe3.h b/tools/quake2/extra/qe4/qe3.h index 67930599..538b54e2 100644 --- a/tools/quake2/extra/qe4/qe3.h +++ b/tools/quake2/extra/qe4/qe3.h @@ -24,9 +24,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define __QE3_H__ // disable data conversion warnings for gl +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4244) // MIPS #pragma warning(disable : 4136) // X86 #pragma warning(disable : 4051) // ALPHA +#endif #include diff --git a/tools/quake2/q2map/q2map.h b/tools/quake2/q2map/q2map.h index 401e6f74..8344f388 100644 --- a/tools/quake2/q2map/q2map.h +++ b/tools/quake2/q2map/q2map.h @@ -20,8 +20,10 @@ */ // q2map.h +#include "globaldefs.h" + /* platform-specific */ -#if defined( __linux__ ) || defined( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define Q_UNIX #endif @@ -31,7 +33,7 @@ #include #endif -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif diff --git a/tools/quake2/q2map/qbsp.h b/tools/quake2/q2map/qbsp.h index 56ac1b2f..d803354c 100644 --- a/tools/quake2/q2map/qbsp.h +++ b/tools/quake2/q2map/qbsp.h @@ -38,6 +38,7 @@ */ +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "scriplib.h" @@ -46,7 +47,7 @@ #include "bspfile.h" #include "inout.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/q2map/qrad.h b/tools/quake2/q2map/qrad.h index d8e3791e..061a2e3f 100644 --- a/tools/quake2/q2map/qrad.h +++ b/tools/quake2/q2map/qrad.h @@ -27,7 +27,7 @@ */ - +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "bspfile.h" @@ -36,11 +36,11 @@ #include "lbmlib.h" #include "inout.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/q2map/qvis.h b/tools/quake2/q2map/qvis.h index a509d009..7ee1e8c7 100644 --- a/tools/quake2/q2map/qvis.h +++ b/tools/quake2/q2map/qvis.h @@ -25,12 +25,13 @@ */ +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "bspfile.h" #include "inout.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/qdata/qdata.c b/tools/quake2/qdata/qdata.c index 50132690..c3923ad3 100644 --- a/tools/quake2/qdata/qdata.c +++ b/tools/quake2/qdata/qdata.c @@ -212,7 +212,7 @@ void Cmd_File( void ){ =============== */ -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void PackDirectory_r( char *dir ){ struct _finddata_t fileinfo; diff --git a/tools/quake2/qdata/qdata.h b/tools/quake2/qdata/qdata.h index cb00003a..bcb0e5ce 100644 --- a/tools/quake2/qdata/qdata.h +++ b/tools/quake2/qdata/qdata.h @@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "globaldefs.h" #include #include #include @@ -34,7 +35,7 @@ #include "l3dslib.h" #include "bspfile.h" -#ifdef WIN32 +#if GDEF_COMPILER_MSVC #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/qdata_heretic2/common/cmdlib.c b/tools/quake2/qdata_heretic2/common/cmdlib.c index 514a1c7b..e67106eb 100644 --- a/tools/quake2/qdata_heretic2/common/cmdlib.c +++ b/tools/quake2/qdata_heretic2/common/cmdlib.c @@ -22,17 +22,18 @@ // Nurail: Swiped from quake3/common #include "cmdlib.h" +#include "globaldefs.h" #include "mathlib.h" #include "inout.h" #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #endif -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #include #endif @@ -84,7 +85,7 @@ void *SafeMalloc( size_t n, char *desc ){ return p; } -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS void strlwr( char *conv_str ){ int i; @@ -115,7 +116,7 @@ char archivedir[1024]; #define MAX_EX_ARGC 1024 int ex_argc; char *ex_argv[MAX_EX_ARGC]; -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void ExpandWildcards( int *argc, char ***argv ){ struct _finddata_t fileinfo; @@ -342,7 +343,7 @@ double I_FloatTime( void ){ void Q_getwd( char *out ){ int i = 0; -#ifdef WIN32 +#if GDEF_OS_WINDOWS _getcwd( out, 256 ); strcat( out, "\\" ); #else @@ -361,7 +362,7 @@ void Q_getwd( char *out ){ void Q_mkdir( const char *path ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS if ( _mkdir( path ) != -1 ) { return; } @@ -964,11 +965,7 @@ int ParseNum( const char *str ){ ============================================================================ */ -#ifdef _SGI_SOURCE -#define __BIG_ENDIAN__ -#endif - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG short LittleShort( short l ){ byte b1,b2; @@ -1140,7 +1137,7 @@ void CreatePath( const char *path ){ char c; char dir[1024]; -#ifdef _WIN32 +#if GDEF_OS_WINDOWS int olddrive = -1; if ( path[1] == ':' ) { @@ -1163,7 +1160,7 @@ void CreatePath( const char *path ){ } } -#ifdef _WIN32 +#if GDEF_OS_WINDOWS if ( olddrive != -1 ) { _chdrive( olddrive ); } @@ -1189,10 +1186,10 @@ void QCopyFile( const char *from, const char *to ){ } void Sys_Sleep( int n ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS Sleep( n ); #endif -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS usleep( n * 1000 ); #endif } diff --git a/tools/quake2/qdata_heretic2/common/cmdlib.h b/tools/quake2/qdata_heretic2/common/cmdlib.h index c94ce377..b66ccb77 100644 --- a/tools/quake2/qdata_heretic2/common/cmdlib.h +++ b/tools/quake2/qdata_heretic2/common/cmdlib.h @@ -24,7 +24,7 @@ #ifndef __CMDLIB__ #define __CMDLIB__ -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4244) // MIPS #pragma warning(disable : 4136) // X86 #pragma warning(disable : 4051) // ALPHA @@ -44,7 +44,7 @@ #include #include -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma intrinsic( memset, memcpy ) diff --git a/tools/quake2/qdata_heretic2/common/inout.c b/tools/quake2/qdata_heretic2/common/inout.c index 30ae39df..165390de 100644 --- a/tools/quake2/qdata_heretic2/common/inout.c +++ b/tools/quake2/qdata_heretic2/common/inout.c @@ -26,6 +26,7 @@ // deal with in/out tasks, for either stdin/stdout or network/XML stream // +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "polylib.h" @@ -33,7 +34,7 @@ #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #endif @@ -42,7 +43,7 @@ #include "l_net/l_net.h" #include "libxml/tree.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS HWND hwndOut = NULL; qboolean lookedForServer = false; UINT wm_BroadcastCommand = -1; diff --git a/tools/quake2/qdata_heretic2/common/inout.h b/tools/quake2/qdata_heretic2/common/inout.h index be0bd9a4..80bf1527 100644 --- a/tools/quake2/qdata_heretic2/common/inout.h +++ b/tools/quake2/qdata_heretic2/common/inout.h @@ -22,6 +22,7 @@ #ifndef __INOUT__ #define __INOUT__ +#include "globaldefs.h" // inout is the only stuff relying on xml, include the headers there #include "libxml/tree.h" #include "mathlib.h" @@ -52,7 +53,7 @@ void Sys_Printf( const char *text, ... ); void Sys_FPrintf( int flag, const char *text, ... ); void Error( const char *error, ... ); -#ifdef _DEBUG +#if GDEF_DEBUG #define DBG_XML 1 #endif diff --git a/tools/quake2/qdata_heretic2/common/mathlib.c b/tools/quake2/qdata_heretic2/common/mathlib.c index 2fa7eabe..ae61e4b3 100644 --- a/tools/quake2/qdata_heretic2/common/mathlib.c +++ b/tools/quake2/qdata_heretic2/common/mathlib.c @@ -94,8 +94,10 @@ void _VectorScale( vec3_t v, vec_t scale, vec3_t out ){ out[2] = v[2] * scale; } +#if GDEF_COMPILER_MSVC #pragma optimize("g", off) // went back to turning optimization off, // the bug_fix thing stopped working +#endif vec_t VectorNormalize( vec3_t in, vec3_t out ){ vec_t length, ilength; @@ -136,7 +138,9 @@ vec_t ColorNormalize( vec3_t in, vec3_t out ){ return max; } +#if GDEF_COMPILER_MSVC #pragma optimize("", on) +#endif void VectorInverse( vec3_t v ){ v[0] = -v[0]; diff --git a/tools/quake2/qdata_heretic2/common/path_init.c b/tools/quake2/qdata_heretic2/common/path_init.c index afe5e9f0..ce5ef540 100644 --- a/tools/quake2/qdata_heretic2/common/path_init.c +++ b/tools/quake2/qdata_heretic2/common/path_init.c @@ -24,12 +24,9 @@ Nurail: Swiped from Q3Map2 */ +#include "globaldefs.h" - -/* marker */ -#define PATH_INIT_C - -#if defined( __linux__ ) || defined( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define Q_UNIX #endif diff --git a/tools/quake2/qdata_heretic2/common/threads.c b/tools/quake2/qdata_heretic2/common/threads.c index 3938807d..31a6ca9f 100644 --- a/tools/quake2/qdata_heretic2/common/threads.c +++ b/tools/quake2/qdata_heretic2/common/threads.c @@ -19,7 +19,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef WIN32 +#include "globaldefs.h" + +#if !GDEF_OS_WINDOWS // The below define is necessary to use // pthreads extensions like pthread_mutexattr_settype #define _GNU_SOURCE @@ -106,7 +108,7 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( =================================================================== */ -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define USED @@ -414,7 +416,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){ ======================================================================= */ -#ifdef __linux__ +#if GDEF_OS_LINUX #define USED int numthreads = 4; diff --git a/tools/quake2/qdata_heretic2/fmodels.c b/tools/quake2/qdata_heretic2/fmodels.c index a3e06c0b..e764a63b 100644 --- a/tools/quake2/qdata_heretic2/fmodels.c +++ b/tools/quake2/qdata_heretic2/fmodels.c @@ -148,7 +148,7 @@ void GetOneGroup( trigroup_t *tris, int grp, triangle_t* triangles ); void ScaleTris( vec3_t min, vec3_t max, int Width, int Height, float* u, float* v, int verts ); void NewDrawLine( int x1, int y1, int x2, int y2, unsigned char* picture, int width, int height ); -#ifndef _WIN32 +#if !GDEF_OS_WINDOWS void strupr( char *string ){ int i; diff --git a/tools/quake2/qdata_heretic2/images.c b/tools/quake2/qdata_heretic2/images.c index 3b07715a..6131c5d0 100644 --- a/tools/quake2/qdata_heretic2/images.c +++ b/tools/quake2/qdata_heretic2/images.c @@ -21,7 +21,7 @@ #include "qdata.h" -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include #endif diff --git a/tools/quake2/qdata_heretic2/joints.h b/tools/quake2/qdata_heretic2/joints.h index 074734e9..960225f6 100644 --- a/tools/quake2/qdata_heretic2/joints.h +++ b/tools/quake2/qdata_heretic2/joints.h @@ -22,6 +22,8 @@ #ifndef JOINTS_H #define JOINTS_H +#include "globaldefs.h" + #ifdef _HERETIC2_ #include "angles.h" #endif @@ -29,7 +31,7 @@ //typedef float vec3_t[3]; //typedef unsigned char byte; -#ifndef _WIN32 +#if !GDEF_OS_WINDOWS #define stricmp strcasecmp #define strcmpi strcasecmp #endif diff --git a/tools/quake2/qdata_heretic2/qcommon/angles.h b/tools/quake2/qdata_heretic2/qcommon/angles.h index 8e893446..0d095c44 100644 --- a/tools/quake2/qdata_heretic2/qcommon/angles.h +++ b/tools/quake2/qdata_heretic2/qcommon/angles.h @@ -71,5 +71,6 @@ #define SHORT_TO_ANGLE ( 360.0 / 65536 ) - +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4305) // 'initializing' : truncation from 'const double ' to 'float ' +#endif diff --git a/tools/quake2/qdata_heretic2/qcommon/arrayedlist.h b/tools/quake2/qdata_heretic2/qcommon/arrayedlist.h index 25bf5483..9ef9705b 100644 --- a/tools/quake2/qdata_heretic2/qcommon/arrayedlist.h +++ b/tools/quake2/qdata_heretic2/qcommon/arrayedlist.h @@ -33,13 +33,7 @@ typedef struct ArrayedListNode_s #define ARRAYEDLISTNODE_NULL -1 -static -#ifdef _WIN32 -_inline -#else -inline -#endif -int GetFreeNode( ArrayedListNode_t *nodeArray, int max ){ +static GDEF_ATTRIBUTE_INLINE int GetFreeNode( ArrayedListNode_t *nodeArray, int max ){ int i; for ( i = 0; i < max; ++i ) @@ -54,13 +48,7 @@ int GetFreeNode( ArrayedListNode_t *nodeArray, int max ){ return -1; } -static -#ifdef _WIN32 -_inline -#else -inline -#endif -void FreeNode( ArrayedListNode_t *nodeArray, int index ){ +static GDEF_ATTRIBUTE_INLINE void FreeNode( ArrayedListNode_t *nodeArray, int index ){ nodeArray[index].inUse = 0; } diff --git a/tools/quake2/qdata_heretic2/qdata.c b/tools/quake2/qdata_heretic2/qdata.c index a715927a..3e1f8f04 100644 --- a/tools/quake2/qdata_heretic2/qdata.c +++ b/tools/quake2/qdata_heretic2/qdata.c @@ -20,6 +20,7 @@ */ #include "qdata.h" +#include "globaldefs.h" #include "md4.h" void TK_Init(); @@ -202,7 +203,7 @@ void Cmd_File( void ){ =============== */ -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void PackDirectory_r( char *dir ){ struct _finddata_t fileinfo; diff --git a/tools/quake2/qdata_heretic2/qdata.h b/tools/quake2/qdata_heretic2/qdata.h index 2ead9751..67d97547 100644 --- a/tools/quake2/qdata_heretic2/qdata.h +++ b/tools/quake2/qdata_heretic2/qdata.h @@ -21,7 +21,7 @@ // qdata.h - +#include "globaldefs.h" #include #include #include @@ -38,7 +38,7 @@ #include "l3dslib.h" #include "bspfile.h" -#ifndef _WIN32 +#if !GDEF_OS_WINDOWS #define stricmp strcasecmp #define strcmpi strcasecmp #endif diff --git a/tools/quake3/common/aselib.c b/tools/quake3/common/aselib.c index df9b986a..314fdc5e 100644 --- a/tools/quake3/common/aselib.c +++ b/tools/quake3/common/aselib.c @@ -19,8 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #include "aselib.h" +#include "globaldefs.h" #include "inout.h" #include @@ -114,7 +114,7 @@ static char gl_filename[1024]; static void ASE_Process( void ); static void ASE_FreeGeomObject( int ndx ); -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS static char* strlwr( char* string ){ char *cp; diff --git a/tools/quake3/common/cmdlib.c b/tools/quake3/common/cmdlib.c index 103047c0..6ff815ab 100644 --- a/tools/quake3/common/cmdlib.c +++ b/tools/quake3/common/cmdlib.c @@ -29,17 +29,18 @@ // replaced qprintf with Sys_Printf #include "cmdlib.h" +#include "globaldefs.h" #include "mathlib.h" #include "inout.h" #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #endif -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #include #endif @@ -95,7 +96,7 @@ char archivedir[1024]; #define MAX_EX_ARGC 1024 int ex_argc; char *ex_argv[MAX_EX_ARGC]; -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void ExpandWildcards( int *argc, char ***argv ){ struct _finddata_t fileinfo; @@ -292,7 +293,7 @@ double I_FloatTime( void ){ void Q_getwd( char *out ){ int i = 0; -#ifdef WIN32 +#if GDEF_OS_WINDOWS _getcwd( out, 256 ); strcat( out, "\\" ); #else @@ -318,7 +319,7 @@ void Q_mkdir( const char *path ){ int retry = 2; while ( retry-- ) { -#ifdef WIN32 +#if GDEF_OS_WINDOWS const char *q = NULL; if ( _mkdir( path ) != -1 ) { return; @@ -882,11 +883,7 @@ int ParseNum( const char *str ){ ============================================================================ */ -#ifdef _SGI_SOURCE -#define __BIG_ENDIAN__ -#endif - -#ifdef __BIG_ENDIAN__ +#if GDEF_ARCH_ENDIAN_BIG short LittleShort( short l ){ byte b1,b2; @@ -1058,7 +1055,7 @@ void CreatePath( const char *path ){ char c; char dir[1024]; -#ifdef _WIN32 +#if GDEF_OS_WINDOWS int olddrive = -1; if ( path[1] == ':' ) { @@ -1081,7 +1078,7 @@ void CreatePath( const char *path ){ } } -#ifdef _WIN32 +#if GDEF_OS_WINDOWS if ( olddrive != -1 ) { _chdrive( olddrive ); } @@ -1107,10 +1104,10 @@ void QCopyFile( const char *from, const char *to ){ } void Sys_Sleep( int n ){ -#ifdef WIN32 +#if GDEF_OS_WINDOWS Sleep( n ); #endif -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS usleep( n * 1000 ); #endif } diff --git a/tools/quake3/common/cmdlib.h b/tools/quake3/common/cmdlib.h index 701b3016..9cbb5e50 100644 --- a/tools/quake3/common/cmdlib.h +++ b/tools/quake3/common/cmdlib.h @@ -25,8 +25,9 @@ #define __CMDLIB__ #include "bytebool.h" +#include "globaldefs.h" -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma warning(disable : 4244) // MIPS #pragma warning(disable : 4136) // X86 #pragma warning(disable : 4051) // ALPHA @@ -46,7 +47,7 @@ #include #include -#ifdef _WIN32 +#if GDEF_COMPILER_MSVC #pragma intrinsic( memset, memcpy ) @@ -97,11 +98,7 @@ void ExpandWildcards( int *argc, char ***argv ); double I_FloatTime( void ); -void Error( const char *error, ... ) -#ifdef __GNUC__ -__attribute__( ( noreturn ) ) -#endif -; +void Error( const char *error, ... ) GDEF_ATTRIBUTE_NORETURN; int CheckParm( const char *check ); FILE *SafeOpenWrite( const char *filename ); diff --git a/tools/quake3/common/inout.c b/tools/quake3/common/inout.c index 14e9eaaf..f05b0bc9 100644 --- a/tools/quake3/common/inout.c +++ b/tools/quake3/common/inout.c @@ -26,6 +26,7 @@ // deal with in/out tasks, for either stdin/stdout or network/XML stream // +#include "globaldefs.h" #include "cmdlib.h" #include "mathlib.h" #include "polylib.h" @@ -33,7 +34,7 @@ #include #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #include #endif @@ -45,7 +46,7 @@ // utf8 conversion #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS HWND hwndOut = NULL; qboolean lookedForServer = qfalse; UINT wm_BroadcastCommand = -1; diff --git a/tools/quake3/common/inout.h b/tools/quake3/common/inout.h index 4efe0dac..10d399f7 100644 --- a/tools/quake3/common/inout.h +++ b/tools/quake3/common/inout.h @@ -22,6 +22,7 @@ #ifndef __INOUT__ #define __INOUT__ +#include "globaldefs.h" // inout is the only stuff relying on xml, include the headers there #include "libxml/tree.h" #include "mathlib.h" @@ -51,7 +52,7 @@ extern qboolean verbose; void Sys_Printf( const char *text, ... ); void Sys_FPrintf( int flag, const char *text, ... ); -#ifdef _DEBUG +#if GDEF_DEBUG #define DBG_XML 1 #endif diff --git a/tools/quake3/common/mutex.c b/tools/quake3/common/mutex.c index d128a031..1d0a354e 100644 --- a/tools/quake3/common/mutex.c +++ b/tools/quake3/common/mutex.c @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - +#include "globaldefs.h" #include "cmdlib.h" #include "qthreads.h" #include "mutex.h" @@ -31,7 +31,7 @@ =================================================================== */ -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define USED diff --git a/tools/quake3/common/threads.c b/tools/quake3/common/threads.c index b886cb87..537732fb 100644 --- a/tools/quake3/common/threads.c +++ b/tools/quake3/common/threads.c @@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef WIN32 +#include "globaldefs.h" +#if !GDEF_OS_WINDOWS // The below define is necessary to use // pthreads extensions like pthread_mutexattr_settype #define _GNU_SOURCE @@ -116,7 +117,7 @@ void RunThreadsOnIndividual( int workcnt, qboolean showpacifier, void ( *func )( =================================================================== */ -#ifdef WIN32 +#if GDEF_OS_WINDOWS #define USED @@ -424,7 +425,7 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, void ( *func )( int ) ){ ======================================================================= */ -#if defined( __linux__ ) || ( defined( __APPLE__ ) && !MAC_STATIC_HACK ) +#if GDEF_OS_LINUX || ( GDEF_OS_MACOS && !MAC_STATIC_HACK ) #define USED #include diff --git a/tools/quake3/common/trilib.c b/tools/quake3/common/trilib.c index d3ec168a..76d35dce 100644 --- a/tools/quake3/common/trilib.c +++ b/tools/quake3/common/trilib.c @@ -23,6 +23,7 @@ // trilib.c: library for loading triangles from an Alias triangle file // +#include "globaldefs.h" #include #include "cmdlib.h" #include "mathlib.h" @@ -38,7 +39,7 @@ //#define NOISY 1 -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define strlwr strlower #endif diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index bc80d727..9026a296 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -31,9 +31,11 @@ #ifndef _VFS_H_ #define _VFS_H_ +#include "globaldefs.h" + // to get PATH_MAX #include -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #include #include #else diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index b4c7d93f..4ad23e49 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -19,13 +19,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "globaldefs.h" #include -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif #include "md3lib.h" -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define filelength(f) Q_filelength(f) #else #define filelength(f) filelength(fileno(f)) diff --git a/tools/quake3/q3data/p3dlib.c b/tools/quake3/q3data/p3dlib.c index 9de83614..2abcea61 100644 --- a/tools/quake3/q3data/p3dlib.c +++ b/tools/quake3/q3data/p3dlib.c @@ -20,8 +20,9 @@ */ #include "p3dlib.h" +#include "globaldefs.h" -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif #include @@ -30,7 +31,7 @@ #define MAX_POLYSETS 64 -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #include "cmdlib.h" #define _strcmpi Q_stricmp #define strlwr strlower diff --git a/tools/quake3/q3data/q3data.c b/tools/quake3/q3data/q3data.c index f517beb0..0544076b 100644 --- a/tools/quake3/q3data/q3data.c +++ b/tools/quake3/q3data/q3data.c @@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef WIN32 +#include "globaldefs.h" +#if GDEF_OS_WINDOWS #include #endif #include "q3data.h" @@ -40,7 +41,7 @@ char *moddir = NULL; // some old defined that was in cmdlib lost during merge char writedir[1024]; -#if defined ( __linux__ ) || defined ( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define strlwr strlower #endif @@ -301,7 +302,7 @@ void Cmd_File( void ){ =============== */ -#ifdef _WIN32 +#if GDEF_OS_WINDOWS #include "io.h" void PackDirectory_r( char *dir ){ struct _finddata_t fileinfo; @@ -334,7 +335,7 @@ void PackDirectory_r( char *dir ){ #else #include -#ifndef WIN32 +#if !GDEF_OS_WINDOWS #include #else #include diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index d3a9432f..f38d5679 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -32,7 +32,7 @@ #ifndef Q3MAP2_H #define Q3MAP2_H - +#include "globaldefs.h" /* version */ #ifndef Q3MAP_VERSION @@ -50,7 +50,7 @@ ------------------------------------------------------------------------------- */ /* platform-specific */ -#if defined( __linux__ ) || defined( __APPLE__ ) +#if GDEF_OS_LINUX || GDEF_OS_MACOS #define Q_UNIX #endif @@ -60,7 +60,7 @@ #include #endif -#ifdef WIN32 +#if GDEF_OS_WINDOWS #include #endif @@ -93,14 +93,14 @@ ------------------------------------------------------------------------------- */ #define MAC_STATIC_HACK 0 -#if defined( __APPLE__ ) && MAC_STATIC_HACK +#if GDEF_OS_MACOS && MAC_STATIC_HACK #define MAC_STATIC static #else #define MAC_STATIC #endif #if 1 - #ifdef WIN32 + #if GDEF_OS_WINDOWS #define Q_stricmp stricmp #define Q_strncasecmp strnicmp #else