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).
This commit is contained in:
Ian Romanick 2005-04-14 21:05:55 +00:00
parent f434e07a6a
commit 6cae4f3bc9
3 changed files with 28 additions and 28 deletions

View file

@ -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

View file

@ -64,9 +64,10 @@
#define GLTHREAD_H
#if defined(PTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
defined(XTHREADS) || defined(BEOS_THREADS)
#define THREADS
#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
defined(WIN32_THREADS) || defined(XTHREADS) || defined(BEOS_THREADS)) \
&& !defined(THREADS)
# define THREADS
#endif
#ifdef VMS

View file

@ -169,31 +169,6 @@ _mesa_get_current_context(void);
/*@}*/
/**
* 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
/**********************************************************************/
/** \name OpenGL SI-style export functions. */
/*@{*/