diff --git a/lib/mac/interfaces_i486.a b/lib/mac/interfaces_i486.a new file mode 100644 index 00000000..b8ce3947 Binary files /dev/null and b/lib/mac/interfaces_i486.a differ diff --git a/lib/mac/mathlib_i486.a b/lib/mac/mathlib_i486.a new file mode 100644 index 00000000..deebb8cc Binary files /dev/null and b/lib/mac/mathlib_i486.a differ diff --git a/lib/mac/tier1_i486.a b/lib/mac/tier1_i486.a new file mode 100644 index 00000000..2cf648d0 Binary files /dev/null and b/lib/mac/tier1_i486.a differ diff --git a/linux_sdk/Makefile b/linux_sdk/Makefile index ec2f968e..fcce185b 100644 --- a/linux_sdk/Makefile +++ b/linux_sdk/Makefile @@ -3,6 +3,8 @@ # # +OS := $(shell uname -s) + ############################################################################# # Developer configurable items ############################################################################# @@ -24,9 +26,15 @@ SRCDS_DIR = ~/srcds/orangebox GAME_DIR = $(SRCDS_DIR)/scratchmod # compiler options (gcc 3.4.1 or above is required - 4.1.2+ recommended) +ifeq "$(OS)" "Darwin" +CC = /usr/bin/clang +CPLUS = /usr/bin/clang++ +CLINK = /usr/bin/clang +else CC = /usr/bin/gcc CPLUS = /usr/bin/g++ CLINK = /usr/bin/gcc +endif CPP_LIB = "libstdc++.a libgcc_eh.a" # put any compiler flags you want passed here @@ -48,6 +56,7 @@ DEBUG = false ############################################################################# # Things below here shouldn't need to be altered ############################################################################# +OS := $(shell uname -s) MAKE = make AR = "ar rvs" @@ -58,18 +67,29 @@ BUILD_OBJ_DIR = $(BUILD_DIR)/obj # the location of the source code SRC_DIR = .. -# the location of the Linux static libraries + +# the location of the static libraries +ifeq "$(OS)" "Darwin" +LIB_DIR = $(SRC_DIR)/lib/mac +else LIB_DIR = $(SRC_DIR)/lib/linux +endif # the CPU target for the build, must be i486 for now ARCH = i486 -ARCH_CFLAGS = -mtune=i686 -march=pentium3 -mmmx -msse -m32 +ARCH_CFLAGS = -mtune=i686 -march=pentium3 -mmmx -msse -msse2 -m32 -DEFINES = -D_LINUX -DLINUX -DCOMPILER_GCC -DPOSIX -DVPROF_LEVEL=1 -DSWDS -D_finite=finite -Dstricmp=strcasecmp -D_stricmp=strcasecmp \ - -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp +ifeq "$(OS)" "Darwin" +DEFINES = -D_OSX -DOSX +else +DEFINES = -D_LINUX -DLINUX +endif + +DEFINES += -DCOMPILER_GCC -DPOSIX -DVPROF_LEVEL=1 -DSWDS -D_finite=finite -Dstricmp=strcasecmp -D_stricmp=strcasecmp \ + -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp UNDEF = -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE -BASE_CFLAGS = -fno-strict-aliasing -Wall -Werror -Wno-conversion -Wno-non-virtual-dtor -Wno-invalid-offsetof +BASE_CFLAGS = -fno-strict-aliasing -Wall -Werror -Wno-conversion -Wno-overloaded-virtual -Wno-non-virtual-dtor -Wno-invalid-offsetof SHLIBEXT = so SHLIBCFLAGS = -fPIC SHLIBLDFLAGS = -shared -Wl,-Map,$@_map.txt -Wl diff --git a/public/mathlib/ssemath.h b/public/mathlib/ssemath.h index e54e444c..40d7ca75 100644 --- a/public/mathlib/ssemath.h +++ b/public/mathlib/ssemath.h @@ -218,7 +218,7 @@ extern const int32 ALIGN16 g_SIMD_EveryOtherMask[]; // 0, ~0, 0, ~0 template inline T *AlignPointer(void * ptr) { - unsigned temp = ptr; + unsigned temp = (unsigned)ptr; temp = ALIGN_VALUE(temp, sizeof(T)); return (T *)temp; } diff --git a/public/tier0/memdbgon.h b/public/tier0/memdbgon.h index a2b13aee..c6ee2f46 100644 --- a/public/tier0/memdbgon.h +++ b/public/tier0/memdbgon.h @@ -31,7 +31,11 @@ #include #endif #include + #ifdef OSX + #include + #else #include + #endif #include "tier0/valve_on.h" #include "commonmacros.h" diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 1233e0aa..f56e3786 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -32,7 +32,11 @@ #include "wchartypes.h" #include "tier0/valve_off.h" +#ifdef OSX +#include +#else #include +#endif #include #include #include @@ -334,13 +338,6 @@ typedef unsigned int uint; #define FLOAT32_MIN FLT_MIN #define FLOAT64_MIN DBL_MIN - // On OSX, SIGTRAP doesn't really stop the thread cold when debugging. - // So if being debugged, use INT3 which is precise. -#ifdef OSX -#define DebuggerBreak() if ( Plat_IsInDebugSession() ) __asm { int 3 } else { raise(SIGTRAP); } -#else -#endif - //----------------------------------------------------------------------------- // Long is evil because it's treated differently by different compilers // Preventing its use is nasty however. This #define, which should be @@ -631,7 +628,7 @@ typedef unsigned int uint; #define DebuggerBreak() __asm { int 3 } #elif COMPILER_MSVCX360 #define DebuggerBreak() DebugBreak() -#elif COMPILER_GCC +#elif COMPILER_GCC #if defined( PLATFORM_CYGWIN ) || defined( PLATFORM_POSIX ) #define DebuggerBreak() __asm__( "int $0x3;") #else diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index 9fbf74ed..abb36908 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -336,9 +336,10 @@ public: void Set(void *); private: - uint32 m_index; #if defined(POSIX) pthread_key_t m_index; +#else + uint32 m_index; #endif }; @@ -890,7 +891,7 @@ template <> struct CAutoLockTypeDeducer { typed CAutoLockT< type > UNIQUE_ID( static_cast( mutex ) ) #define AUTO_LOCK( mutex ) \ - AUTO_LOCK_( CAutoLockTypeDeducer::Type_t, mutex ) + AUTO_LOCK_( typeof(CAutoLockTypeDeducer::Type_t), mutex ) #define AUTO_LOCK_FM( mutex ) \ diff --git a/public/tier0/vprof.h b/public/tier0/vprof.h index e74232b8..20386ba0 100644 --- a/public/tier0/vprof.h +++ b/public/tier0/vprof.h @@ -749,9 +749,9 @@ public: inline CVProfNode::CVProfNode( const tchar * pszName, int detailLevel, CVProfNode *pParent, const tchar *pBudgetGroupName, int budgetFlags ) : m_pszName( pszName ), + m_nRecursions( 0 ), m_nCurFrameCalls( 0 ), m_nPrevFrameCalls( 0 ), - m_nRecursions( 0 ), m_pParent( pParent ), m_pChild( NULL ), m_pSibling( NULL ), diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h index 5d30c49d..aff1fd50 100644 --- a/public/tier1/utlblockmemory.h +++ b/public/tier1/utlblockmemory.h @@ -336,7 +336,7 @@ void CUtlBlockMemory::Purge( int numElements ) } int nBlockSize = NumElementsInBlock(); - int nBlocksOld = m_nBlocks; + // int nBlocksOld = m_nBlocks; int nBlocks = ( numElements + nBlockSize - 1 ) / nBlockSize; // If the number of blocks is the same as the allocated number of blocks, we are done. diff --git a/tier1/checksum_md5.cpp b/tier1/checksum_md5.cpp index d41f1de2..0c4aeefa 100644 --- a/tier1/checksum_md5.cpp +++ b/tier1/checksum_md5.cpp @@ -232,7 +232,7 @@ void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t *ctx) MD5Transform(ctx->buf, (unsigned int *) ctx->in); //byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, MD5_DIGEST_LENGTH); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(MD5Context_t)); /* In case it's sensitive */ } //----------------------------------------------------------------------------- diff --git a/tier1/datamanager.cpp b/tier1/datamanager.cpp index 24935280..fd3ddf1a 100644 --- a/tier1/datamanager.cpp +++ b/tier1/datamanager.cpp @@ -122,8 +122,6 @@ unsigned int CDataManagerBase::FlushAll() unsigned int CDataManagerBase::Purge( unsigned int nBytesToPurge ) { unsigned int nTargetSize = MemUsed_Inline() - nBytesToPurge; - if ( nTargetSize < 0 ) - nTargetSize = 0; unsigned int nImpliedCapacity = MemTotal_Inline() - nTargetSize; return EnsureCapacity( nImpliedCapacity ); } diff --git a/tier1/strtools.cpp b/tier1/strtools.cpp index fb1cced7..9f270ae3 100644 --- a/tier1/strtools.cpp +++ b/tier1/strtools.cpp @@ -228,7 +228,7 @@ char *V_strnlwr(char *s, size_t count) if ( !s ) return s; - while ( --count >= 0 ) + while ( count-- ) { if ( !*s ) break;