From 4ec31291c0de9334f6715edc13bf2d28ea884eb0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 1 Feb 2018 17:37:31 -0800 Subject: Add semaphore functions to the thread API wrapper --- common/threads.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common/threads.h') diff --git a/common/threads.h b/common/threads.h index 87b8a6f5..a8096546 100644 --- a/common/threads.h +++ b/common/threads.h @@ -57,6 +57,7 @@ typedef CONDITION_VARIABLE alcnd_t; #else typedef struct { void *Ptr; } alcnd_t; #endif +typedef HANDLE alsem_t; typedef DWORD altss_t; typedef LONG alonce_flag; @@ -127,11 +128,13 @@ inline int altss_set(altss_t tss_id, void *val) #include #include #include +#include typedef pthread_t althrd_t; typedef pthread_mutex_t almtx_t; typedef pthread_cond_t alcnd_t; +typedef sem_t alsem_t; typedef pthread_key_t altss_t; typedef pthread_once_t alonce_flag; @@ -233,6 +236,12 @@ int alcnd_wait(alcnd_t *cond, almtx_t *mtx); int alcnd_timedwait(alcnd_t *cond, almtx_t *mtx, const struct timespec *time_point); void alcnd_destroy(alcnd_t *cond); +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_timedwait(alsem_t *sem, const struct timespec *time_point); + int altss_create(altss_t *tss_id, altss_dtor_t callback); void altss_delete(altss_t tss_id); -- cgit v1.2.3