Integrate C++11 branch into 5_1-new
This commit is contained in:
@@ -85,7 +85,7 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
|
||||
thread->m_StartFinishedSem = new SemaImpl_Pthreads( 0 );
|
||||
|
||||
int ret = pthread_create( &thread->thread, NULL, StartThread, thread );
|
||||
int ret = pthread_create( &thread->thread, nullptr, StartThread, thread );
|
||||
ASSERT_M( ret == 0, ssprintf( "MakeThread: pthread_create: %s", strerror(errno)) );
|
||||
|
||||
// Don't return until StartThread sets m_piThreadID.
|
||||
@@ -131,7 +131,7 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
MutexImpl_Pthreads::MutexImpl_Pthreads( RageMutex *pParent ):
|
||||
MutexImpl( pParent )
|
||||
{
|
||||
pthread_mutex_init( &mutex, NULL );
|
||||
pthread_mutex_init( &mutex, nullptr );
|
||||
}
|
||||
|
||||
MutexImpl_Pthreads::~MutexImpl_Pthreads()
|
||||
@@ -166,7 +166,7 @@ bool MutexImpl_Pthreads::Lock()
|
||||
/* Wait for ten seconds. If it takes longer than that, we're
|
||||
* probably deadlocked. */
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
timespec ts;
|
||||
ts.tv_sec = tv.tv_sec + len;
|
||||
@@ -248,7 +248,7 @@ MutexImpl *MakeMutex( RageMutex *pParent )
|
||||
namespace
|
||||
{
|
||||
typedef int (* CONDATTR_SET_CLOCK)( pthread_condattr_t *attr, clockid_t clock_id );
|
||||
CONDATTR_SET_CLOCK g_CondattrSetclock = NULL;
|
||||
CONDATTR_SET_CLOCK g_CondattrSetclock = nullptr;
|
||||
bool bInitialized = false;
|
||||
|
||||
#if defined(UNIX)
|
||||
@@ -263,17 +263,17 @@ namespace
|
||||
return;
|
||||
bInitialized = true;
|
||||
|
||||
void *pLib = NULL;
|
||||
void *pLib = nullptr;
|
||||
|
||||
do {
|
||||
{
|
||||
pLib = dlopen( NULL, RTLD_LAZY );
|
||||
if( pLib == NULL )
|
||||
pLib = dlopen( nullptr, RTLD_LAZY );
|
||||
if( pLib == nullptr )
|
||||
break;
|
||||
|
||||
g_CondattrSetclock = (CONDATTR_SET_CLOCK) dlsym( pLib, "pthread_condattr_setclock" );
|
||||
|
||||
if( g_CondattrSetclock == NULL )
|
||||
if( g_CondattrSetclock == nullptr )
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -293,10 +293,10 @@ namespace
|
||||
return;
|
||||
} while(0);
|
||||
|
||||
g_CondattrSetclock = NULL;
|
||||
if( pLib != NULL )
|
||||
g_CondattrSetclock = nullptr;
|
||||
if( pLib != nullptr )
|
||||
dlclose( pLib );
|
||||
pLib = NULL;
|
||||
pLib = nullptr;
|
||||
}
|
||||
#elif defined(MACOSX)
|
||||
void InitMonotonic() { bInitialized = true; }
|
||||
@@ -323,7 +323,7 @@ EventImpl_Pthreads::EventImpl_Pthreads( MutexImpl_Pthreads *pParent )
|
||||
pthread_condattr_t condattr;
|
||||
pthread_condattr_init( &condattr );
|
||||
|
||||
if( g_CondattrSetclock != NULL )
|
||||
if( g_CondattrSetclock != nullptr )
|
||||
g_CondattrSetclock( &condattr, GetClock() );
|
||||
|
||||
pthread_cond_init( &m_Cond, &condattr );
|
||||
@@ -338,7 +338,7 @@ EventImpl_Pthreads::~EventImpl_Pthreads()
|
||||
#if defined(HAVE_PTHREAD_COND_TIMEDWAIT)
|
||||
bool EventImpl_Pthreads::Wait( RageTimer *pTimeout )
|
||||
{
|
||||
if( pTimeout == NULL )
|
||||
if( pTimeout == nullptr )
|
||||
{
|
||||
pthread_cond_wait( &m_Cond, &m_pParent->mutex );
|
||||
return true;
|
||||
@@ -348,7 +348,7 @@ bool EventImpl_Pthreads::Wait( RageTimer *pTimeout )
|
||||
* (no condattr_setclock), pthread_cond_timedwait has an inherent race
|
||||
* condition: the system clock may change before we call it. */
|
||||
timespec abstime;
|
||||
if( g_CondattrSetclock != NULL || GetClock() == CLOCK_REALTIME )
|
||||
if( g_CondattrSetclock != nullptr || GetClock() == CLOCK_REALTIME )
|
||||
{
|
||||
/* If we support condattr_setclock, we'll set the condition to use
|
||||
* the same clock as RageTimer and can use it directly. If the
|
||||
@@ -360,7 +360,7 @@ bool EventImpl_Pthreads::Wait( RageTimer *pTimeout )
|
||||
{
|
||||
// The RageTimer clock is different than the wait clock; convert it.
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
RageTimer timeofday( tv.tv_sec, tv.tv_usec );
|
||||
|
||||
@@ -460,9 +460,9 @@ bool SemaImpl_Pthreads::TryWait()
|
||||
// Use conditions, to work around OS X "forgetting" to implement semaphores.
|
||||
SemaImpl_Pthreads::SemaImpl_Pthreads( int iInitialValue )
|
||||
{
|
||||
int ret = pthread_cond_init( &m_Cond, NULL );
|
||||
int ret = pthread_cond_init( &m_Cond, nullptr );
|
||||
ASSERT_M( ret == 0, ssprintf( "SemaImpl_Pthreads: pthread_cond_init: %s", strerror(errno)) );
|
||||
ret = pthread_mutex_init( &m_Mutex, NULL );
|
||||
ret = pthread_mutex_init( &m_Mutex, nullptr );
|
||||
ASSERT_M( ret == 0, ssprintf( "SemaImpl_Pthreads: pthread_mutex_init: %s", strerror(errno)) );
|
||||
|
||||
m_iValue = iInitialValue;
|
||||
@@ -489,7 +489,7 @@ bool SemaImpl_Pthreads::Wait()
|
||||
if( UseTimedlock() )
|
||||
{
|
||||
timeval tv;
|
||||
gettimeofday( &tv, NULL );
|
||||
gettimeofday( &tv, nullptr );
|
||||
|
||||
/* Wait for ten seconds. If it takes longer than that, we're probably deadlocked. */
|
||||
timespec ts;
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
const int MAX_THREADS=128;
|
||||
|
||||
static MutexImpl_Win32 *g_pThreadIdMutex = NULL;
|
||||
static MutexImpl_Win32 *g_pThreadIdMutex = nullptr;
|
||||
static void InitThreadIdMutex()
|
||||
{
|
||||
if( g_pThreadIdMutex != NULL )
|
||||
if( g_pThreadIdMutex != nullptr )
|
||||
return;
|
||||
g_pThreadIdMutex = new MutexImpl_Win32(NULL);
|
||||
g_pThreadIdMutex = new MutexImpl_Win32(nullptr);
|
||||
}
|
||||
|
||||
static uint64_t g_ThreadIds[MAX_THREADS];
|
||||
@@ -26,7 +26,7 @@ HANDLE Win32ThreadIdToHandle( uint64_t iID )
|
||||
return g_ThreadHandles[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ThreadImpl_Win32::Halt( bool Kill )
|
||||
@@ -55,7 +55,7 @@ int ThreadImpl_Win32::Wait()
|
||||
GetExitCodeThread( ThreadHandle, &ret );
|
||||
|
||||
CloseHandle( ThreadHandle );
|
||||
ThreadHandle = NULL;
|
||||
ThreadHandle = nullptr;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ static DWORD WINAPI StartThread( LPVOID pData )
|
||||
{
|
||||
if( g_ThreadIds[i] == RageThread::GetCurrentThreadID() )
|
||||
{
|
||||
g_ThreadHandles[i] = NULL;
|
||||
g_ThreadHandles[i] = nullptr;
|
||||
g_ThreadIds[i] = 0;
|
||||
break;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ ThreadImpl *MakeThisThread()
|
||||
// LOG->Warn( werr_ssprintf( GetLastError(), "DuplicateHandle(%p, %p) failed",
|
||||
// CurProc, GetCurrentThread() ) );
|
||||
|
||||
thread->ThreadHandle = NULL;
|
||||
thread->ThreadHandle = nullptr;
|
||||
}
|
||||
|
||||
thread->ThreadId = GetCurrentThreadId();
|
||||
@@ -160,9 +160,9 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
thread->m_pFunc = pFunc;
|
||||
thread->m_pData = pData;
|
||||
|
||||
thread->ThreadHandle = CreateThread( NULL, 0, &StartThread, thread, CREATE_SUSPENDED, &thread->ThreadId );
|
||||
thread->ThreadHandle = CreateThread( nullptr, 0, &StartThread, thread, CREATE_SUSPENDED, &thread->ThreadId );
|
||||
*piThreadID = (uint64_t) thread->ThreadId;
|
||||
ASSERT_M( thread->ThreadHandle != NULL, ssprintf("%s", werr_ssprintf(GetLastError(), "CreateThread").c_str() ) );
|
||||
ASSERT_M( thread->ThreadHandle != nullptr, ssprintf("%s", werr_ssprintf(GetLastError(), "CreateThread").c_str() ) );
|
||||
|
||||
int slot = GetOpenSlot( thread->ThreadId );
|
||||
g_ThreadHandles[slot] = thread->ThreadHandle;
|
||||
@@ -177,8 +177,8 @@ ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThre
|
||||
MutexImpl_Win32::MutexImpl_Win32( RageMutex *pParent ):
|
||||
MutexImpl( pParent )
|
||||
{
|
||||
mutex = CreateMutex( NULL, false, NULL );
|
||||
ASSERT_M( mutex != NULL, werr_ssprintf(GetLastError(), "CreateMutex") );
|
||||
mutex = CreateMutex( nullptr, false, nullptr );
|
||||
ASSERT_M( mutex != nullptr, werr_ssprintf(GetLastError(), "CreateMutex") );
|
||||
}
|
||||
|
||||
MutexImpl_Win32::~MutexImpl_Win32()
|
||||
@@ -188,7 +188,7 @@ MutexImpl_Win32::~MutexImpl_Win32()
|
||||
|
||||
static bool SimpleWaitForSingleObject( HANDLE h, DWORD ms )
|
||||
{
|
||||
ASSERT( h != NULL );
|
||||
ASSERT( h != nullptr );
|
||||
|
||||
DWORD ret = WaitForSingleObject( h, ms );
|
||||
switch( ret )
|
||||
@@ -266,9 +266,9 @@ EventImpl_Win32::EventImpl_Win32( MutexImpl_Win32 *pParent )
|
||||
{
|
||||
m_pParent = pParent;
|
||||
m_iNumWaiting = 0;
|
||||
m_WakeupSema = CreateSemaphore( NULL, 0, 0x7fffffff, NULL );
|
||||
m_WakeupSema = CreateSemaphore( nullptr, 0, 0x7fffffff, nullptr );
|
||||
InitializeCriticalSection( &m_iNumWaitingLock );
|
||||
m_WaitersDone = CreateEvent( NULL, FALSE, FALSE, NULL );
|
||||
m_WaitersDone = CreateEvent( nullptr, FALSE, FALSE, nullptr );
|
||||
}
|
||||
|
||||
EventImpl_Win32::~EventImpl_Win32()
|
||||
@@ -356,7 +356,7 @@ bool EventImpl_Win32::Wait( RageTimer *pTimeout )
|
||||
LeaveCriticalSection( &m_iNumWaitingLock );
|
||||
|
||||
unsigned iMilliseconds = INFINITE;
|
||||
if( pTimeout != NULL )
|
||||
if( pTimeout != nullptr )
|
||||
{
|
||||
float fSecondsInFuture = -pTimeout->Ago();
|
||||
iMilliseconds = (unsigned) max( 0, int( fSecondsInFuture * 1000 ) );
|
||||
@@ -435,7 +435,7 @@ EventImpl *MakeEvent( MutexImpl *pMutex )
|
||||
|
||||
SemaImpl_Win32::SemaImpl_Win32( int iInitialValue )
|
||||
{
|
||||
sem = CreateSemaphore( NULL, iInitialValue, 999999999, NULL );
|
||||
sem = CreateSemaphore( nullptr, iInitialValue, 999999999, nullptr );
|
||||
m_iCounter = iInitialValue;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ SemaImpl_Win32::~SemaImpl_Win32()
|
||||
void SemaImpl_Win32::Post()
|
||||
{
|
||||
++m_iCounter;
|
||||
ReleaseSemaphore( sem, 1, NULL );
|
||||
ReleaseSemaphore( sem, 1, nullptr );
|
||||
}
|
||||
|
||||
bool SemaImpl_Win32::Wait()
|
||||
|
||||
Reference in New Issue
Block a user