In p_thread.h replace _glthread_* functions with new pipe_* functions.
Remove other old cruft.
struct fenced_buffer_list
{
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
struct pipe_winsys *winsys;
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
assert(fenced_buf->base.base.refcount == 0);
if (fenced_buf->fence) {
struct pipe_winsys *winsys = fenced_list->winsys;
else {
_fenced_buffer_destroy(fenced_buf);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
return;
}
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
if (fenced_buf->fence)
_fenced_buffer_remove(fenced_list, fenced_buf);
if (fence) {
fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE;
_fenced_buffer_add(fenced_buf);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
fenced_list->numDelayed = 0;
- _glthread_INIT_MUTEX(fenced_list->mutex);
+ pipe_mutex_init(fenced_list->mutex);
return fenced_list;
}
fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait)
{
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
_fenced_buffer_list_check_free(fenced_list, wait);
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
}
void
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
{
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
/* Wait on outstanding fences */
while (fenced_list->numDelayed) {
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
#if defined(PIPE_OS_LINUX)
sched_yield();
#endif
_fenced_buffer_list_check_free(fenced_list, 1);
- _glthread_LOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_lock(fenced_list->mutex);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ pipe_mutex_unlock(fenced_list->mutex);
FREE(fenced_list);
}
struct pb_manager *provider;
unsigned usecs;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
struct list_head delayed;
size_t numDelayed;
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
struct pb_cache_manager *mgr = buf->mgr;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
assert(buf->base.base.refcount == 0);
_pb_cache_buffer_list_check_free(mgr);
util_time_add(&buf->start, mgr->usecs, &buf->end);
LIST_ADDTAIL(&buf->head, &mgr->delayed);
++mgr->numDelayed;
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
struct list_head *curr, *next;
struct util_time now;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
buf = NULL;
curr = mgr->delayed.next;
if(buf) {
LIST_DEL(&buf->head);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
++buf->base.base.refcount;
return &buf->base;
}
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
buf = CALLOC_STRUCT(pb_cache_buffer);
if(!buf)
struct list_head *curr, *next;
struct pb_cache_buffer *buf;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
curr = mgr->delayed.next;
next = curr->next;
while(curr != &mgr->delayed) {
curr = next;
next = curr->next;
}
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
mgr->usecs = usecs;
LIST_INITHEAD(&mgr->delayed);
mgr->numDelayed = 0;
- _glthread_INIT_MUTEX(mgr->mutex);
+ pipe_mutex_init(mgr->mutex);
return &mgr->base;
}
{
struct pb_manager base;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
size_t size;
struct mem_block *heap;
assert(buf->base.refcount == 0);
- _glthread_LOCK_MUTEX(mm->mutex);
+ pipe_mutex_lock(mm->mutex);
mmFreeMem(mm_buf->block);
FREE(buf);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
}
if(desc->alignment % (1 << mm->align2))
return NULL;
- _glthread_LOCK_MUTEX(mm->mutex);
+ pipe_mutex_lock(mm->mutex);
mm_buf = CALLOC_STRUCT(mm_buffer);
if (!mm_buf) {
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
return NULL;
}
mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
if(!mm_buf->block) {
FREE(mm_buf);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
return NULL;
}
}
assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
return SUPER(mm_buf);
}
{
struct mm_pb_manager *mm = mm_pb_manager(mgr);
- _glthread_LOCK_MUTEX(mm->mutex);
+ pipe_mutex_lock(mm->mutex);
mmDestroy(mm->heap);
pb_unmap(mm->buffer);
pb_reference(&mm->buffer, NULL);
- _glthread_UNLOCK_MUTEX(mm->mutex);
+ pipe_mutex_unlock(mm->mutex);
FREE(mgr);
}
mm->size = size;
mm->align2 = align2; /* 64-byte alignment */
- _glthread_INIT_MUTEX(mm->mutex);
+ pipe_mutex_init(mm->mutex);
mm->buffer = buffer;
{
struct pb_manager base;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
size_t bufSize;
size_t bufAlign;
assert(pool_buf->base.base.refcount == 0);
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
pool->numFree++;
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
}
struct pool_pb_manager *pool = pool_buf->mgr;
void *map;
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
map = (unsigned char *) pool->map + pool_buf->start;
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
return map;
}
assert(size == pool->bufSize);
assert(pool->bufAlign % desc->alignment == 0);
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
if (pool->numFree == 0) {
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
debug_printf("warning: out of fixed size buffer objects\n");
return NULL;
}
item = pool->free.next;
if (item == &pool->free) {
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
debug_printf("error: fixed size buffer pool corruption\n");
return NULL;
}
LIST_DEL(item);
--pool->numFree;
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
assert(pool_buf->base.base.refcount == 0);
pool_bufmgr_destroy(struct pb_manager *mgr)
{
struct pool_pb_manager *pool = pool_pb_manager(mgr);
- _glthread_LOCK_MUTEX(pool->mutex);
+ pipe_mutex_lock(pool->mutex);
FREE(pool->bufs);
pb_unmap(pool->buffer);
pb_reference(&pool->buffer, NULL);
- _glthread_UNLOCK_MUTEX(pool->mutex);
+ pipe_mutex_unlock(pool->mutex);
FREE(mgr);
}
pool->bufSize = bufSize;
pool->bufAlign = desc->alignment;
- _glthread_INIT_MUTEX(pool->mutex);
+ pipe_mutex_init(pool->mutex);
pool->buffer = provider->create_buffer(provider, numBufs*bufSize, desc);
if (!pool->buffer)
struct list_head head;
unsigned mapCount;
size_t start;
- _glthread_Cond event;
+ pipe_condvar event;
};
struct pb_slab
struct list_head slabs;
struct list_head freeSlabs;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
/**
struct pb_slab_manager *mgr = slab->mgr;
struct list_head *list = &buf->head;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
assert(buf->base.base.refcount == 0);
}
}
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
--buf->mapCount;
if (buf->mapCount == 0)
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
}
buf->slab = slab;
buf->start = i* mgr->bufSize;
buf->mapCount = 0;
- _glthread_INIT_COND(buf->event);
+ pipe_condvar_init(buf->event);
LIST_ADDTAIL(&buf->head, &slab->freeBuffers);
slab->numFree++;
buf++;
if(!pb_check_usage(desc->usage, mgr->desc.usage))
return NULL;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
if (mgr->slabs.next == &mgr->slabs) {
(void) pb_slab_create(mgr);
if (mgr->slabs.next == &mgr->slabs) {
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
return NULL;
}
}
list = slab->freeBuffers.next;
LIST_DELINIT(list);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
++buf->base.base.refcount;
LIST_INITHEAD(&mgr->slabs);
LIST_INITHEAD(&mgr->freeSlabs);
- _glthread_INIT_MUTEX(mgr->mutex);
+ pipe_mutex_init(mgr->mutex);
return &mgr->base;
}
#include <unistd.h>
#include <sys/mman.h>
+#include "pipe/p_thread.h"
#include "util/u_mm.h"
#define EXEC_HEAP_SIZE (10*1024*1024)
-_glthread_DECLARE_STATIC_MUTEX(exec_mutex);
+pipe_static_mutex(exec_mutex);
static struct mem_block *exec_heap = NULL;
static unsigned char *exec_mem = NULL;
struct mem_block *block = NULL;
void *addr = NULL;
- _glthread_LOCK_MUTEX(exec_mutex);
+ pipe_mutex_lock(exec_mutex);
init_heap();
else
debug_printf("rtasm_exec_malloc failed\n");
- _glthread_UNLOCK_MUTEX(exec_mutex);
+ pipe_mutex_unlock(exec_mutex);
return addr;
}
void
rtasm_exec_free(void *addr)
{
- _glthread_LOCK_MUTEX(exec_mutex);
+ pipe_mutex_lock(exec_mutex);
if (exec_heap) {
struct mem_block *block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
mmFreeMem(block);
}
- _glthread_UNLOCK_MUTEX(exec_mutex);
+ pipe_mutex_unlock(exec_mutex);
}
*
**************************************************************************/
+
/**
- * @file
- * Thread
- *
- * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu)
- * and Christoph Poliwoda (poliwoda@volumegraphics.com)
- * Revised by Keith Whitwell
- * Adapted for new gl dispatcher by Brian Paul
- *
- *
- *
- * DOCUMENTATION
- *
- * This thread module exports the following types:
- * _glthread_TSD Thread-specific data area
- * _glthread_Thread Thread datatype
- * _glthread_Mutex Mutual exclusion lock
- *
- * Macros:
- * _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex
- * _glthread_INIT_MUTEX(name) Initialize a mutex
- * _glthread_LOCK_MUTEX(name) Lock a mutex
- * _glthread_UNLOCK_MUTEX(name) Unlock a mutex
- *
- * Functions:
- * _glthread_GetID(v) Get integer thread ID
- * _glthread_InitTSD() Initialize thread-specific data
- * _glthread_GetTSD() Get thread-specific data
- * _glthread_SetTSD() Set thread-specific data
- *
- * If this file is accidentally included by a non-threaded build,
- * it should not cause the build to fail, or otherwise cause problems.
- * In general, it should only be included when needed however.
+ * Thread, mutex, condition var and thread-specific data functions.
*/
-#ifndef _P_THREAD_H_
-#define _P_THREAD_H_
+#ifndef _P_THREAD2_H_
+#define _P_THREAD2_H_
-#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
- defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
- && !defined(THREADS)
-# define THREADS
-#endif
-#ifdef VMS
-#include <GL/vms_x_fix.h>
-#endif
+#include "pipe/p_compiler.h"
-/*
- * POSIX threads. This should be your choice in the Unix world
- * whenever possible. When building with POSIX threads, be sure
- * to enable any compiler flags which will cause the MT-safe
- * libc (if one exists) to be used when linking, as well as any
- * header macros for MT-safe errno, etc. For Solaris, this is the -mt
- * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
- * proper compiling for MT-safe libc etc.
- */
-#if defined(PTHREADS)
-#include <pthread.h> /* POSIX threads headers */
-typedef struct {
- pthread_key_t key;
- int initMagic;
-} _glthread_TSD;
+#if defined(PIPE_OS_LINUX)
-typedef pthread_t _glthread_Thread;
+#include <pthread.h> /* POSIX threads headers */
+#include <stdio.h> /* for perror() */
-typedef pthread_mutex_t _glthread_Mutex;
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER
+typedef pthread_t pipe_thread;
+typedef pthread_mutex_t pipe_mutex;
+typedef pthread_cond_t pipe_condvar;
-#define _glthread_INIT_MUTEX(name) \
- pthread_mutex_init(&(name), NULL)
+#define pipe_static_mutex(mutex) \
+ static pipe_mutex mutex = PTHREAD_MUTEX_INITIALIZER
-#define _glthread_DESTROY_MUTEX(name) \
- pthread_mutex_destroy(&(name))
+#define pipe_mutex_init(mutex) \
+ pthread_mutex_init(&(mutex), NULL)
-#define _glthread_LOCK_MUTEX(name) \
- (void) pthread_mutex_lock(&(name))
+#define pipe_mutex_destroy(mutex) \
+ pthread_mutex_destroy(&(mutex))
-#define _glthread_UNLOCK_MUTEX(name) \
- (void) pthread_mutex_unlock(&(name))
+#define pipe_mutex_lock(mutex) \
+ (void) pthread_mutex_lock(&(mutex))
-typedef pthread_cond_t _glthread_Cond;
+#define pipe_mutex_unlock(mutex) \
+ (void) pthread_mutex_unlock(&(mutex))
-#define _glthread_DECLARE_STATIC_COND(name) \
- static _glthread_Cond name = PTHREAD_COND_INITIALIZER
+#define pipe_static_condvar(mutex) \
+ static pipe_condvar mutex = PTHREAD_COND_INITIALIZER
-#define _glthread_INIT_COND(cond) \
+#define pipe_condvar_init(cond) \
pthread_cond_init(&(cond), NULL)
-#define _glthread_DESTROY_COND(name) \
- pthread_cond_destroy(&(name))
+#define pipe_condvar_destroy(cond) \
+ pthread_cond_destroy(&(cond))
-#define _glthread_COND_WAIT(cond, mutex) \
+#define pipe_condvar_wait(cond, mutex) \
pthread_cond_wait(&(cond), &(mutex))
-#define _glthread_COND_SIGNAL(cond) \
+#define pipe_condvar_signal(cond) \
pthread_cond_signal(&(cond))
-#define _glthread_COND_BROADCAST(cond) \
+#define pipe_condvar_broadcast(cond) \
pthread_cond_broadcast(&(cond))
-#endif /* PTHREADS */
-
-
+#elif defined(PIPE_OS_WINDOWS)
-/*
- * Solaris threads. Use only up to Solaris 2.4.
- * Solaris 2.5 and higher provide POSIX threads.
- * Be sure to compile with -mt on the Solaris compilers, or
- * use -D_REENTRANT if using gcc.
- */
-#ifdef SOLARIS_THREADS
-#include <thread.h>
-
-typedef struct {
- thread_key_t key;
- mutex_t keylock;
- int initMagic;
-} _glthread_TSD;
-
-typedef thread_t _glthread_Thread;
-
-typedef mutex_t _glthread_Mutex;
-
-/* XXX need to really implement mutex-related macros */
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
-#define _glthread_INIT_MUTEX(name) (void) name
-#define _glthread_DESTROY_MUTEX(name) (void) name
-#define _glthread_LOCK_MUTEX(name) (void) name
-#define _glthread_UNLOCK_MUTEX(name) (void) name
-
-#endif /* SOLARIS_THREADS */
-
-
-
-
-/*
- * Windows threads. Should work with Windows NT and 95.
- * IMPORTANT: Link with multithreaded runtime library when THREADS are
- * used!
- */
-#ifdef WIN32_THREADS
#include <windows.h>
-typedef struct {
- DWORD key;
- int initMagic;
-} _glthread_TSD;
-
-typedef HANDLE _glthread_Thread;
+typedef HANDLE pipe_thread;
+typedef CRITICAL_SECTION pipe_mutex;
-typedef CRITICAL_SECTION _glthread_Mutex;
+#define pipe_static_mutex(name) \
+ /*static*/ pipe_mutex name = {0,0,0,0,0,0}
-#define _glthread_DECLARE_STATIC_MUTEX(name) /*static*/ _glthread_Mutex name = {0,0,0,0,0,0}
-#define _glthread_INIT_MUTEX(name) InitializeCriticalSection(&name)
-#define _glthread_DESTROY_MUTEX(name) DeleteCriticalSection(&name)
-#define _glthread_LOCK_MUTEX(name) EnterCriticalSection(&name)
-#define _glthread_UNLOCK_MUTEX(name) LeaveCriticalSection(&name)
+#define pipe_mutex_init(name) \
+ InitializeCriticalSection(&name)
-#endif /* WIN32_THREADS */
+#define pipe_mutex_destroy(name) \
+ DeleteCriticalSection(&name)
+#define pipe_mutex_lock(name) \
+ EnterCriticalSection(&name)
+#define pipe_mutex_unlock(name) \
+ LeaveCriticalSection(&name)
-/*
- * XFree86 has its own thread wrapper, Xthreads.h
- * We wrap it again for GL.
- */
-#ifdef USE_XTHREADS
-#include <X11/Xthreads.h>
-
-typedef struct {
- xthread_key_t key;
- int initMagic;
-} _glthread_TSD;
-
-typedef xthread_t _glthread_Thread;
-
-typedef xmutex_rec _glthread_Mutex;
-
-#ifdef XMUTEX_INITIALIZER
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name = XMUTEX_INITIALIZER
#else
-#define _glthread_DECLARE_STATIC_MUTEX(name) \
- static _glthread_Mutex name
-#endif
-
-#define _glthread_INIT_MUTEX(name) \
- xmutex_init(&(name))
-
-#define _glthread_DESTROY_MUTEX(name) \
- xmutex_clear(&(name))
-
-#define _glthread_LOCK_MUTEX(name) \
- (void) xmutex_lock(&(name))
-
-#define _glthread_UNLOCK_MUTEX(name) \
- (void) xmutex_unlock(&(name))
-
-#endif /* USE_XTHREADS */
-
-
-
-/*
- * 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, 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)
+/** Dummy definitions */
-#endif /* BEOS_THREADS */
+typedef unsigned pipe_thread;
+typedef unsigned pipe_mutex;
+typedef unsigned pipe_condvar;
+typedef unsigned pipe_tsd;
+#define pipe_static_mutex(mutex) \
+ static pipe_mutex mutex = 0
+#define pipe_mutex_init(mutex) \
+ (void) mutex
-#ifndef THREADS
+#define pipe_mutex_destroy(mutex) \
+ (void) mutex
-/*
- * THREADS not defined
- */
-
-typedef unsigned _glthread_TSD;
-
-typedef unsigned _glthread_Thread;
-
-typedef unsigned _glthread_Mutex;
+#define pipe_mutex_lock(mutex) \
+ (void) mutex
-#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
+#define pipe_mutex_unlock(mutex) \
+ (void) mutex
-#define _glthread_INIT_MUTEX(name) (void) name
+#define pipe_static_condvar(condvar) \
+ static _glthread_Cond condvar = 0
-#define _glthread_DESTROY_MUTEX(name) (void) name
+#define pipe_condvar_init(condvar) \
+ (void) condvar
-#define _glthread_LOCK_MUTEX(name) (void) name
+#define pipe_condvar_destroy(condvar) \
+ (void) condvar
-#define _glthread_UNLOCK_MUTEX(name) (void) name
+#define pipe_condvar_wait(condvar, mutex) \
+ (void) condvar
-typedef unsigned _glthread_Cond;
+#define pipe_condvar_signal(condvar) \
+ (void) condvar
-#define _glthread_DECLARE_STATIC_COND(name) static _glthread_Cond name = 0
+#define pipe_condvar_broadcast(condvar) \
+ (void) condvar
-#define _glthread_INIT_COND(name) (void) name
-#define _glthread_DESTROY_COND(name) (void) name
-
-#define _glthread_COND_WAIT(name, mutex) (void) name
-
-#define _glthread_COND_SIGNAL(name) (void) name
-
-#define _glthread_COND_BROADCAST(name) (void) name
-
-#endif /* THREADS */
+#endif /* PIPE_OS_? */
/*
- * Platform independent thread specific data API.
+ * Thread-specific data.
*/
-extern unsigned long
-_glthread_GetID(void);
-
-
-extern void
-_glthread_InitTSD(_glthread_TSD *);
+typedef struct {
+#if defined(PIPE_OS_LINUX)
+ pthread_key_t key;
+#elif defined(PIPE_OS_WINDOWS)
+ DWORD key;
+#endif
+ int initMagic;
+} pipe_tsd;
-extern void *
-_glthread_GetTSD(_glthread_TSD *);
+#define PIPE_TSD_INIT_MAGIC 0xff8adc98
-extern void
-_glthread_SetTSD(_glthread_TSD *, void *);
+static INLINE void
+pipe_tsd_init(pipe_tsd *tsd)
+{
+#if defined(PIPE_OS_LINUX)
+ if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
+ perror("pthread_key_create(): failed to allocate key for thread specific data");
+ exit(-1);
+ }
+#elif defined(PIPE_OS_WINDOWS)
+ assert(0);
+#endif
+ tsd->initMagic = PIPE_TSD_INIT_MAGIC;
+}
+
+static INLINE void *
+pipe_tsd_get(pipe_tsd *tsd)
+{
+ if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
+ pipe_tsd_init(tsd);
+ }
+#if defined(PIPE_OS_LINUX)
+ return pthread_getspecific(tsd->key);
+#elif defined(PIPE_OS_WINDOWS)
+ assert(0);
+ return NULL;
+#else
+ assert(0);
+ return NULL;
+#endif
+}
+
+static INLINE void
+pipe_tsd_set(pipe_tsd *tsd, void *value)
+{
+ if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
+ pipe_tsd_init(tsd);
+ }
+#if defined(PIPE_OS_LINUX)
+ if (pthread_setspecific(tsd->key, value) != 0) {
+ perror("pthread_set_specific() failed");
+ exit(-1);
+ }
+#elif defined(PIPE_OS_WINDOWS)
+ assert(0);
+#else
+ assert(0);
+#endif
+}
-#endif /* _P_THREAD_H_ */
+#endif /* _P_THREAD2_H_ */
#include <xf86drm.h>
#include <stdlib.h>
#include <stdio.h>
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include "errno.h"
#include "ws_dri_bufmgr.h"
#include "string.h"
* driBufferObject mutex - > this rw lock.
*/
-_glthread_DECLARE_STATIC_MUTEX(bmMutex);
-_glthread_DECLARE_STATIC_COND(bmCond);
+pipe_static_mutex(bmMutex);
+pipe_static_condvar(bmCond);
static int kernelReaders = 0;
static int num_buffers = 0;
void driWriteLockKernelBO(void)
{
- _glthread_LOCK_MUTEX(bmMutex);
+ pipe_mutex_lock(bmMutex);
while(kernelReaders != 0)
- _glthread_COND_WAIT(bmCond, bmMutex);
+ pipe_condvar_wait(bmCond, bmMutex);
}
void driWriteUnlockKernelBO(void)
{
- _glthread_UNLOCK_MUTEX(bmMutex);
+ pipe_mutex_unlock(bmMutex);
}
void driReadLockKernelBO(void)
{
- _glthread_LOCK_MUTEX(bmMutex);
+ pipe_mutex_lock(bmMutex);
kernelReaders++;
- _glthread_UNLOCK_MUTEX(bmMutex);
+ pipe_mutex_unlock(bmMutex);
}
void driReadUnlockKernelBO(void)
{
- _glthread_LOCK_MUTEX(bmMutex);
+ pipe_mutex_lock(bmMutex);
if (--kernelReaders == 0)
- _glthread_COND_BROADCAST(bmCond);
- _glthread_UNLOCK_MUTEX(bmMutex);
+ pipe_condvar_broadcast(bmCond);
+ pipe_mutex_unlock(bmMutex);
}
typedef struct _DriBufferObject
{
DriBufferPool *pool;
- _glthread_Mutex mutex;
+ pipe_mutx mutex;
int refCount;
const char *name;
uint64_t flags;
drmBO *ret;
driReadLockKernelBO();
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
assert(buf->private != NULL);
ret = buf->pool->kernel(buf->pool, buf->private);
if (!ret)
BM_CKFATAL(-EINVAL);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
driReadUnlockKernelBO();
return ret;
* that time??
*/
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, &buf->mutex, lazy));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
void *
return buf->userData;
}
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
assert(buf->private != NULL);
retval = buf->pool->map(buf->pool, buf->private, flags, hint,
&buf->mutex, &virtual);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return retval == 0 ? virtual : NULL;
}
return;
assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
unsigned long
assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
ret = buf->pool->offset(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return ret;
}
assert(buf->private != NULL);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
ret = buf->pool->poolOffset(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return ret;
}
assert(buf->private != NULL);
driReadLockKernelBO();
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
ret = buf->pool->flags(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
driReadUnlockKernelBO();
return ret;
}
struct _DriBufferObject *
driBOReference(struct _DriBufferObject *buf)
{
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (++buf->refCount == 1) {
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
BM_CKFATAL(-EINVAL);
}
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return buf;
}
if (!buf)
return;
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
tmp = --buf->refCount;
if (!tmp) {
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
if (buf->private) {
if (buf->createdByReference)
buf->pool->unreference(buf->pool, buf->private);
num_buffers--;
free(buf);
} else
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
assert(!buf->userBuffer); /* XXX just do a memcpy? */
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
pool = buf->pool;
if (pool == NULL && newPool != NULL) {
}
out:
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return retval;
}
assert(!buf->userBuffer); /* XXX just do a memcpy? */
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
DRM_BO_FLAG_WRITE, 0, &buf->mutex,
memcpy((unsigned char *) virtual + offset, data, size);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
}
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
void
assert(!buf->userBuffer); /* XXX just do a memcpy? */
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
DRM_BO_FLAG_READ, 0, &buf->mutex, &virtual));
memcpy(data, (unsigned char *) virtual + offset, size);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
}
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
void
driBOSetReferenced(struct _DriBufferObject *buf,
unsigned long handle)
{
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (buf->private != NULL) {
assert((size_t)"Invalid buffer for setReferenced\n" & 0);
BM_CKFATAL(-EINVAL);
}
buf->createdByReference = TRUE;
buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
int
if (!buf)
return -ENOMEM;
- _glthread_INIT_MUTEX(buf->mutex);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_init(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
buf->refCount = 1;
buf->flags = flags;
buf->hint = hint;
buf->alignment = alignment;
buf->pool = pool;
buf->createdByReference = 0;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
buffers[i] = buf;
}
return 0;
{
int newItem;
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
buf->pool->kernel(buf->pool, buf->private),
flags, mask, itemLoc, node));
if (newItem)
buf->refCount++;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
drmBOList *driGetdrmBOList(struct _DriBufferList *list)
void
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
{
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (buf->pool->fence)
BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
while (curBuf) {
buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
if (buf->pool->validate)
BM_CKFATAL(buf->pool->validate(buf->pool, buf->private, &buf->mutex));
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
curBuf = drmBOListNext(&list->driBuffers, curBuf);
}
}
{
unsigned long size;
- _glthread_LOCK_MUTEX(buf->mutex);
+ pipe_mutex_lock(buf->mutex);
size = buf->pool->size(buf->pool, buf->private);
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return size;
#define _PSB_BUFPOOL_H_
#include <xf86drm.h>
-#include <glthread.h>
+#include "pipe/p_thread.h"
struct _DriFenceObject;
typedef struct _DriBufferPool
{
int fd;
int (*map) (struct _DriBufferPool * pool, void *private,
- unsigned flags, int hint, _glthread_Mutex *mutex,
+ unsigned flags, int hint, pipe_mutex *mutex,
void **virtual);
int (*unmap) (struct _DriBufferPool * pool, void *private);
int (*destroy) (struct _DriBufferPool * pool, void *private);
int (*fence) (struct _DriBufferPool * pool, void *private,
struct _DriFenceObject * fence);
drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
- int (*validate) (struct _DriBufferPool * pool, void *private, _glthread_Mutex *mutex);
- int (*waitIdle) (struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
+ int (*validate) (struct _DriBufferPool * pool, void *private, pipe_mutex *mutex);
+ int (*waitIdle) (struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
int lazy);
int (*setStatus) (struct _DriBufferPool *pool, void *private,
uint64_t flag_diff, uint64_t old_flags);
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, _glthread_Mutex *mutex, void **virtual)
+ int hint, pipe_mutex *mutex, void **virtual)
{
drmBO *buf = (drmBO *) private;
int ret;
}
static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private, _glthread_Mutex *mutex,
+pool_waitIdle(struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
int lazy)
{
drmBO *buf = (drmBO *) private;
#include "ws_dri_fencemgr.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include <xf86mm.h>
#include <string.h>
#include <unistd.h>
/*
* These members are protected by this->mutex
*/
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
int refCount;
drmMMListHead *heads;
int num_fences;
/*
* These members are protected by this->mutex.
*/
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
uint32_t signaled_type;
void *private;
};
if (!tmp)
return NULL;
- _glthread_INIT_MUTEX(tmp->mutex);
- _glthread_LOCK_MUTEX(tmp->mutex);
+ pipe_mutex_init(tmp->mutex);
+ pipe_mutex_lock(tmp->mutex);
tmp->refCount = 1;
tmp->info = *info;
tmp->num_fences = 0;
for (i=0; i<tmp->info.num_classes; ++i) {
DRMINITLISTHEAD(&tmp->heads[i]);
}
- _glthread_UNLOCK_MUTEX(tmp->mutex);
+ pipe_mutex_unlock(tmp->mutex);
return tmp;
out_err:
if (--mgr->refCount == 0)
free(mgr);
else
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
}
void
driFenceMgrUnReference(struct _DriFenceMgr **pMgr)
{
- _glthread_LOCK_MUTEX((*pMgr)->mutex);
+ pipe_mutex_lock((*pMgr)->mutex);
driFenceMgrUnrefUnlock(pMgr);
}
*/
++entry->refCount;
- _glthread_UNLOCK_MUTEX(mgr->mutex);
- _glthread_LOCK_MUTEX(entry->mutex);
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
+ pipe_mutex_lock(entry->mutex);
+ pipe_mutex_lock(mgr->mutex);
prev = list->prev;
* Somebody else removed the entry from the list.
*/
- _glthread_UNLOCK_MUTEX(entry->mutex);
+ pipe_mutex_unlock(entry->mutex);
driFenceUnReferenceLocked(&entry);
return;
}
DRMLISTDELINIT(list);
mgr->info.unreference(mgr, &entry->private);
}
- _glthread_UNLOCK_MUTEX(entry->mutex);
+ pipe_mutex_unlock(entry->mutex);
driFenceUnReferenceLocked(&entry);
list = prev;
}
struct _DriFenceMgr *mgr = fence->mgr;
int ret = 0;
- _glthread_LOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
if ((fence->signaled_type & fence_type) == fence_type)
goto out0;
if (ret)
goto out0;
- _glthread_LOCK_MUTEX(mgr->mutex);
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(mgr->mutex);
+ pipe_mutex_unlock(fence->mutex);
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
fence_type);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
return 0;
out0:
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return ret;
}
{
uint32_t ret;
- _glthread_LOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
ret = fence->signaled_type;
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return ret;
}
int ret = 0;
struct _DriFenceMgr *mgr;
- _glthread_LOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
mgr = fence->mgr;
*signaled = fence->signaled_type;
if ((fence->signaled_type & flush_type) == flush_type)
if ((fence->signaled_type | *signaled) == fence->signaled_type)
goto out0;
- _glthread_LOCK_MUTEX(mgr->mutex);
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_lock(mgr->mutex);
+ pipe_mutex_unlock(fence->mutex);
driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
*signaled);
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
return 0;
out0:
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return ret;
}
struct _DriFenceObject *
driFenceReference(struct _DriFenceObject *fence)
{
- _glthread_LOCK_MUTEX(fence->mgr->mutex);
+ pipe_mutex_lock(fence->mgr->mutex);
++fence->refCount;
- _glthread_UNLOCK_MUTEX(fence->mgr->mutex);
+ pipe_mutex_unlock(fence->mgr->mutex);
return fence;
}
return;
mgr = (*pFence)->mgr;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
++mgr->refCount;
driFenceUnReferenceLocked(pFence);
driFenceMgrUnrefUnlock(&mgr);
return NULL;
}
- _glthread_INIT_MUTEX(fence->mutex);
- _glthread_LOCK_MUTEX(fence->mutex);
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_init(fence->mutex);
+ pipe_mutex_lock(fence->mutex);
+ pipe_mutex_lock(mgr->mutex);
fence->refCount = 1;
DRMLISTADDTAIL(&fence->head, &mgr->heads[fence_class]);
fence->mgr = mgr;
++mgr->refCount;
++mgr->num_fences;
- _glthread_UNLOCK_MUTEX(mgr->mutex);
+ pipe_mutex_unlock(mgr->mutex);
fence->fence_class = fence_class;
fence->fence_type = fence_type;
fence->signaled_type = 0;
memcpy(fence->private, private, private_size);
}
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return fence;
}
#include <stdlib.h>
#include <errno.h>
#include "pipe/p_debug.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include "ws_dri_bufpool.h"
#include "ws_dri_bufmgr.h"
static int
pool_waitIdle(struct _DriBufferPool *pool, void *private,
- _glthread_Mutex *mutex, int lazy)
+ pipe_mutex *mutex, int lazy)
{
return 0;
}
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, _glthread_Mutex *mutex, void **virtual)
+ int hint, pipe_mutex *mutex, void **virtual)
{
*virtual = (void *)((unsigned long *)private + 2);
return 0;
#include "ws_dri_bufpool.h"
#include "ws_dri_fencemgr.h"
#include "ws_dri_bufmgr.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#define DRI_SLABPOOL_ALLOC_RETRIES 100
uint32_t start;
uint32_t fenceType;
int unFenced;
- _glthread_Cond event;
+ pipe_condvar event;
};
struct _DriKernelBO {
uint32_t numDelayed;
struct _DriSlabPool *slabPool;
uint32_t bufSize;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
struct _DriFreeSlabManager {
drmMMListHead timeoutList;
drmMMListHead unCached;
drmMMListHead cached;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
{
struct timeval time;
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
gettimeofday(&time, NULL);
driTimeAdd(&time, &fMan->slabTimeout);
DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
driFreeTimeoutKBOsLocked(fMan, &time);
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
}
/*
size = (size <= slabPool->maxSlabSize) ? size : slabPool->maxSlabSize;
size = (size + slabPool->pageSize - 1) & ~(slabPool->pageSize - 1);
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
kbo = NULL;
DRMLISTDELINIT(&kbo->timeoutHead);
}
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
if (kbo) {
uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
buf->start = i* header->bufSize;
buf->mapCount = 0;
buf->isSlabBuffer = 1;
- _glthread_INIT_COND(buf->event);
+ pipe_condvar_init(buf->event);
DRMLISTADDTAIL(&buf->head, &slab->freeBuffers);
slab->numFree++;
buf++;
drmMMListHead *list;
int count = DRI_SLABPOOL_ALLOC_RETRIES;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
while(header->slabs.next == &header->slabs && count > 0) {
driSlabCheckFreeLocked(header, 0);
if (header->slabs.next != &header->slabs)
break;
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
if (count != DRI_SLABPOOL_ALLOC_RETRIES)
usleep(1);
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
(void) driAllocSlab(header);
count--;
}
list = header->slabs.next;
if (list == &header->slabs) {
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
return NULL;
}
slab = DRMLISTENTRY(struct _DriSlab, list, head);
list = slab->freeBuffers.next;
DRMLISTDELINIT(list);
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
return buf;
}
slab = buf->parent;
header = slab->header;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
buf->unFenced = 0;
buf->mapCount = 0;
driSlabFreeBufferLocked(buf);
}
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
return 0;
}
static int
pool_waitIdle(struct _DriBufferPool *driPool, void *private,
- _glthread_Mutex *mutex, int lazy)
+ pipe_mutex *mutex, int lazy)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
while(buf->unFenced)
- _glthread_COND_WAIT(buf->event, *mutex);
+ pipe_condvar_wait(buf->event, *mutex);
if (!buf->fence)
return 0;
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, _glthread_Mutex *mutex, void **virtual)
+ int hint, pipe_mutex *mutex, void **virtual)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
int busy;
--buf->mapCount;
if (buf->mapCount == 0 && buf->isSlabBuffer)
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
return 0;
}
buf->fenceType = bo->fenceFlags;
buf->unFenced = 0;
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
return 0;
}
static int
pool_validate(struct _DriBufferPool *pool, void *private,
- _glthread_Mutex *mutex)
+ pipe_mutex *mutex)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
return 0;
while(buf->mapCount != 0)
- _glthread_COND_WAIT(buf->event, *mutex);
+ pipe_condvar_wait(buf->event, *mutex);
buf->unFenced = 1;
return 0;
if (!tmp)
return NULL;
- _glthread_INIT_MUTEX(tmp->mutex);
- _glthread_LOCK_MUTEX(tmp->mutex);
+ pipe_mutex_init(tmp->mutex);
+ pipe_mutex_lock(tmp->mutex);
tmp->slabTimeout.tv_usec = slabTimeoutMsec*1000;
tmp->slabTimeout.tv_sec = tmp->slabTimeout.tv_usec / 1000000;
tmp->slabTimeout.tv_usec -= tmp->slabTimeout.tv_sec*1000000;
DRMINITLISTHEAD(&tmp->timeoutList);
DRMINITLISTHEAD(&tmp->unCached);
DRMINITLISTHEAD(&tmp->cached);
- _glthread_UNLOCK_MUTEX(tmp->mutex);
+ pipe_mutex_unlock(tmp->mutex);
return tmp;
}
time = fMan->nextCheck;
driTimeAdd(&time, &fMan->checkInterval);
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
driFreeTimeoutKBOsLocked(fMan, &time);
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
assert(fMan->timeoutList.next == &fMan->timeoutList);
assert(fMan->unCached.next == &fMan->unCached);
driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
struct _DriSlabSizeHeader *header)
{
- _glthread_INIT_MUTEX(header->mutex);
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_init(header->mutex);
+ pipe_mutex_lock(header->mutex);
DRMINITLISTHEAD(&header->slabs);
DRMINITLISTHEAD(&header->freeSlabs);
header->slabPool = pool;
header->bufSize = size;
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
}
static void
drmMMListHead *list, *next;
struct _DriSlabBuffer *buf;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
for (list = header->delayedBuffers.next, next = list->next;
list != &header->delayedBuffers;
list = next, next = list->next) {
header->numDelayed--;
driSlabFreeBufferLocked(buf);
}
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
}
static void
#include "main/glheader.h"
-#include "glapi/glthread.h"
+#include "pipe/p_lthread.h"
#include <GL/internal/glcore.h>
#include "state_tracker/st_public.h"
#include "intel_context.h"
-_glthread_DECLARE_STATIC_MUTEX( lockMutex );
+pipe_static_mutex( lockMutex );
static void
{
char __ret = 0;
- _glthread_LOCK_MUTEX(lockMutex);
+ pipe_mutex_lock(lockMutex);
assert(!intel->locked);
DRM_CAS(intel->driHwLock, intel->hHWContext,
DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
- _glthread_UNLOCK_MUTEX(lockMutex);
+ pipe_mutex_unlock(lockMutex);
DBG(LOCK, "%s - unlocked\n", __progname);
}
#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glxapi.h"
+#include "pipe/p_thread.h"
extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
/**
* GLX API current context.
*/
-#if defined(GLX_USE_TLS)
-PUBLIC __thread void * CurrentContext
- __attribute__((tls_model("initial-exec")));
-#elif defined(THREADS)
-static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
-#else
-static GLXContext CurrentContext = 0;
-#endif
+pipe_tsd ContextTSD;
static void
SetCurrentContext(GLXContext c)
{
-#if defined(GLX_USE_TLS)
- CurrentContext = c;
-#elif defined(THREADS)
- _glthread_SetTSD(&ContextTSD, c);
-#else
- CurrentContext = c;
-#endif
+ pipe_tsd_set(&ContextTSD, c);
}
GLXContext PUBLIC
glXGetCurrentContext(void)
{
-#if defined(GLX_USE_TLS)
- return CurrentContext;
-#elif defined(THREADS)
- return (GLXContext) _glthread_GetTSD(&ContextTSD);
-#else
- return CurrentContext;
-#endif
+ return (GLXContext) pipe_tsd_get(&ContextTSD);
}
#include "xmesaP.h"
#include "main/context.h"
#include "main/framebuffer.h"
-#include "glapi/glthread.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
/**
* Global X driver lock
*/
-_glthread_Mutex _xmesa_lock;
+pipe_mutex _xmesa_lock;
int xmesa_mode;
#else
Status stat;
- _glthread_LOCK_MUTEX(_xmesa_lock);
+ pipe_mutex_lock(_xmesa_lock);
XSync(b->xm_visual->display, 0); /* added for Chromium */
stat = get_drawable_size(dpy, b->drawable, width, height);
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ pipe_mutex_unlock(_xmesa_lock);
if (!stat) {
/* probably querying a window that's recently been destroyed */
uint pf;
if (firstTime) {
- _glthread_INIT_MUTEX(_xmesa_lock);
+ pipe_mutex_init(_xmesa_lock);
firstTime = GL_FALSE;
}
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
+#include "pipe/p_thread.h"
-extern _glthread_Mutex _xmesa_lock;
+extern pipe_mutex _xmesa_lock;
extern XMesaBuffer XMesaBufferList;