diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/glapi/glthread.c | 42 | ||||
-rw-r--r-- | src/mesa/glapi/glthread.h | 35 |
2 files changed, 75 insertions, 2 deletions
diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c index 16b3336b9f4..778fa4873c8 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mesa/glapi/glthread.c @@ -1,4 +1,4 @@ -/* $Id: glthread.c,v 1.8 2001/03/12 00:48:38 gareth Exp $ */ +/* $Id: glthread.c,v 1.9 2001/11/12 23:50:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -292,6 +292,46 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) +/* + * BeOS threads + */ +#ifdef BEOS_THREADS + +unsigned long +_glthread_GetID(void) +{ + return (unsigned long) find_thread(NULL); +} + +void +_glthread_InitTSD(_glthread_TSD *tsd) +{ + tsd->key = tls_allocate(); + tsd->initMagic = INIT_MAGIC; +} + +void * +_glthread_GetTSD(_glthread_TSD *tsd) +{ + if (tsd->initMagic != (int) INIT_MAGIC) { + _glthread_InitTSD(tsd); + } + return tls_get(tsd->key); +} + +void +_glthread_SetTSD(_glthread_TSD *tsd, void *ptr) +{ + if (tsd->initMagic != (int) INIT_MAGIC) { + _glthread_InitTSD(tsd); + } + tls_set(tsd->key, ptr); +} + +#endif /* BEOS_THREADS */ + + + #else /* THREADS */ diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h index 639c46e427e..9ac51aef821 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mesa/glapi/glthread.h @@ -1,4 +1,4 @@ -/* $Id: glthread.h,v 1.8 2001/03/12 00:48:38 gareth Exp $ */ +/* $Id: glthread.h,v 1.9 2001/11/12 23:50:12 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -202,6 +202,39 @@ typedef xmutex_rec _glthread_Mutex; +/* + * BeOS threads. R5.x required. + */ +#ifdef BEOS_THREADS +#include <kernel/OS.h> +#include <support/TLS.h> + +typedef struct { + int32 key; + int initMagic; +} _glthread_TSD; + +typedef thread_id _glthread_Thread; + +/* Use Benaphore, aka speeder semaphore */ +typedef struct { + int32 lock; + sem_id sem; +} 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) + +#endif /* BEOS_THREADS */ + + #ifndef THREADS |