summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-08-26 16:35:12 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-08-26 16:35:12 -0600
commit0bb852fa49e7f9a31036089ea4f5dfbd312a4a3a (patch)
tree7f93ecd62f156d5c94b176cd7e4f083823051f67 /src/gallium/winsys
parentb5ab3b7dfc42a568a156dec2fa043292014f98a7 (diff)
gallium: thread wrapper clean-up
In p_thread.h replace _glthread_* functions with new pipe_* functions. Remove other old cruft.
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c102
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h8
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c4
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c66
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c6
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c66
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_lock.c8
-rw-r--r--src/gallium/winsys/xlib/glxapi.c26
-rw-r--r--src/gallium/winsys/xlib/xm_api.c9
-rw-r--r--src/gallium/winsys/xlib/xmesaP.h3
10 files changed, 140 insertions, 158 deletions
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
index b6d901f85e..499f7bef8f 100644
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
@@ -33,7 +33,7 @@
#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"
@@ -51,8 +51,8 @@
* 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;
@@ -241,29 +241,29 @@ static int drmBOResetList(drmBOList *list)
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);
}
@@ -277,7 +277,7 @@ void driReadUnlockKernelBO(void)
typedef struct _DriBufferObject
{
DriBufferPool *pool;
- _glthread_Mutex mutex;
+ pipe_mutx mutex;
int refCount;
const char *name;
uint64_t flags;
@@ -318,12 +318,12 @@ driBOKernel(struct _DriBufferObject *buf)
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;
@@ -338,9 +338,9 @@ driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
* 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 *
@@ -353,11 +353,11 @@ driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
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;
}
@@ -369,9 +369,9 @@ driBOUnmap(struct _DriBufferObject *buf)
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
@@ -381,9 +381,9 @@ driBOOffset(struct _DriBufferObject *buf)
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;
}
@@ -394,9 +394,9 @@ driBOPoolOffset(struct _DriBufferObject *buf)
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;
}
@@ -408,9 +408,9 @@ driBOFlags(struct _DriBufferObject *buf)
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;
}
@@ -418,12 +418,12 @@ driBOFlags(struct _DriBufferObject *buf)
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;
}
@@ -435,10 +435,10 @@ driBOUnReference(struct _DriBufferObject *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);
@@ -451,7 +451,7 @@ driBOUnReference(struct _DriBufferObject *buf)
num_buffers--;
free(buf);
} else
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
@@ -469,7 +469,7 @@ driBOData(struct _DriBufferObject *buf,
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) {
@@ -556,7 +556,7 @@ driBOData(struct _DriBufferObject *buf,
}
out:
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
return retval;
}
@@ -569,7 +569,7 @@ driBOSubData(struct _DriBufferObject *buf,
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,
@@ -577,7 +577,7 @@ driBOSubData(struct _DriBufferObject *buf,
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
@@ -588,21 +588,21 @@ driBOGetSubData(struct _DriBufferObject *buf,
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);
@@ -619,7 +619,7 @@ driBOSetReferenced(struct _DriBufferObject *buf,
}
buf->createdByReference = TRUE;
buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
int
@@ -644,8 +644,8 @@ driGenBuffers(struct _DriBufferPool *pool,
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;
@@ -653,7 +653,7 @@ driGenBuffers(struct _DriBufferPool *pool,
buf->alignment = alignment;
buf->pool = pool;
buf->createdByReference = 0;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
buffers[i] = buf;
}
return 0;
@@ -818,7 +818,7 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
{
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));
@@ -827,7 +827,7 @@ driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
if (newItem)
buf->refCount++;
- _glthread_UNLOCK_MUTEX(buf->mutex);
+ pipe_mutex_unlock(buf->mutex);
}
drmBOList *driGetdrmBOList(struct _DriBufferList *list)
@@ -845,10 +845,10 @@ void driPutdrmBOList(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);
}
@@ -908,10 +908,10 @@ driBOValidateUserList(struct _DriBufferList * list)
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);
}
}
@@ -929,9 +929,9 @@ driBOSize(struct _DriBufferObject *buf)
{
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;
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
index bf60798924..ad3b6f3931 100644
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
@@ -33,14 +33,14 @@
#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);
@@ -55,8 +55,8 @@ typedef struct _DriBufferPool
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);
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
index 40929efa2f..54618b1c82 100644
--- a/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
@@ -113,7 +113,7 @@ pool_unreference(struct _DriBufferPool *pool, void *private)
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;
@@ -202,7 +202,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
}
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;
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
index b56bc269da..831c75d30c 100644
--- a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
@@ -1,5 +1,5 @@
#include "ws_dri_fencemgr.h"
-#include "glthread.h"
+#include "pipe/p_thread.h"
#include <xf86mm.h>
#include <string.h>
#include <unistd.h>
@@ -20,7 +20,7 @@ struct _DriFenceMgr {
/*
* These members are protected by this->mutex
*/
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
int refCount;
drmMMListHead *heads;
int num_fences;
@@ -44,7 +44,7 @@ struct _DriFenceObject {
/*
* These members are protected by this->mutex.
*/
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
uint32_t signaled_type;
void *private;
};
@@ -65,8 +65,8 @@ driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
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;
@@ -77,7 +77,7 @@ driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
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:
@@ -95,13 +95,13 @@ driFenceMgrUnrefUnlock(struct _DriFenceMgr **pMgr)
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);
}
@@ -143,9 +143,9 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
*/
++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;
@@ -157,7 +157,7 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
* Somebody else removed the entry from the list.
*/
- _glthread_UNLOCK_MUTEX(entry->mutex);
+ pipe_mutex_unlock(entry->mutex);
driFenceUnReferenceLocked(&entry);
return;
}
@@ -167,7 +167,7 @@ driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
DRMLISTDELINIT(list);
mgr->info.unreference(mgr, &entry->private);
}
- _glthread_UNLOCK_MUTEX(entry->mutex);
+ pipe_mutex_unlock(entry->mutex);
driFenceUnReferenceLocked(&entry);
list = prev;
}
@@ -181,7 +181,7 @@ driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
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;
@@ -190,16 +190,16 @@ driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
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;
}
@@ -207,9 +207,9 @@ uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence)
{
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;
}
@@ -221,7 +221,7 @@ driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
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)
@@ -236,25 +236,25 @@ driFenceSignaledType(struct _DriFenceObject *fence, uint32_t 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;
}
@@ -267,7 +267,7 @@ driFenceUnReference(struct _DriFenceObject **pFence)
return;
mgr = (*pFence)->mgr;
- _glthread_LOCK_MUTEX(mgr->mutex);
+ pipe_mutex_lock(mgr->mutex);
++mgr->refCount;
driFenceUnReferenceLocked(pFence);
driFenceMgrUnrefUnlock(&mgr);
@@ -294,15 +294,15 @@ struct _DriFenceObject
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;
@@ -312,7 +312,7 @@ struct _DriFenceObject
memcpy(fence->private, private, private_size);
}
- _glthread_UNLOCK_MUTEX(fence->mutex);
+ pipe_mutex_unlock(fence->mutex);
return fence;
}
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
index a80555c9c7..60924eac9e 100644
--- a/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
@@ -33,7 +33,7 @@
#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"
@@ -60,14 +60,14 @@ pool_destroy(struct _DriBufferPool *pool, void *private)
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;
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
index dfcf6d6b19..391cea50a7 100644
--- a/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
+++ b/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
@@ -37,7 +37,7 @@
#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
@@ -53,7 +53,7 @@ struct _DriSlabBuffer {
uint32_t start;
uint32_t fenceType;
int unFenced;
- _glthread_Cond event;
+ pipe_condvar event;
};
struct _DriKernelBO {
@@ -84,7 +84,7 @@ struct _DriSlabSizeHeader {
uint32_t numDelayed;
struct _DriSlabPool *slabPool;
uint32_t bufSize;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
struct _DriFreeSlabManager {
@@ -94,7 +94,7 @@ struct _DriFreeSlabManager {
drmMMListHead timeoutList;
drmMMListHead unCached;
drmMMListHead cached;
- _glthread_Mutex mutex;
+ pipe_mutex mutex;
};
@@ -196,7 +196,7 @@ driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
{
struct timeval time;
- _glthread_LOCK_MUTEX(fMan->mutex);
+ pipe_mutex_lock(fMan->mutex);
gettimeofday(&time, NULL);
driTimeAdd(&time, &fMan->slabTimeout);
@@ -210,7 +210,7 @@ driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
driFreeTimeoutKBOsLocked(fMan, &time);
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
}
/*
@@ -237,7 +237,7 @@ driAllocKernelBO(struct _DriSlabSizeHeader *header)
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;
@@ -269,7 +269,7 @@ driAllocKernelBO(struct _DriSlabSizeHeader *header)
DRMLISTDELINIT(&kbo->timeoutHead);
}
- _glthread_UNLOCK_MUTEX(fMan->mutex);
+ pipe_mutex_unlock(fMan->mutex);
if (kbo) {
uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
@@ -360,7 +360,7 @@ driAllocSlab(struct _DriSlabSizeHeader *header)
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++;
@@ -494,23 +494,23 @@ driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
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);
@@ -520,7 +520,7 @@ driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
list = slab->freeBuffers.next;
DRMLISTDELINIT(list);
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
return buf;
}
@@ -618,7 +618,7 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
slab = buf->parent;
header = slab->header;
- _glthread_LOCK_MUTEX(header->mutex);
+ pipe_mutex_lock(header->mutex);
buf->unFenced = 0;
buf->mapCount = 0;
@@ -631,18 +631,18 @@ pool_destroy(struct _DriBufferPool *driPool, void *private)
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;
@@ -655,7 +655,7 @@ pool_waitIdle(struct _DriBufferPool *driPool, void *private,
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;
@@ -689,7 +689,7 @@ pool_unmap(struct _DriBufferPool *pool, void *private)
--buf->mapCount;
if (buf->mapCount == 0 && buf->isSlabBuffer)
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
return 0;
}
@@ -760,7 +760,7 @@ pool_fence(struct _DriBufferPool *pool, void *private,
buf->fenceType = bo->fenceFlags;
buf->unFenced = 0;
- _glthread_COND_BROADCAST(buf->event);
+ pipe_condvar_broadcast(buf->event);
return 0;
}
@@ -775,7 +775,7 @@ pool_kernel(struct _DriBufferPool *pool, void *private)
static int
pool_validate(struct _DriBufferPool *pool, void *private,
- _glthread_Mutex *mutex)
+ pipe_mutex *mutex)
{
struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
@@ -783,7 +783,7 @@ pool_validate(struct _DriBufferPool *pool, void *private,
return 0;
while(buf->mapCount != 0)
- _glthread_COND_WAIT(buf->event, *mutex);
+ pipe_condvar_wait(buf->event, *mutex);
buf->unFenced = 1;
return 0;
@@ -799,8 +799,8 @@ driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
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;
@@ -814,7 +814,7 @@ driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
DRMINITLISTHEAD(&tmp->timeoutList);
DRMINITLISTHEAD(&tmp->unCached);
DRMINITLISTHEAD(&tmp->cached);
- _glthread_UNLOCK_MUTEX(tmp->mutex);
+ pipe_mutex_unlock(tmp->mutex);
return tmp;
}
@@ -827,9 +827,9 @@ driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan)
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);
@@ -842,8 +842,8 @@ static void
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);
@@ -853,7 +853,7 @@ driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
header->slabPool = pool;
header->bufSize = size;
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
}
static void
@@ -862,7 +862,7 @@ driFinishSizeHeader(struct _DriSlabSizeHeader *header)
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) {
@@ -875,7 +875,7 @@ driFinishSizeHeader(struct _DriSlabSizeHeader *header)
header->numDelayed--;
driSlabFreeBufferLocked(buf);
}
- _glthread_UNLOCK_MUTEX(header->mutex);
+ pipe_mutex_unlock(header->mutex);
}
static void
diff --git a/src/gallium/winsys/drm/intel/dri/intel_lock.c b/src/gallium/winsys/drm/intel/dri/intel_lock.c
index 406284c98f..18c7bba0d5 100644
--- a/src/gallium/winsys/drm/intel/dri/intel_lock.c
+++ b/src/gallium/winsys/drm/intel/dri/intel_lock.c
@@ -27,7 +27,7 @@
#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"
@@ -35,7 +35,7 @@
-_glthread_DECLARE_STATIC_MUTEX( lockMutex );
+pipe_static_mutex( lockMutex );
static void
@@ -72,7 +72,7 @@ void LOCK_HARDWARE( struct intel_context *intel )
{
char __ret = 0;
- _glthread_LOCK_MUTEX(lockMutex);
+ pipe_mutex_lock(lockMutex);
assert(!intel->locked);
DRM_CAS(intel->driHwLock, intel->hHWContext,
@@ -96,7 +96,7 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
- _glthread_UNLOCK_MUTEX(lockMutex);
+ pipe_mutex_unlock(lockMutex);
DBG(LOCK, "%s - unlocked\n", __progname);
}
diff --git a/src/gallium/winsys/xlib/glxapi.c b/src/gallium/winsys/xlib/glxapi.c
index c2ccce6f52..c059fc3edb 100644
--- a/src/gallium/winsys/xlib/glxapi.c
+++ b/src/gallium/winsys/xlib/glxapi.c
@@ -37,6 +37,7 @@
#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glxapi.h"
+#include "pipe/p_thread.h"
extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
@@ -127,26 +128,13 @@ get_dispatch(Display *dpy)
/**
* 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);
}
@@ -238,13 +226,7 @@ glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
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);
}
diff --git a/src/gallium/winsys/xlib/xm_api.c b/src/gallium/winsys/xlib/xm_api.c
index 7256340420..edcadff9c5 100644
--- a/src/gallium/winsys/xlib/xm_api.c
+++ b/src/gallium/winsys/xlib/xm_api.c
@@ -62,7 +62,6 @@
#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"
@@ -75,7 +74,7 @@
/**
* Global X driver lock
*/
-_glthread_Mutex _xmesa_lock;
+pipe_mutex _xmesa_lock;
int xmesa_mode;
@@ -245,10 +244,10 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
#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 */
@@ -779,7 +778,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
uint pf;
if (firstTime) {
- _glthread_INIT_MUTEX(_xmesa_lock);
+ pipe_mutex_init(_xmesa_lock);
firstTime = GL_FALSE;
}
diff --git a/src/gallium/winsys/xlib/xmesaP.h b/src/gallium/winsys/xlib/xmesaP.h
index 9b15b2ddf9..fcaeee52bc 100644
--- a/src/gallium/winsys/xlib/xmesaP.h
+++ b/src/gallium/winsys/xlib/xmesaP.h
@@ -35,9 +35,10 @@
#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;