egl/main: replace INLINE with inline
[mesa.git] / src / egl / main / eglcurrent.c
index cbca9ff2c2f4c6a8e953aa148ec11de724b12d09..d358feaad5e2aeab69d97efd2014e75a2de3b8e8 100644 (file)
@@ -1,5 +1,35 @@
+/**************************************************************************
+ *
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * 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"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
 #include <stdlib.h>
 #include <string.h>
+#include "c99_compat.h"
+
 #include "egllog.h"
 #include "eglmutex.h"
 #include "eglcurrent.h"
 static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
 
 
-#if PTHREADS
+#if HAVE_PTHREAD
 #include <pthread.h>
 
-static _EGL_DECLARE_MUTEX(_egl_TSDMutex);
+static _EGLMutex _egl_TSDMutex = _EGL_MUTEX_INITIALIZER;
 static EGLBoolean _egl_TSDInitialized;
 static pthread_key_t _egl_TSD;
 static void (*_egl_FreeTSD)(_EGLThreadInfo *);
@@ -27,7 +57,7 @@ static __thread const _EGLThreadInfo *_egl_TLS
    __attribute__ ((tls_model("initial-exec")));
 #endif
 
-static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
+static inline void _eglSetTSD(const _EGLThreadInfo *t)
 {
    pthread_setspecific(_egl_TSD, (const void *) t);
 #ifdef GLX_USE_TLS
@@ -35,7 +65,7 @@ static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
 #endif
 }
 
-static INLINE _EGLThreadInfo *_eglGetTSD(void)
+static inline _EGLThreadInfo *_eglGetTSD(void)
 {
 #ifdef GLX_USE_TLS
    return (_EGLThreadInfo *) _egl_TLS;
@@ -44,7 +74,7 @@ static INLINE _EGLThreadInfo *_eglGetTSD(void)
 #endif
 }
 
-static INLINE void _eglFiniTSD(void)
+static inline void _eglFiniTSD(void)
 {
    _eglLockMutex(&_egl_TSDMutex);
    if (_egl_TSDInitialized) {
@@ -58,7 +88,7 @@ static INLINE void _eglFiniTSD(void)
    _eglUnlockMutex(&_egl_TSDMutex);
 }
 
-static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
+static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
 {
    if (!_egl_TSDInitialized) {
       _eglLockMutex(&_egl_TSDMutex);
@@ -80,27 +110,27 @@ static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
    return EGL_TRUE;
 }
 
-#else /* PTHREADS */
+#else /* HAVE_PTHREAD */
 static const _EGLThreadInfo *_egl_TSD;
 static void (*_egl_FreeTSD)(_EGLThreadInfo *);
 
-static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
+static inline void _eglSetTSD(const _EGLThreadInfo *t)
 {
    _egl_TSD = t;
 }
 
-static INLINE _EGLThreadInfo *_eglGetTSD(void)
+static inline _EGLThreadInfo *_eglGetTSD(void)
 {
    return (_EGLThreadInfo *) _egl_TSD;
 }
 
-static INLINE void _eglFiniTSD(void)
+static inline void _eglFiniTSD(void)
 {
    if (_egl_FreeTSD && _egl_TSD)
       _egl_FreeTSD((_EGLThreadInfo *) _egl_TSD);
 }
 
-static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
+static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
 {
    if (!_egl_FreeTSD && dtor) {
       _egl_FreeTSD = dtor;
@@ -109,7 +139,7 @@ static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
    return EGL_TRUE;
 }
 
-#endif /* !PTHREADS */
+#endif /* !HAVE_PTHREAD */
 
 
 static void
@@ -128,7 +158,7 @@ _eglInitThreadInfo(_EGLThreadInfo *t)
 static _EGLThreadInfo *
 _eglCreateThreadInfo(void)
 {
-   _EGLThreadInfo *t = (_EGLThreadInfo *) calloc(1, sizeof(_EGLThreadInfo));
+   _EGLThreadInfo *t = calloc(1, sizeof(_EGLThreadInfo));
    if (t)
       _eglInitThreadInfo(t);
    else
@@ -151,7 +181,7 @@ _eglDestroyThreadInfo(_EGLThreadInfo *t)
 /**
  * Make sure TSD is initialized and return current value.
  */
-static INLINE _EGLThreadInfo *
+static inline _EGLThreadInfo *
 _eglCheckedGetTSD(void)
 {
    if (_eglInitTSD(&_eglDestroyThreadInfo) != EGL_TRUE) {
@@ -286,6 +316,9 @@ _eglError(EGLint errCode, const char *msg)
       case EGL_BAD_SURFACE:
          s = "EGL_BAD_SURFACE";
          break;
+      case EGL_NOT_INITIALIZED:
+         s = "EGL_NOT_INITIALIZED";
+         break;
 #ifdef EGL_MESA_screen_surface
       case EGL_BAD_SCREEN_MESA:
          s = "EGL_BAD_SCREEN_MESA";
@@ -295,7 +328,7 @@ _eglError(EGLint errCode, const char *msg)
          break;
 #endif
       default:
-         s = "other";
+         s = "other EGL error";
       }
       _eglLog(_EGL_DEBUG, "EGL user error 0x%x (%s) in %s\n", errCode, s, msg);
    }