From c2da83dea86f57e3095a704ef1f9c7b01852cd03 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 27 Nov 2018 14:50:41 -0800 Subject: Avoid alsem* wrappers for al::semaphore --- common/threads.h | 57 ++++++++++++-------------------------------------------- 1 file changed, 12 insertions(+), 45 deletions(-) (limited to 'common/threads.h') diff --git a/common/threads.h b/common/threads.h index 03a3899c..7eb2d608 100644 --- a/common/threads.h +++ b/common/threads.h @@ -3,6 +3,8 @@ #include +#include + #if defined(__GNUC__) && defined(__i386__) /* force_align_arg_pointer is required for proper function arguments aligning * when SSE code is used. Some systems (Windows, QNX) do not guarantee our @@ -13,61 +15,28 @@ #define FORCE_ALIGN #endif -#ifdef __cplusplus -#include - -extern "C" { -#endif - -enum { - althrd_success = 0, - althrd_error, - althrd_nomem, - althrd_timedout, - althrd_busy -}; - - #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include - -typedef HANDLE alsem_t; - -#else - -#include -#include -#include -#ifdef __APPLE__ +#elif defined(__APPLE__) #include -#else /* !__APPLE__ */ +#else #include -#endif /* __APPLE__ */ - -#ifdef __APPLE__ -typedef dispatch_semaphore_t alsem_t; -#else /* !__APPLE__ */ -typedef sem_t alsem_t; -#endif /* __APPLE__ */ - #endif void althrd_setname(const char *name); -int alsem_init(alsem_t *sem, unsigned int initial); -void alsem_destroy(alsem_t *sem); -int alsem_post(alsem_t *sem); -int alsem_wait(alsem_t *sem); -int alsem_trywait(alsem_t *sem); - -#ifdef __cplusplus -} // extern "C" - namespace al { class semaphore { - alsem_t mSem; +#ifdef _WIN32 + using native_type = HANDLE; +#elif defined(__APPLE__) + using native_type = dispatch_semaphore_t; +#else + using native_type = sem_t; +#endif + native_type mSem; public: semaphore(unsigned int initial=0); @@ -83,6 +52,4 @@ public: } // namespace al -#endif - #endif /* AL_THREADS_H */ -- cgit v1.2.3