summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-07-21 15:19:48 +0200
committermadmaxoft <github@xoft.cz>2014-07-21 17:40:43 +0200
commit93d29555e58df172bafba530afbc593c16ec66a3 (patch)
tree681174bef875ffd821d7d87602f2063251f25673 /src/OSSupport
parentStyle: Normalized spaces after if, for and while. (diff)
downloadcuberite-93d29555e58df172bafba530afbc593c16ec66a3.tar
cuberite-93d29555e58df172bafba530afbc593c16ec66a3.tar.gz
cuberite-93d29555e58df172bafba530afbc593c16ec66a3.tar.bz2
cuberite-93d29555e58df172bafba530afbc593c16ec66a3.tar.lz
cuberite-93d29555e58df172bafba530afbc593c16ec66a3.tar.xz
cuberite-93d29555e58df172bafba530afbc593c16ec66a3.tar.zst
cuberite-93d29555e58df172bafba530afbc593c16ec66a3.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/Errors.cpp12
-rw-r--r--src/OSSupport/Event.cpp4
-rw-r--r--src/OSSupport/Semaphore.cpp26
-rw-r--r--src/OSSupport/Semaphore.h2
-rw-r--r--src/OSSupport/Sleep.cpp2
-rw-r--r--src/OSSupport/Sleep.h2
-rw-r--r--src/OSSupport/Thread.cpp32
-rw-r--r--src/OSSupport/Thread.h8
8 files changed, 44 insertions, 44 deletions
diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp
index 02de28e4e..9401ec257 100644
--- a/src/OSSupport/Errors.cpp
+++ b/src/OSSupport/Errors.cpp
@@ -3,7 +3,7 @@
#include "Errors.h"
-AString GetOSErrorString( int a_ErrNo )
+AString GetOSErrorString( int a_ErrNo)
{
char buffer[ 1024 ];
AString Out;
@@ -22,10 +22,10 @@ AString GetOSErrorString( int a_ErrNo )
// According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r():
- #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r()
+ #if !defined(__APPLE__) && ( _GNU_SOURCE) && !defined(ANDROID_NDK) // GNU version of strerror_r()
- char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
- if (res != NULL )
+ char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
+ if (res != NULL)
{
Printf(Out, "%d: %s", a_ErrNo, res);
return Out;
@@ -33,8 +33,8 @@ AString GetOSErrorString( int a_ErrNo )
#else // XSI version of strerror_r():
- int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
- if (res == 0 )
+ int res = strerror_r( errno, buffer, ARRAYCOUNT(buffer));
+ if (res == 0)
{
Printf(Out, "%d: %s", a_ErrNo, buffer);
return Out;
diff --git a/src/OSSupport/Event.cpp b/src/OSSupport/Event.cpp
index 72bce4c3c..74f823216 100644
--- a/src/OSSupport/Event.cpp
+++ b/src/OSSupport/Event.cpp
@@ -32,7 +32,7 @@ cEvent::cEvent(void)
AString EventName;
Printf(EventName, "cEvent%p", this);
- m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0 );
+ m_Event = sem_open(EventName.c_str(), O_CREAT, 777, 0);
if (m_Event == SEM_FAILED)
{
AString error = GetOSErrorString(errno);
@@ -90,7 +90,7 @@ void cEvent::Wait(void)
}
#else
int res = sem_wait(m_Event);
- if (res != 0 )
+ if (res != 0)
{
AString error = GetOSErrorString(errno);
LOGWARN("cEvent: waiting for the event failed: %i, err = %s. Continuing, but server may be unstable.", res, error.c_str());
diff --git a/src/OSSupport/Semaphore.cpp b/src/OSSupport/Semaphore.cpp
index cb9ccc83b..c1fc7d9c7 100644
--- a/src/OSSupport/Semaphore.cpp
+++ b/src/OSSupport/Semaphore.cpp
@@ -5,9 +5,9 @@
-cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */ )
+cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /* = 0 */)
#ifndef _WIN32
- : m_bNamed( false )
+ : m_bNamed( false)
#endif
{
#ifndef _WIN32
@@ -20,15 +20,15 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
m_bNamed = true;
AString Name;
- Printf(Name, "cSemaphore%p", this );
+ Printf(Name, "cSemaphore%p", this);
m_Handle = sem_open(Name.c_str(), O_CREAT, 777, a_InitialCount);
- if (m_Handle == SEM_FAILED )
+ if (m_Handle == SEM_FAILED)
{
- LOG("ERROR: Could not create Semaphore. (%i)", errno );
+ LOG("ERROR: Could not create Semaphore. (%i)", errno);
}
else
{
- if (sem_unlink(Name.c_str()) != 0 )
+ if (sem_unlink(Name.c_str()) != 0)
{
LOG("ERROR: Could not unlink cSemaphore. (%i)", errno);
}
@@ -51,18 +51,18 @@ cSemaphore::cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount /*
cSemaphore::~cSemaphore()
{
#ifdef _WIN32
- CloseHandle( m_Handle );
+ CloseHandle( m_Handle);
#else
- if (m_bNamed )
+ if (m_bNamed)
{
- if (sem_close( (sem_t*)m_Handle ) != 0 )
+ if (sem_close( (sem_t*)m_Handle) != 0)
{
LOG("ERROR: Could not close cSemaphore. (%i)", errno);
}
}
else
{
- sem_destroy( (sem_t*)m_Handle );
+ sem_destroy( (sem_t*)m_Handle);
delete (sem_t*)m_Handle;
}
m_Handle = 0;
@@ -77,7 +77,7 @@ cSemaphore::~cSemaphore()
void cSemaphore::Wait()
{
#ifndef _WIN32
- if (sem_wait( (sem_t*)m_Handle ) != 0)
+ if (sem_wait( (sem_t*)m_Handle) != 0)
{
LOG("ERROR: Could not wait for cSemaphore. (%i)", errno);
}
@@ -93,12 +93,12 @@ void cSemaphore::Wait()
void cSemaphore::Signal()
{
#ifndef _WIN32
- if (sem_post( (sem_t*)m_Handle ) != 0 )
+ if (sem_post( (sem_t*)m_Handle) != 0)
{
LOG("ERROR: Could not signal cSemaphore. (%i)", errno);
}
#else
- ReleaseSemaphore( m_Handle, 1, NULL );
+ ReleaseSemaphore( m_Handle, 1, NULL);
#endif
}
diff --git a/src/OSSupport/Semaphore.h b/src/OSSupport/Semaphore.h
index ac574e8a1..adc531ed8 100644
--- a/src/OSSupport/Semaphore.h
+++ b/src/OSSupport/Semaphore.h
@@ -3,7 +3,7 @@
class cSemaphore
{
public:
- cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0 );
+ cSemaphore( unsigned int a_MaxCount, unsigned int a_InitialCount = 0);
~cSemaphore();
void Wait();
diff --git a/src/OSSupport/Sleep.cpp b/src/OSSupport/Sleep.cpp
index 223a8b855..297d668d7 100644
--- a/src/OSSupport/Sleep.cpp
+++ b/src/OSSupport/Sleep.cpp
@@ -9,7 +9,7 @@
-void cSleep::MilliSleep( unsigned int a_MilliSeconds )
+void cSleep::MilliSleep( unsigned int a_MilliSeconds)
{
#ifdef _WIN32
Sleep(a_MilliSeconds); // Don't tick too much
diff --git a/src/OSSupport/Sleep.h b/src/OSSupport/Sleep.h
index 0ec0adf9d..57d29682c 100644
--- a/src/OSSupport/Sleep.h
+++ b/src/OSSupport/Sleep.h
@@ -3,5 +3,5 @@
class cSleep
{
public:
- static void MilliSleep( unsigned int a_MilliSeconds );
+ static void MilliSleep( unsigned int a_MilliSeconds);
};
diff --git a/src/OSSupport/Thread.cpp b/src/OSSupport/Thread.cpp
index 811e7cb21..faaccce96 100644
--- a/src/OSSupport/Thread.cpp
+++ b/src/OSSupport/Thread.cpp
@@ -47,13 +47,13 @@ static void SetThreadName(DWORD dwThreadID, const char * threadName)
-cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */ )
- : m_ThreadFunction( a_ThreadFunction )
- , m_Param( a_Param )
- , m_Event( new cEvent() )
- , m_StopEvent( 0 )
+cThread::cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName /* = 0 */)
+ : m_ThreadFunction( a_ThreadFunction)
+ , m_Param( a_Param)
+ , m_Event( new cEvent())
+ , m_StopEvent( 0)
{
- if (a_ThreadName )
+ if (a_ThreadName)
{
m_ThreadName.assign(a_ThreadName);
}
@@ -68,7 +68,7 @@ cThread::~cThread()
delete m_Event;
m_Event = NULL;
- if (m_StopEvent )
+ if (m_StopEvent)
{
m_StopEvent->Wait();
delete m_StopEvent;
@@ -80,14 +80,14 @@ cThread::~cThread()
-void cThread::Start( bool a_bWaitOnDelete /* = true */ )
+void cThread::Start( bool a_bWaitOnDelete /* = true */)
{
- if (a_bWaitOnDelete )
+ if (a_bWaitOnDelete)
m_StopEvent = new cEvent();
#ifndef _WIN32
pthread_t SndThread;
- if (pthread_create( &SndThread, NULL, MyThread, this) )
+ if (pthread_create( &SndThread, NULL, MyThread, this))
LOGERROR("ERROR: Could not create thread!");
#else
DWORD ThreadID = 0;
@@ -96,8 +96,8 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ )
, (LPTHREAD_START_ROUTINE) MyThread // function name
, this // parameters
, 0 // flags
- , &ThreadID ); // thread id
- CloseHandle( hThread );
+ , &ThreadID); // thread id
+ CloseHandle( hThread);
#ifdef _MSC_VER
if (!m_ThreadName.empty())
@@ -116,9 +116,9 @@ void cThread::Start( bool a_bWaitOnDelete /* = true */ )
#ifdef _WIN32
-unsigned long cThread::MyThread(void* a_Param )
+unsigned long cThread::MyThread(void* a_Param)
#else
-void *cThread::MyThread( void *a_Param )
+void *cThread::MyThread( void *a_Param)
#endif
{
cThread* self = (cThread*)a_Param;
@@ -130,8 +130,8 @@ void *cThread::MyThread( void *a_Param )
// Set event to let other thread know this thread has been created and it's safe to delete the cThread object
self->m_Event->Set();
- ThreadFunction( ThreadParam );
+ ThreadFunction( ThreadParam);
- if (StopEvent ) StopEvent->Set();
+ if (StopEvent) StopEvent->Set();
return 0;
}
diff --git a/src/OSSupport/Thread.h b/src/OSSupport/Thread.h
index 4153b2427..7ee352c82 100644
--- a/src/OSSupport/Thread.h
+++ b/src/OSSupport/Thread.h
@@ -4,18 +4,18 @@ class cThread
{
public:
typedef void (ThreadFunc)(void*);
- cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0 );
+ cThread( ThreadFunc a_ThreadFunction, void* a_Param, const char* a_ThreadName = 0);
~cThread();
- void Start( bool a_bWaitOnDelete = true );
+ void Start( bool a_bWaitOnDelete = true);
void WaitForThread();
private:
ThreadFunc* m_ThreadFunction;
#ifdef _WIN32
- static unsigned long MyThread(void* a_Param );
+ static unsigned long MyThread(void* a_Param);
#else
- static void *MyThread( void *lpParam );
+ static void *MyThread( void *lpParam);
#endif
void* m_Param;