fix GL_DOT3_RGBA texture combiner mode in generated fragment programs (bug #11030)
[mesa.git] / src / mesa / glapi / glthread.c
index 778fa4873c89ca1863df59d87f3ee0715201c89b..4513853f5a2b1f4e68726f1cc33e5bf0ab9f8f8f 100644 (file)
@@ -1,10 +1,8 @@
-/* $Id: glthread.c,v 1.9 2001/11/12 23:50:12 brianp Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  6.5.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  */
 
 
-#ifdef PC_ALL
-#include "all.h"
-#else
 #include "glheader.h"
 #include "glthread.h"
-#endif
 
 
 /*
@@ -191,11 +185,23 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
  */
 #ifdef WIN32_THREADS
 
+void FreeTSD(_glthread_TSD *p)
+{
+   if (p->initMagic==INIT_MAGIC) {
+      TlsFree(p->key);
+      p->initMagic=0;
+   }
+}
+
+void InsteadOf_exit(int nCode)
+{
+   DWORD dwErr=GetLastError();
+}
+
 unsigned long
 _glthread_GetID(void)
 {
-   abort();   /* XXX not implemented yet */
-   return (unsigned long) 0;
+   return GetCurrentThreadId();
 }
 
 
@@ -203,11 +209,9 @@ void
 _glthread_InitTSD(_glthread_TSD *tsd)
 {
    tsd->key = TlsAlloc();
-   if (tsd->key == 0xffffffff) {
-      /* Can Windows handle stderr messages for non-console
-         applications? Does Windows have perror? */
-      /* perror(SET_INIT_ERROR);*/
-      exit(-1);
+   if (tsd->key == TLS_OUT_OF_INDEXES) {
+      perror("Mesa:_glthread_InitTSD");
+      InsteadOf_exit(-1);
    }
    tsd->initMagic = INIT_MAGIC;
 }
@@ -232,10 +236,8 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
       _glthread_InitTSD(tsd);
    }
    if (TlsSetValue(tsd->key, ptr) == 0) {
-      /* Can Windows handle stderr messages for non-console
-         applications? Does Windows have perror? */
-      /* perror(SET_TSD_ERROR);*/
-      exit(-1);
+         perror("Mesa:_glthread_SetTSD");
+         InsteadOf_exit(-1);
    }
 }
 
@@ -247,7 +249,7 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
  * XFree86 has its own thread wrapper, Xthreads.h
  * We wrap it again for GL.
  */
-#ifdef XTHREADS
+#ifdef USE_XTHREADS
 
 unsigned long
 _glthread_GetID(void)