On Sat, Jul 18, 2009 at 20:37, RALOVICH,
Kristóf<[email protected]> wrote:
> Hi,
>
> I have been going through the GLX sources and found some usages of 
> USE_XTHREADS.
>
> After grepping the whole tree including the configs directory I have
> found some other references too, but no predefined configs that set
> it.
>
> Please educate me whether USE_XTHREADS code is used by anyone on any
> platform today? If not, may I propose patches that remove dead code?
>
> Thanks,
> Kristof
>

This is a RFC.

I made the patches that remove xthreads from the source tree. Please
review them.

Thanks,
Kristof
From 29a7d65cb8898eb073779e7eaedb8b088bab82b4 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?RALOVICH,=20Krist=C3=B3f?= <[email protected]>
Date: Thu, 23 Jul 2009 17:56:52 +0200
Subject: [PATCH 1/4] glapi: remove XTHREADS support

---
 src/mesa/glapi/gl_x86-64_asm.py |    2 +-
 src/mesa/glapi/gl_x86_asm.py    |    2 +-
 src/mesa/glapi/glthread.c       |   51 ---------------------------------------
 src/mesa/glapi/glthread.h       |   44 +--------------------------------
 4 files changed, 3 insertions(+), 96 deletions(-)

diff --git a/src/mesa/glapi/gl_x86-64_asm.py b/src/mesa/glapi/gl_x86-64_asm.py
index fa45406..f36ad3a 100644
--- a/src/mesa/glapi/gl_x86-64_asm.py
+++ b/src/mesa/glapi/gl_x86-64_asm.py
@@ -138,7 +138,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
 		print '#  define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
 		print '# endif'
 		print ''
-		print '#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
+		print '#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
 		print '#  define THREADS'
 		print '#endif'
 		print ''
diff --git a/src/mesa/glapi/gl_x86_asm.py b/src/mesa/glapi/gl_x86_asm.py
index 0dbf3eb..36f0e31 100644
--- a/src/mesa/glapi/gl_x86_asm.py
+++ b/src/mesa/glapi/gl_x86_asm.py
@@ -79,7 +79,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
 		print '#define GLOBL_FN(x) GLOBL x'
 		print '#endif'
 		print ''
-		print '#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
+		print '#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
 		print '#  define THREADS'
 		print '#endif'
 		print ''
diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c
index e3abb0f..737fd4d 100644
--- a/src/mesa/glapi/glthread.c
+++ b/src/mesa/glapi/glthread.c
@@ -246,57 +246,6 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
 
 #endif /* WIN32_THREADS */
 
-
-
-/*
- * XFree86 has its own thread wrapper, Xthreads.h
- * We wrap it again for GL.
- */
-#ifdef USE_XTHREADS
-
-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;
-}
-
-
-void *
-_glthread_GetTSD(_glthread_TSD *tsd)
-{
-   void *ptr;
-   if (tsd->initMagic != INIT_MAGIC) {
-      _glthread_InitTSD(tsd);
-   }
-   xthread_get_specific(tsd->key, &ptr);
-   return ptr;
-}
-
-
-void
-_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
-{
-   if (tsd->initMagic != INIT_MAGIC) {
-      _glthread_InitTSD(tsd);
-   }
-   xthread_set_specific(tsd->key, ptr);
-}
-
-#endif /* XTHREAD */
-
-
-
 /*
  * BeOS threads
  */
diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h
index dfe09a9..8ec933a 100644
--- a/src/mesa/glapi/glthread.h
+++ b/src/mesa/glapi/glthread.h
@@ -71,7 +71,7 @@
 
 
 #if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
-     defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
+     defined(WIN32_THREADS) || defined(BEOS_THREADS)) \
     && !defined(THREADS)
 # define THREADS
 #endif
@@ -218,48 +218,6 @@ typedef CRITICAL_SECTION _glthread_Mutex;
 #endif /* WIN32_THREADS */
 
 
-
-
-/*
- * 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.
  */
-- 
1.6.3.3

From 4dded7502db829b3bf4b10df75ed066d8467b01c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?RALOVICH,=20Krist=C3=B3f?= <[email protected]>
Date: Thu, 23 Jul 2009 17:57:22 +0200
Subject: [PATCH 2/4] glapi: regenerated GL API assembly files

---
 src/mesa/x86-64/glapi_x86-64.S |    2 +-
 src/mesa/x86/glapi_x86.S       |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/x86-64/glapi_x86-64.S b/src/mesa/x86-64/glapi_x86-64.S
index 90ad36a..44179ab 100644
--- a/src/mesa/x86-64/glapi_x86-64.S
+++ b/src/mesa/x86-64/glapi_x86-64.S
@@ -45,7 +45,7 @@
 #  define GL_PREFIX(n) GLNAME(CONCAT(gl,n))
 # endif
 
-#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)
+#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)
 #  define THREADS
 #endif
 
diff --git a/src/mesa/x86/glapi_x86.S b/src/mesa/x86/glapi_x86.S
index 40fc6f2..fa25bf7 100644
--- a/src/mesa/x86/glapi_x86.S
+++ b/src/mesa/x86/glapi_x86.S
@@ -52,7 +52,7 @@
 #define GLOBL_FN(x) GLOBL x
 #endif
 
-#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)
+#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)
 #  define THREADS
 #endif
 
-- 
1.6.3.3

