From 93d83286a4e801ad30132972cfe183a9eabf2c9c Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 30 May 2016 11:07:19 -0300 Subject: [PATCH] Ajustes para eliminar problemas que apareceram na atualização do gcc para windows. --- src/classlib/private.h | 103 ++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------- 1 file changed, 48 insertions(+), 55 deletions(-) diff --git a/src/classlib/private.h b/src/classlib/private.h index 6f670ae..ee2055e 100644 --- a/src/classlib/private.h +++ b/src/classlib/private.h @@ -34,79 +34,72 @@ #include #include - #if __cplusplus < 201103L + #if defined(_WIN32) - #define nullptr NULL - - - #ifdef _WIN32 - - class recursive_mutex { - private: - HANDLE hMutex; + class recursive_mutex { + private: + HANDLE hMutex; - public: - recursive_mutex() { - hMutex = CreateMutex(NULL,FALSE,NULL); - }; - - ~recursive_mutex() { - CloseHandle(hMutex); - }; - - void lock(void) { - WaitForSingleObject(hMutex,INFINITE); - }; + public: + recursive_mutex() { + hMutex = CreateMutex(NULL,FALSE,NULL); + }; - void unlock(void) { - ReleaseMutex(hMutex); - }; + ~recursive_mutex() { + CloseHandle(hMutex); + }; - bool try_lock(void) { - if(WaitForSingleObject(hMutex,1) == WAIT_OBJECT_0) - return true; - return false; - }; + void lock(void) { + WaitForSingleObject(hMutex,INFINITE); }; - #else + void unlock(void) { + ReleaseMutex(hMutex); + }; - class recursive_mutex { - private: - pthread_mutex_t mtx; - pthread_mutexattr_t mtxAttr; + bool try_lock(void) { + if(WaitForSingleObject(hMutex,1) == WAIT_OBJECT_0) + return true; + return false; + }; + }; - public: - recursive_mutex() { + #elif __cplusplus < 201103L - memset(&mtx,0,sizeof(mtx)); - memset(&mtxAttr,0,sizeof(mtxAttr)); + #define nullptr NULL - pthread_mutexattr_init(&mtxAttr); - pthread_mutexattr_settype(&mtxAttr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&mtx, &mtxAttr); - }; + class recursive_mutex { + private: + pthread_mutex_t mtx; + pthread_mutexattr_t mtxAttr; - ~recursive_mutex() { - pthread_mutex_destroy(&mtx); - }; + public: + recursive_mutex() { - void lock(void) { - pthread_mutex_lock(&mtx); - }; + memset(&mtx,0,sizeof(mtx)); + memset(&mtxAttr,0,sizeof(mtxAttr)); - void unlock(void) { - pthread_mutex_unlock(&mtx); - }; + pthread_mutexattr_init(&mtxAttr); + pthread_mutexattr_settype(&mtxAttr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&mtx, &mtxAttr); + }; - bool try_lock(void) { - return pthread_mutex_trylock(&mtx) == 0; - }; + ~recursive_mutex() { + pthread_mutex_destroy(&mtx); }; + void lock(void) { + pthread_mutex_lock(&mtx); + }; + void unlock(void) { + pthread_mutex_unlock(&mtx); + }; - #endif // _WIN32 + bool try_lock(void) { + return pthread_mutex_trylock(&mtx) == 0; + }; + }; #else -- libgit2 0.21.2