glapi.c: misc coscmetic for FreeTSD
authorGeorge Sapountzis <gsapountzis@gmail.com>
Mon, 1 Mar 2010 02:44:02 +0000 (04:44 +0200)
committerGeorge Sapountzis <gsapountzis@gmail.com>
Mon, 1 Mar 2010 18:54:20 +0000 (20:54 +0200)
- move out of of the dispatch/context block to after corresponding init functions

- use more consistent naming with corresponding init functions

- XXX use _glthread_InitTSD() vs (void)_glthread_GetTSD() in _glapi_check_multithread() XXX

src/gallium/state_trackers/wgl/stw_device.c
src/mesa/glapi/glapi.c
src/mesa/glapi/glapi.h
src/mesa/glapi/glthread.c
src/mesa/glapi/glthread.h

index e5fa6ac..472a2a5 100644 (file)
@@ -47,7 +47,6 @@
 
 #ifdef WIN32_THREADS
 extern _glthread_Mutex OneTimeLock;
-extern void FreeAllTSD(void);
 #endif
 
 
@@ -183,7 +182,8 @@ stw_cleanup(void)
 
 #ifdef WIN32_THREADS
    _glthread_DESTROY_MUTEX(OneTimeLock);
-   FreeAllTSD();
+
+   _glapi_destroy_multithread();
 #endif
 
 #ifdef DEBUG
index fe52307..056abd7 100644 (file)
@@ -118,15 +118,6 @@ _glthread_TSD _gl_DispatchTSD;           /**< Per-thread dispatch pointer */
 
 static _glthread_TSD ContextTSD;         /**< Per-thread context pointer */
 
-#if defined(WIN32_THREADS)
-void FreeTSD(_glthread_TSD *p);
-void FreeAllTSD(void)
-{
-   FreeTSD(&_gl_DispatchTSD);
-   FreeTSD(&ContextTSD);
-}
-#endif /* defined(WIN32_THREADS) */
-
 #endif /* defined(THREADS) */
 
 PUBLIC struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table;
@@ -140,6 +131,22 @@ PUBLIC void *_glapi_Context = NULL;
 
 #if defined(THREADS) && !defined(GLX_USE_TLS)
 
+void
+_glapi_init_multithread(void)
+{
+   _glthread_InitTSD(&_gl_DispatchTSD);
+   _glthread_InitTSD(&ContextTSD);
+}
+
+void
+_glapi_destroy_multithread(void)
+{
+#ifdef WIN32_THREADS
+   _glthread_DestroyTSD(&_gl_DispatchTSD);
+   _glthread_DestroyTSD(&ContextTSD);
+#endif
+}
+
 /**
  * Mutex for multithread check.
  */
@@ -168,9 +175,7 @@ _glapi_check_multithread(void)
 
    CHECK_MULTITHREAD_LOCK();
    if (firstCall) {
-      /* initialize TSDs */
-      (void) _glthread_GetTSD(&ContextTSD);
-      (void) _glthread_GetTSD(&_gl_DispatchTSD);
+      _glapi_init_multithread(void)
 
       knownID = _glthread_GetID();
       firstCall = GL_FALSE;
@@ -185,6 +190,12 @@ _glapi_check_multithread(void)
 
 #else
 
+void
+_glapi_init_multithread(void) { }
+
+void
+_glapi_destroy_multithread(void) { }
+
 PUBLIC void
 _glapi_check_multithread(void) { }
 
index 0abec5d..2eae6d5 100644 (file)
@@ -122,6 +122,14 @@ extern void *_glapi_Context;
  **/
 
 extern void
+_glapi_init_multithread(void);
+
+
+extern void
+_glapi_destroy_multithread(void);
+
+
+extern void
 _glapi_check_multithread(void);
 
 
index be4e2f7..15401d7 100644 (file)
@@ -190,17 +190,9 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
  */
 #ifdef WIN32_THREADS
 
-void FreeTSD(_glthread_TSD *p)
+static void InsteadOf_exit(int nCode)
 {
-   if (p->initMagic==INIT_MAGIC) {
-      TlsFree(p->key);
-      p->initMagic=0;
-   }
-}
-
-void InsteadOf_exit(int nCode)
-{
-   DWORD dwErr=GetLastError();
+   DWORD dwErr = GetLastError();
 }
 
 PUBLIC unsigned long
@@ -222,6 +214,17 @@ _glthread_InitTSD(_glthread_TSD *tsd)
 }
 
 
+void
+_glthread_DestroyTSD(_glthread_TSD *tsd)
+{
+   if (tsd->initMagic != INIT_MAGIC) {
+      return;
+   }
+   TlsFree(tsd->key);
+   tsd->initMagic = 0x0;
+}
+
+
 void *
 _glthread_GetTSD(_glthread_TSD *tsd)
 {
index be39501..389c242 100644 (file)
@@ -315,6 +315,10 @@ extern void
 _glthread_InitTSD(_glthread_TSD *);
 
 
+extern void
+_glthread_DestroyTSD(_glthread_TSD *); /* WIN32 only */
+
+
 extern void *
 _glthread_GetTSD(_glthread_TSD *);