1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 12:06:07 +08:00

Some includes can be used on Mac OS X now (bug 3515, r=ds).

This commit is contained in:
David Anderson
2008-12-22 23:33:59 -05:00
parent 7ff7f366d5
commit 168e6792f9
7 changed files with 26 additions and 8 deletions

View File

@ -37,8 +37,10 @@
#endif #endif
#ifdef _LINUX #if defined _LINUX && !defined __APPLE__
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
#elif defined __APPLE__
#include <stdint.h>
#endif #endif
#define ExecuteNTimes( nTimes, x ) \ #define ExecuteNTimes( nTimes, x ) \
@ -68,6 +70,9 @@ inline T AlignValue( T val, unsigned alignment )
( ((number) + ((boundary)-1)) / (boundary) ) * (boundary) ( ((number) + ((boundary)-1)) / (boundary) ) * (boundary)
// In case this ever changes // In case this ever changes
#if defined M_PI
# undef M_PI
#endif
#define M_PI 3.14159265358979323846 #define M_PI 3.14159265358979323846
#include "valve_minmax_on.h" #include "valve_minmax_on.h"
@ -103,7 +108,9 @@ typedef unsigned char BYTE;
typedef unsigned char byte; typedef unsigned char byte;
typedef unsigned short word; typedef unsigned short word;
#if !defined __APPLE__
typedef unsigned int uintptr_t; typedef unsigned int uintptr_t;
#endif
enum ThreeState_t enum ThreeState_t

View File

@ -117,7 +117,7 @@ inline void *MemAlloc_AllocAligned( size_t size, size_t align )
{ {
unsigned char *pAlloc, *pResult; unsigned char *pAlloc, *pResult;
if (!IsPowerOfTwo(align)) if (!IsPowerOfTwo(uint(align)))
return NULL; return NULL;
align = (align > sizeof(void *) ? align : sizeof(void *)) - 1; 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; unsigned char *pAlloc, *pResult;
if (!IsPowerOfTwo(align)) if (!IsPowerOfTwo(uint(align)))
return NULL; return NULL;
align = (align > sizeof(void *) ? align : sizeof(void *)) - 1; 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 ) inline void *MemAlloc_ReallocAligned( void *ptr, size_t size, size_t align )
{ {
if ( !IsPowerOfTwo( align ) ) if ( !IsPowerOfTwo( uint(align) ) )
return NULL; return NULL;
// Don't change alignment between allocation + reallocation. // Don't change alignment between allocation + reallocation.

View File

@ -29,7 +29,11 @@
#include <wchar.h> #include <wchar.h>
#endif #endif
#include <string.h> #include <string.h>
#if defined __APPLE__
#include <stdlib.h>
#else
#include <malloc.h> #include <malloc.h>
#endif
#include "commonmacros.h" #include "commonmacros.h"
#include "memalloc.h" #include "memalloc.h"

View File

@ -42,7 +42,11 @@
#include <alloca.h> #include <alloca.h>
#endif // _LINUX #endif // _LINUX
#if defined __APPLE__
#include <stdlib.h>
#else
#include <malloc.h> #include <malloc.h>
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
#include <new.h> #include <new.h>
#elif defined __GNUC__ #elif defined __GNUC__

View File

@ -1410,6 +1410,9 @@ inline CThreadMutex::CThreadMutex()
{ {
// enable recursive locks as we need them // enable recursive locks as we need them
pthread_mutexattr_init( &m_Attr ); 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_mutexattr_settype( &m_Attr, PTHREAD_MUTEX_RECURSIVE_NP );
pthread_mutex_init( &m_Mutex, &m_Attr ); pthread_mutex_init( &m_Mutex, &m_Attr );
} }

View File

@ -167,8 +167,8 @@ public:
void SetColor( const char *keyName, Color value); void SetColor( const char *keyName, Color value);
// Memory allocation (optimized) // Memory allocation (optimized)
void *operator new( unsigned int iAllocSize ); void *operator new( size_t iAllocSize );
void *operator new( unsigned int iAllocSize, int nBlockUse, const char *pFileName, int nLine ); void *operator new( size_t iAllocSize, int nBlockUse, const char *pFileName, int nLine );
void operator delete( void *pMem ); void operator delete( void *pMem );
void operator delete( void *pMem, int nBlockUse, const char *pFileName, int nLine ); void operator delete( void *pMem, int nBlockUse, const char *pFileName, int nLine );

View File

@ -2340,13 +2340,13 @@ bool KeyValues::ReadAsBinary( CUtlBuffer &buffer )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Purpose: memory allocator // Purpose: memory allocator
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void *KeyValues::operator new( unsigned int iAllocSize ) void *KeyValues::operator new( size_t iAllocSize )
{ {
MEM_ALLOC_CREDIT(); MEM_ALLOC_CREDIT();
return KeyValuesSystem()->AllocKeyValuesMemory(iAllocSize); 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 ); MemAlloc_PushAllocDbgInfo( pFileName, nLine );
void *p = KeyValuesSystem()->AllocKeyValuesMemory(iAllocSize); void *p = KeyValuesSystem()->AllocKeyValuesMemory(iAllocSize);