From 6cae4f3bc9b92f9bbda753843e8ff0f0bbbb8fb3 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 14 Apr 2005 21:05:55 +0000 Subject: In GLX_USE_TLS builds, make GET_CURRENT_CONTEXT use the TLS verion of the variable. Without this, GET_CURRENT_CONTEXT would *always* result in a call to _glapi_get_context (because _glapi_Context is a const pointer to NULL in TLS builds). --- src/mesa/glapi/glapi.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/mesa/glapi/glapi.h') diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index e3ef066e69..fa4554ec7b 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -59,11 +59,35 @@ typedef void (*_glapi_proc)(void); /* generic function pointer */ const extern void *_glapi_Context; const extern struct _glapi_table *_glapi_Dispatch; +extern __thread void * _glapi_tls_Context + __attribute__((tls_model("initial-exec"))); + +# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context + #else extern void *_glapi_Context; extern struct _glapi_table *_glapi_Dispatch; +/** + * Macro for declaration and fetching the current context. + * + * \param C local variable which will hold the current context. + * + * It should be used in the variable declaration area of a function: + * \code + * ... + * { + * GET_CURRENT_CONTEXT(ctx); + * ... + * \endcode + */ +# ifdef THREADS +# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()) +# else +# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context +# endif + #endif /* defined (GLX_USE_TLS) */ extern void -- cgit v1.2.3