diff options
author | Chris Robinson <[email protected]> | 2014-04-16 08:21:45 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-04-16 08:21:45 -0700 |
commit | 8cc3d05949b9c2750a5460488cac58c82174e85c (patch) | |
tree | 70a70b17cfb218e25cb2f48145b7140ea1bb24ab | |
parent | 2149ccd985427e1ad0db6d8e3e3769a1370f92f9 (diff) |
Fix some almtx_ return values
-rw-r--r-- | Alc/threads.c | 17 | ||||
-rw-r--r-- | OpenAL32/Include/threads.h | 32 |
2 files changed, 36 insertions, 13 deletions
diff --git a/Alc/threads.c b/Alc/threads.c index 5361e649..1dece664 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -184,7 +184,10 @@ int almtx_timedlock(almtx_t *mtx, const struct timespec *ts) { DWORD now = timeGetTime(); if(now-start >= timelen) + { + ret = althrd_timedout; break; + } SwitchToThread(); } @@ -331,12 +334,20 @@ void almtx_destroy(almtx_t *mtx) int almtx_timedlock(almtx_t *mtx, const struct timespec *ts) { + int ret; + if(!mtx || !ts) return althrd_error; - if(pthread_mutex_timedlock(mtx, ts) != 0) - return althrd_busy; - return althrd_success; + ret = pthread_mutex_timedlock(mtx, ts); + switch(ret) + { + case 0: return althrd_success; + case ETIMEDOUT: return althrd_timedout; + case EAGAIN: + case EBUSY: return althrd_busy; + } + return althrd_error; } #endif 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 |