diff options
Diffstat (limited to 'platform/osx/sem_osx.cpp')
-rw-r--r-- | platform/osx/sem_osx.cpp | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/platform/osx/sem_osx.cpp b/platform/osx/sem_osx.cpp index ca710d8b1e..069e3a5153 100644 --- a/platform/osx/sem_osx.cpp +++ b/platform/osx/sem_osx.cpp @@ -28,11 +28,10 @@ /*************************************************************************/ #include "sem_osx.h" -#include <unistd.h> #include <fcntl.h> +#include <unistd.h> -void cgsem_init(cgsem_t *cgsem) -{ +void cgsem_init(cgsem_t *cgsem) { int flags, fd, i; pipe(cgsem->pipefd); @@ -47,31 +46,26 @@ void cgsem_init(cgsem_t *cgsem) } } -void cgsem_post(cgsem_t *cgsem) -{ +void cgsem_post(cgsem_t *cgsem) { const char buf = 1; write(cgsem->pipefd[1], &buf, 1); } -void cgsem_wait(cgsem_t *cgsem) -{ +void cgsem_wait(cgsem_t *cgsem) { char buf; read(cgsem->pipefd[0], &buf, 1); } -void cgsem_destroy(cgsem_t *cgsem) -{ +void cgsem_destroy(cgsem_t *cgsem) { close(cgsem->pipefd[1]); close(cgsem->pipefd[0]); } - #include "os/memory.h" #include <errno.h> - Error SemaphoreOSX::wait() { cgsem_wait(&sem); @@ -89,15 +83,14 @@ int SemaphoreOSX::get() const { return 0; } - Semaphore *SemaphoreOSX::create_semaphore_osx() { - return memnew( SemaphoreOSX ); + return memnew(SemaphoreOSX); } void SemaphoreOSX::make_default() { - create_func=create_semaphore_osx; + create_func = create_semaphore_osx; } SemaphoreOSX::SemaphoreOSX() { @@ -105,11 +98,7 @@ SemaphoreOSX::SemaphoreOSX() { cgsem_init(&sem); } - SemaphoreOSX::~SemaphoreOSX() { cgsem_destroy(&sem); } - - - |