[Mesa-dev] [PATCH] egl: initialise dummy_thread via _eglInitThreadInfo

Eric Engestrom eric.engestrom at imgtec.com
Tue Apr 25 16:48:33 UTC 2017


On Tuesday, 2017-04-25 17:07:46 +0100, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Considering we cannot make dummy_thread a constant we might as well,
> initialise by the same function that handles the actual thread info.
> 
> This way we don't need to worry about mismatch between the initialiser
> and initialising function.
> 
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>

Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

> ---
>  src/egl/main/eglcurrent.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
> index eae7bdcea15..26f42761e26 100644
> --- a/src/egl/main/eglcurrent.c
> +++ b/src/egl/main/eglcurrent.c
> @@ -37,12 +37,8 @@
>  #include "eglcurrent.h"
>  #include "eglglobals.h"
>  
> -/* This should be kept in sync with _eglInitThreadInfo() */
> -#define _EGL_THREAD_INFO_INITIALIZER \
> -   { EGL_SUCCESS, NULL, EGL_OPENGL_ES_API, NULL, NULL, NULL }
> -
>  /* a fallback thread info to guarantee that every thread always has one */
> -static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
> +static _EGLThreadInfo dummy_thread;
>  static mtx_t _egl_TSDMutex = _MTX_INITIALIZER_NP;
>  static EGLBoolean _egl_TSDInitialized;
>  static tss_t _egl_TSD;
> @@ -109,7 +105,6 @@ static inline EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
>  static void
>  _eglInitThreadInfo(_EGLThreadInfo *t)
>  {
> -   memset(t, 0, sizeof(*t));
>     t->LastError = EGL_SUCCESS;
>     /* default, per EGL spec */
>     t->CurrentAPI = EGL_OPENGL_ES_API;
> @@ -123,10 +118,10 @@ static _EGLThreadInfo *
>  _eglCreateThreadInfo(void)
>  {
>     _EGLThreadInfo *t = calloc(1, sizeof(_EGLThreadInfo));
> -   if (t)
> -      _eglInitThreadInfo(t);
> -   else
> +   if (!t)
>        t = &dummy_thread;
> +
> +   _eglInitThreadInfo(t);
>     return t;
>  }
>  
> -- 
> 2.12.2
> 


More information about the mesa-dev mailing list