egl: don't fill client apis string forever.
[mesa.git] / src / egl / main / eglscreen.c
index fc3ab322ab0e0862af4c3ab2d550cce98cd78914..42ac621fcd98d5f3602d96c7414140413200c084 100644 (file)
@@ -1,3 +1,33 @@
+/**************************************************************************
+ *
+ * Copyright 2008 VMware, Inc.
+ * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
+ * Copyright 2010 LunarG, Inc.
+ * 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.
+ *
+ **************************************************************************/
+
+
 /*
  * Ideas for screen management extension to EGL.
  *
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include "c11/threads.h"
 
 #include "egldisplay.h"
 #include "eglcurrent.h"
 #include "eglmode.h"
-#include "eglconfig.h"
 #include "eglsurface.h"
 #include "eglscreen.h"
-#include "eglmutex.h"
 
 
 #ifdef EGL_MESA_screen_surface
 
 
 /* ugh, no atomic op? */
-static _EGL_DECLARE_MUTEX(_eglNextScreenHandleMutex);
+static mtx_t _eglNextScreenHandleMutex = _MTX_INITIALIZER_NP;
 static EGLScreenMESA _eglNextScreenHandle = 1;
 
 
@@ -41,10 +70,10 @@ _eglAllocScreenHandle(void)
 {
    EGLScreenMESA s;
 
-   _eglLockMutex(&_eglNextScreenHandleMutex);
+   mtx_lock(&_eglNextScreenHandleMutex);
    s = _eglNextScreenHandle;
    _eglNextScreenHandle += _EGL_SCREEN_MAX_MODES;
-   _eglUnlockMutex(&_eglNextScreenHandleMutex);
+   mtx_unlock(&_eglNextScreenHandleMutex);
 
    return s;
 }
@@ -65,7 +94,7 @@ _eglInitScreen(_EGLScreen *screen, _EGLDisplay *dpy, EGLint num_modes)
 
    if (num_modes > _EGL_SCREEN_MAX_MODES)
       num_modes = _EGL_SCREEN_MAX_MODES;
-   screen->Modes = (_EGLMode *) calloc(num_modes, sizeof(*screen->Modes));
+   screen->Modes = calloc(num_modes, sizeof(*screen->Modes));
    screen->NumModes = (screen->Modes) ? num_modes : 0;
 }