commit 63adae25d5c89753d3a2c812e6218fe3af0393cc parent e08cb870bb2bd1e2e74d488b851314fa88a96606 Author: Michael Savage <mikejsavage@gmail.com> Date: Thu Jan 19 00:06:30 +0200 linux_semaphore.h -> unix_semaphore.h Diffstat:
linux_semaphore.h | | | 23 | ----------------------- |
platform_semaphore.h | | | 2 | +- |
unix_semaphore.h | | | 23 | +++++++++++++++++++++++ |
diff --git a/linux_semaphore.h b/linux_semaphore.h @@ -1,23 +0,0 @@ -#pragma once - -#include <err.h> -#include <semaphore.h> - -struct Semaphore { - sem_t sem; -}; - -inline void semaphore_init( Semaphore * sem ) { - int ok = sem_init( &sem->sem, 0, 0 ); - if( ok == -1 ) { - err( 1, "sem_init failed" ); - } -} - -inline void semaphore_signal( Semaphore * sem ) { - sem_post( &sem->sem ); -} - -inline void semaphore_wait( Semaphore * sem ) { - sem_wait( &sem->sem ); -} diff --git a/platform_semaphore.h b/platform_semaphore.h @@ -7,7 +7,7 @@ #elif PLATFORM_OSX #include "darwin_semaphore.h" #elif PLATFORM_UNIX -#include "linux_semaphore.h" +#include "unix_semaphore.h" #else #error new platform #endif diff --git a/unix_semaphore.h b/unix_semaphore.h @@ -0,0 +1,23 @@ +#pragma once + +#include <err.h> +#include <semaphore.h> + +struct Semaphore { + sem_t sem; +}; + +inline void semaphore_init( Semaphore * sem ) { + int ok = sem_init( &sem->sem, 0, 0 ); + if( ok == -1 ) { + err( 1, "sem_init failed" ); + } +} + +inline void semaphore_signal( Semaphore * sem ) { + sem_post( &sem->sem ); +} + +inline void semaphore_wait( Semaphore * sem ) { + sem_wait( &sem->sem ); +}