From c0234a9f25b18b60b2a7a89a952cc8162b99400f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?RALOVICH,=20Krist=C3=B3f?= <[email protected]>
Date: Thu, 23 Jul 2009 17:57:48 +0200
Subject: [PATCH 3/4] docs: do not mentions xthreads any more

---
 docs/dispatch.html |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/docs/dispatch.html b/docs/dispatch.html
index b9ea882..bcab74c 100644
--- a/docs/dispatch.html
+++ b/docs/dispatch.html
@@ -198,7 +198,7 @@ few preprocessor defines.</p>
 <ul>
 <li>If <tt>GLX_USE_TLS</tt> is defined, method #4 is used.</li>
 <li>If <tt>PTHREADS</tt> is defined, method #3 is used.</li>
-<li>If any of <tt>PTHREADS</tt>, <tt>USE_XTHREADS</tt>,
+<li>If any of <tt>PTHREADS</tt>,
 <tt>SOLARIS_THREADS</tt>, <tt>WIN32_THREADS</tt>, or <tt>BEOS_THREADS</tt>
 is defined, method #2 is used.</li>
 <li>If none of the preceeding are defined, method #1 is used.</li>
-- 
1.6.3.3

From 5bce18fcafd3ece4fe95316e7815f932670a619c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?RALOVICH,=20Krist=C3=B3f?= <[email protected]>
Date: Thu, 23 Jul 2009 17:58:08 +0200
Subject: [PATCH 4/4] glx: remove XTHREADS support

---
 src/glx/x11/glxclient.h  |   14 ++++----------
 src/glx/x11/glxcurrent.c |   40 +---------------------------------------
 src/glx/x11/glxext.c     |   11 -----------
 3 files changed, 5 insertions(+), 60 deletions(-)

diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index bf68d0f..aff1c85 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -55,9 +55,7 @@
 #include "GL/internal/glcore.h"
 #include "glapi/glapitable.h"
 #include "glxhash.h"
-#if defined( USE_XTHREADS )
-# include <X11/Xthreads.h>
-#elif defined( PTHREADS )
+#if defined( PTHREADS )
 # include <pthread.h>
 #endif
 
@@ -623,7 +621,7 @@ extern void __glXPreferEGL(int state);
 extern int __glXDebug;
 
 /* This is per-thread storage in an MT environment */
-#if defined( USE_XTHREADS ) || defined( PTHREADS )
+#if defined( PTHREADS )
 
 extern void __glXSetCurrentContext(__GLXcontext *c);
 
@@ -646,7 +644,7 @@ extern __GLXcontext *__glXcurrentContext;
 #define __glXGetCurrentContext()	__glXcurrentContext
 #define __glXSetCurrentContext(gc)	__glXcurrentContext = gc
 
-#endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
+#endif /* defined( PTHREADS ) */
 
 extern void __glXSetCurrentContextNull(void);
 
@@ -657,11 +655,7 @@ extern void __glXFreeContext(__GLXcontext*);
 ** Global lock for all threads in this address space using the GLX
 ** extension
 */
-#if defined( USE_XTHREADS )
-extern xmutex_rec __glXmutex;
-#define __glXLock()    xmutex_lock(&__glXmutex)
-#define __glXUnlock()  xmutex_unlock(&__glXmutex)
-#elif defined( PTHREADS )
+#if defined( PTHREADS )
 extern pthread_mutex_t __glXmutex;
 #define __glXLock()    pthread_mutex_lock(&__glXmutex)
 #define __glXUnlock()  pthread_mutex_unlock(&__glXmutex)
diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c
index d44e0dd..ce037e0 100644
--- a/src/glx/x11/glxcurrent.c
+++ b/src/glx/x11/glxcurrent.c
@@ -73,45 +73,7 @@ static __GLapi *IndirectAPI = NULL;
  * Current context management and locking
  */
 
-#if defined( USE_XTHREADS )
-
-/* thread safe */
-static GLboolean TSDinitialized = GL_FALSE;
-static xthread_key_t ContextTSD;
-
-_X_HIDDEN __GLXcontext *
-__glXGetCurrentContext(void)
-{
-   if (!TSDinitialized) {
-      xthread_key_create(&ContextTSD, NULL);
-      TSDinitialized = GL_TRUE;
-      return &dummyContext;
-   }
-   else {
-      void *p;
-      xthread_get_specific(ContextTSD, &p);
-      if (!p)
-         return &dummyContext;
-      else
-         return (__GLXcontext *) p;
-   }
-}
-
-_X_HIDDEN void
-__glXSetCurrentContext(__GLXcontext * c)
-{
-   if (!TSDinitialized) {
-      xthread_key_create(&ContextTSD, NULL);
-      TSDinitialized = GL_TRUE;
-   }
-   xthread_set_specific(ContextTSD, c);
-}
-
-
-/* Used by the __glXLock() and __glXUnlock() macros */
-_X_HIDDEN xmutex_rec __glXmutex;
-
-#elif defined( PTHREADS )
+#if defined( PTHREADS )
 
 _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
 
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index b296b7c..e07ed29 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -646,17 +646,6 @@ __glXInitialize(Display * dpy)
    Bool glx_direct, glx_accel;
 #endif
 
-#if defined(USE_XTHREADS)
-   {
-      static int firstCall = 1;
-      if (firstCall) {
-         /* initialize the GLX mutexes */
-         xmutex_init(&__glXmutex);
-         firstCall = 0;
-      }
-   }
-#endif
-
    /* The one and only long long lock */
    __glXLock();
 
-- 
1.6.3.3

------------------------------------------------------------------------------
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to