aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glx/glthread.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-09-03 14:16:57 +0000
committermarha <marha@users.sourceforge.net>2010-09-03 14:16:57 +0000
commit618c64aa88755d61b734ba8b54a325a56ac830ad (patch)
treeaf63069a8597de2b1a190d18a62ebe3ce752cd02 /xorg-server/glx/glthread.c
parent917506f14358fb7ceb85e1b769c98951dccc9dd9 (diff)
downloadvcxsrv-618c64aa88755d61b734ba8b54a325a56ac830ad.tar.gz
vcxsrv-618c64aa88755d61b734ba8b54a325a56ac830ad.tar.bz2
vcxsrv-618c64aa88755d61b734ba8b54a325a56ac830ad.zip
Synchronised glx with mesa
Diffstat (limited to 'xorg-server/glx/glthread.c')
-rw-r--r--xorg-server/glx/glthread.c160
1 files changed, 23 insertions, 137 deletions
diff --git a/xorg-server/glx/glthread.c b/xorg-server/glx/glthread.c
index 8b9f61885..c466e9bf0 100644
--- a/xorg-server/glx/glthread.c
+++ b/xorg-server/glx/glthread.c
@@ -25,13 +25,15 @@
/*
* XXX There's probably some work to do in order to make this file
- * truly reusable outside of Mesa.
+ * truly reusable outside of Mesa. First, the glheader.h include must go.
*/
-
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#include <X11/Xfuncproto.h>
+#ifndef PUBLIC
+#define PUBLIC
+#endif
#endif
#include <stdlib.h>
@@ -72,7 +74,7 @@
*/
#ifdef PTHREADS
-_X_EXPORT unsigned long
+PUBLIC unsigned long
_glthread_GetID(void)
{
return (unsigned long) pthread_self();
@@ -117,94 +119,18 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
/*
- * Solaris/Unix International Threads -- Use only if POSIX threads
- * aren't available on your Unix platform. Solaris 2.[34] are examples
- * of platforms where this is the case. Be sure to use -mt and/or
- * -D_REENTRANT when compiling.
- */
-#ifdef SOLARIS_THREADS
-#define USE_LOCK_FOR_KEY /* undef this to try a version without
- lock for the global key... */
-
-_X_EXPORT unsigned long
-_glthread_GetID(void)
-{
- OsAbort(); /* XXX not implemented yet */
- return (unsigned long) 0;
-}
-
-
-void
-_glthread_InitTSD(_glthread_TSD *tsd)
-{
- if ((errno = mutex_init(&tsd->keylock, 0, NULL)) != 0 ||
- (errno = thr_keycreate(&(tsd->key), free)) != 0) {
- perror(INIT_TSD_ERROR);
- exit(-1);
- }
- tsd->initMagic = INIT_MAGIC;
-}
-
-
-void *
-_glthread_GetTSD(_glthread_TSD *tsd)
-{
- void* ret;
- if (tsd->initMagic != INIT_MAGIC) {
- _glthread_InitTSD(tsd);
- }
-#ifdef USE_LOCK_FOR_KEY
- mutex_lock(&tsd->keylock);
- thr_getspecific(tsd->key, &ret);
- mutex_unlock(&tsd->keylock);
-#else
- if ((errno = thr_getspecific(tsd->key, &ret)) != 0) {
- perror(GET_TSD_ERROR);
- exit(-1);
- }
-#endif
- return ret;
-}
-
-
-void
-_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
-{
- if (tsd->initMagic != INIT_MAGIC) {
- _glthread_InitTSD(tsd);
- }
- if ((errno = thr_setspecific(tsd->key, ptr)) != 0) {
- perror(SET_TSD_ERROR);
- exit(-1);
- }
-}
-
-#undef USE_LOCK_FOR_KEY
-#endif /* SOLARIS_THREADS */
-
-
-
-/*
* Win32 Threads. The only available option for Windows 95/NT.
* Be sure that you compile using the Multithreaded runtime, otherwise
* bad things will happen.
*/
#ifdef WIN32_THREADS
-void FreeTSD(_glthread_TSD *p)
-{
- if (p->initMagic==INIT_MAGIC) {
- TlsFree(p->key);
- p->initMagic=0;
- }
-}
-
-void InsteadOf_exit(int nCode)
+static void InsteadOf_exit(int nCode)
{
- DWORD dwErr=GetLastError();
+ DWORD dwErr = GetLastError();
}
-unsigned long
+PUBLIC unsigned long
_glthread_GetID(void)
{
return GetCurrentThreadId();
@@ -216,96 +142,56 @@ _glthread_InitTSD(_glthread_TSD *tsd)
{
tsd->key = TlsAlloc();
if (tsd->key == TLS_OUT_OF_INDEXES) {
- perror("Mesa:_glthread_InitTSD");
+ perror(INIT_TSD_ERROR);
InsteadOf_exit(-1);
}
tsd->initMagic = INIT_MAGIC;
}
-void *
-_glthread_GetTSD(_glthread_TSD *tsd)
-{
- if (tsd->initMagic != INIT_MAGIC) {
- _glthread_InitTSD(tsd);
- }
- return TlsGetValue(tsd->key);
-}
-
-
void
-_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+_glthread_DestroyTSD(_glthread_TSD *tsd)
{
- /* the following code assumes that the _glthread_TSD has been initialized
- to zero at creation */
if (tsd->initMagic != INIT_MAGIC) {
- _glthread_InitTSD(tsd);
- }
- if (TlsSetValue(tsd->key, ptr) == 0) {
- perror("Mesa:_glthread_SetTSD");
- InsteadOf_exit(-1);
+ return;
}
-}
-
-#endif /* WIN32_THREADS */
-
-
-
-/*
- * XFree86 has its own thread wrapper, Xthreads.h
- * We wrap it again for GL.
- */
-#ifdef USE_XTHREADS
-
-_X_EXPORT unsigned long
-_glthread_GetID(void)
-{
- return (unsigned long) xthread_self();
-}
-
-
-void
-_glthread_InitTSD(_glthread_TSD *tsd)
-{
- if (xthread_key_create(&tsd->key, NULL) != 0) {
- perror(INIT_TSD_ERROR);
- exit(-1);
- }
- tsd->initMagic = INIT_MAGIC;
+ TlsFree(tsd->key);
+ tsd->initMagic = 0x0;
}
void *
_glthread_GetTSD(_glthread_TSD *tsd)
{
- void *ptr;
if (tsd->initMagic != INIT_MAGIC) {
_glthread_InitTSD(tsd);
}
- xthread_get_specific(tsd->key, &ptr);
- return ptr;
+ return TlsGetValue(tsd->key);
}
void
_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
{
+ /* the following code assumes that the _glthread_TSD has been initialized
+ to zero at creation */
if (tsd->initMagic != INIT_MAGIC) {
_glthread_InitTSD(tsd);
}
- xthread_set_specific(tsd->key, ptr);
+ if (TlsSetValue(tsd->key, ptr) == 0) {
+ perror(SET_TSD_ERROR);
+ InsteadOf_exit(-1);
+ }
}
-#endif /* XTHREAD */
-
-
+#endif /* WIN32_THREADS */
/*
* BeOS threads
*/
#ifdef BEOS_THREADS
-unsigned long
+PUBLIC unsigned long
_glthread_GetID(void)
{
return (unsigned long) find_thread(NULL);
@@ -347,7 +233,7 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
* no-op functions
*/
-_X_EXPORT unsigned long
+PUBLIC unsigned long
_glthread_GetID(void)
{
return 0;