diff --git a/public/tier0/basetypes.h b/public/tier0/basetypes.h index 541b69d7..ccf15dcd 100644 --- a/public/tier0/basetypes.h +++ b/public/tier0/basetypes.h @@ -37,8 +37,10 @@ #endif -#ifdef _LINUX +#if defined _LINUX && !defined __APPLE__ typedef unsigned int uintptr_t; +#elif defined __APPLE__ +#include #endif #define ExecuteNTimes( nTimes, x ) \ @@ -68,6 +70,9 @@ inline T AlignValue( T val, unsigned alignment ) ( ((number) + ((boundary)-1)) / (boundary) ) * (boundary) // In case this ever changes +#if defined M_PI +# undef M_PI +#endif #define M_PI 3.14159265358979323846 #include "valve_minmax_on.h" @@ -103,7 +108,9 @@ typedef unsigned char BYTE; typedef unsigned char byte; typedef unsigned short word; +#if !defined __APPLE__ typedef unsigned int uintptr_t; +#endif enum ThreeState_t diff --git a/public/tier0/memalloc.h b/public/tier0/memalloc.h index b1ccbf1d..eb001b68 100644 --- a/public/tier0/memalloc.h +++ b/public/tier0/memalloc.h @@ -117,7 +117,7 @@ inline void *MemAlloc_AllocAligned( size_t size, size_t align ) { unsigned char *pAlloc, *pResult; - if (!IsPowerOfTwo(align)) + if (!IsPowerOfTwo(uint(align))) return NULL; align = (align > sizeof(void *) ? align : sizeof(void *)) - 1; @@ -135,7 +135,7 @@ inline void *MemAlloc_AllocAligned( size_t size, size_t align, const char *pszFi { unsigned char *pAlloc, *pResult; - if (!IsPowerOfTwo(align)) + if (!IsPowerOfTwo(uint(align))) return NULL; align = (align > sizeof(void *) ? align : sizeof(void *)) - 1; @@ -151,7 +151,7 @@ inline void *MemAlloc_AllocAligned( size_t size, size_t align, const char *pszFi inline void *MemAlloc_ReallocAligned( void *ptr, size_t size, size_t align ) { - if ( !IsPowerOfTwo( align ) ) + if ( !IsPowerOfTwo( uint(align) ) ) return NULL; // Don't change alignment between allocation + reallocation. diff --git a/public/tier0/memdbgon.h b/public/tier0/memdbgon.h index 59ad4675..b269ccd4 100644 --- a/public/tier0/memdbgon.h +++ b/public/tier0/memdbgon.h @@ -29,7 +29,11 @@ #include #endif #include +#if defined __APPLE__ +#include +#else #include +#endif #include "commonmacros.h" #include "memalloc.h" diff --git a/public/tier0/platform.h b/public/tier0/platform.h index 0da9e564..8b21a079 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -42,7 +42,11 @@ #include #endif // _LINUX +#if defined __APPLE__ +#include +#else #include +#endif #ifdef _MSC_VER #include #elif defined __GNUC__ diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index 130dbfc0..eead39ed 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -1410,6 +1410,9 @@ inline CThreadMutex::CThreadMutex() { // enable recursive locks as we need them pthread_mutexattr_init( &m_Attr ); +#if defined __APPLE__ +# define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE +#endif pthread_mutexattr_settype( &m_Attr, PTHREAD_MUTEX_RECURSIVE_NP ); pthread_mutex_init( &m_Mutex, &m_Attr ); } diff --git a/public/tier1/KeyValues.h b/public/tier1/KeyValues.h index 52856d64..7eb2f026 100644 --- a/public/tier1/KeyValues.h +++ b/public/tier1/KeyValues.h @@ -167,8 +167,8 @@ public: void SetColor( const char *keyName, Color value); // Memory allocation (optimized) - void *operator new( unsigned int iAllocSize ); - void *operator new( unsigned int iAllocSize, int nBlockUse, const char *pFileName, int nLine ); + void *operator new( size_t iAllocSize ); + void *operator new( size_t iAllocSize, int nBlockUse, const char *pFileName, int nLine ); void operator delete( void *pMem ); void operator delete( void *pMem, int nBlockUse, const char *pFileName, int nLine ); diff --git a/tier1/KeyValues.cpp b/tier1/KeyValues.cpp index e8ba3e54..ad08e5f3 100644 --- a/tier1/KeyValues.cpp +++ b/tier1/KeyValues.cpp @@ -2340,13 +2340,13 @@ bool KeyValues::ReadAsBinary( CUtlBuffer &buffer ) //----------------------------------------------------------------------------- // Purpose: memory allocator //----------------------------------------------------------------------------- -void *KeyValues::operator new( unsigned int iAllocSize ) +void *KeyValues::operator new( size_t iAllocSize ) { MEM_ALLOC_CREDIT(); return KeyValuesSystem()->AllocKeyValuesMemory(iAllocSize); } -void *KeyValues::operator new( unsigned int iAllocSize, int nBlockUse, const char *pFileName, int nLine ) +void *KeyValues::operator new( size_t iAllocSize, int nBlockUse, const char *pFileName, int nLine ) { MemAlloc_PushAllocDbgInfo( pFileName, nLine ); void *p = KeyValuesSystem()->AllocKeyValuesMemory(iAllocSize);