diff options
author | Philippe Houdoin <[email protected]> | 2004-08-14 09:48:57 +0000 |
---|---|---|
committer | Philippe Houdoin <[email protected]> | 2004-08-14 09:48:57 +0000 |
commit | b4907820c23887e3f2447586d925cb52fd38ea41 (patch) | |
tree | 1e0c0e717f8b8f5118e7090f8d4f8a309164d31d /src/mesa/glapi/glthread.h | |
parent | 4b3be4d8be05da426e9f9b06d6d8317e86e70d68 (diff) |
BeOS's _glthread_DECLARE_STATIC_MUTEX() couldn't be used outside a function
because she called create_sem(). Now the semaphore creation is made at first
_glthread_LOCK_MUTEX() call.
Diffstat (limited to 'src/mesa/glapi/glthread.h')
-rw-r--r-- | src/mesa/glapi/glthread.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h index 283d549df07..6dc136e975e 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mesa/glapi/glthread.h @@ -65,7 +65,8 @@ #define GLTHREAD_H -#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(XTHREADS) +#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ + defined(XTHREADS) || defined(BEOS_THREADS) #define THREADS #endif @@ -232,6 +233,7 @@ typedef xmutex_rec _glthread_Mutex; * BeOS threads. R5.x required. */ #ifdef BEOS_THREADS + #include <kernel/OS.h> #include <support/TLS.h> @@ -249,11 +251,12 @@ typedef struct { } benaphore; typedef benaphore _glthread_Mutex; -#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, -create_sem(0, #name"_benaphore") } -#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0 -#define _glthread_LOCK_MUTEX(name) if((atomic_add(&(name.lock), 1)) >= 1) acquire_sem(name.sem) -#define _glthread_UNLOCK_MUTEX(name) if((atomic_add(&(name.lock), -1)) > 1) release_sem(name.sem) +#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, 0 } +#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0 +#define _glthread_DESTROY_MUTEX(name) delete_sem(name.sem), name.lock = 0 +#define _glthread_LOCK_MUTEX(name) if (name.sem == 0) _glthread_INIT_MUTEX(name); \ + if (atomic_add(&(name.lock), 1) >= 1) acquire_sem(name.sem) +#define _glthread_UNLOCK_MUTEX(name) if (atomic_add(&(name.lock), -1) > 1) release_sem(name.sem) #endif /* BEOS_THREADS */ |