From 8cc3d05949b9c2750a5460488cac58c82174e85c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Apr 2014 08:21:45 -0700 Subject: Fix some almtx_ return values --- OpenAL32/Include/threads.h | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'OpenAL32/Include/threads.h') diff --git a/OpenAL32/Include/threads.h b/OpenAL32/Include/threads.h index 847ade7f..f0ee1b5c 100644 --- a/OpenAL32/Include/threads.h +++ b/OpenAL32/Include/threads.h @@ -6,10 +6,10 @@ enum { althrd_success = 0, - althrd_timeout, - althrd_error, + althrd_nomem, + althrd_timedout, althrd_busy, - althrd_nomem + althrd_error }; enum { @@ -134,9 +134,15 @@ inline int althrd_sleep(const struct timespec *ts, struct timespec *rem) inline int almtx_lock(almtx_t *mtx) { - if(!mtx) return althrd_error; - pthread_mutex_lock(mtx); - return althrd_success; + int ret = EINVAL; + if(mtx != NULL) + ret = pthread_mutex_lock(mtx); + switch(ret) + { + case 0: return althrd_success; + case EAGAIN: return althrd_busy; + } + return althrd_error; } inline int almtx_unlock(almtx_t *mtx) @@ -148,10 +154,16 @@ inline int almtx_unlock(almtx_t *mtx) inline int almtx_trylock(almtx_t *mtx) { - if(!mtx) return althrd_error; - if(pthread_mutex_trylock(mtx) != 0) - return althrd_busy; - return althrd_success; + int ret = EINVAL; + if(mtx != NULL) + ret = pthread_mutex_trylock(mtx); + switch(ret) + { + case 0: return althrd_success; + case EAGAIN: + case EBUSY: return althrd_busy; + } + return althrd_error; } #endif -- cgit v1.2.3