diff options
-rw-r--r-- | src/mesa/glapi/glapi.c | 29 | ||||
-rw-r--r-- | src/mesa/glapi/glapi.h | 4 | ||||
-rw-r--r-- | src/mesa/main/context.h | 10 |
3 files changed, 20 insertions, 23 deletions
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index ed1a0c97da1..97cb1c8c8df 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -1,4 +1,4 @@ -/* $Id: glapi.c,v 1.18 1999/12/17 14:51:28 brianp Exp $ */ +/* $Id: glapi.c,v 1.19 2000/01/05 04:36:17 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -49,7 +49,7 @@ /* Flag to indicate whether thread-safe dispatch is enabled */ -GLboolean _glapi_ThreadSafe = GL_FALSE; +static GLboolean ThreadSafe = GL_FALSE; /* This is used when thread safety is disabled */ static struct _glapi_table *Dispatch = &__glapi_noop_table; @@ -95,7 +95,7 @@ void _glapi_check_multithread(void) { #if defined(THREADS) - if (!_glapi_ThreadSafe) { + if (!ThreadSafe) { static unsigned long knownID; static GLboolean firstCall = GL_TRUE; if (firstCall) { @@ -103,10 +103,10 @@ _glapi_check_multithread(void) firstCall = GL_FALSE; } else if (knownID != _glthread_GetID()) { - _glapi_ThreadSafe = GL_TRUE; + ThreadSafe = GL_TRUE; } } - if (_glapi_ThreadSafe) { + if (ThreadSafe) { /* make sure that this thread's dispatch pointer isn't null */ if (!_glapi_get_dispatch()) { _glapi_set_dispatch(NULL); @@ -127,7 +127,7 @@ _glapi_set_current_context(void *context) { #if defined(THREADS) _glthread_SetTSD(&ContextTSD, context, context_thread_init); - if (_glapi_ThreadSafe) + if (ThreadSafe) _glapi_CurrentContext = NULL; /* to help with debugging */ else _glapi_CurrentContext = context; @@ -147,7 +147,7 @@ void * _glapi_get_current_context(void) { #if defined(THREADS) - if (_glapi_ThreadSafe) { + if (ThreadSafe) { return _glthread_GetTSD(&ContextTSD); } else { @@ -178,7 +178,7 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) #if defined(THREADS) _glthread_SetTSD(&DispatchTSD, (void*) dispatch, dispatch_thread_init); - if (_glapi_ThreadSafe) + if (ThreadSafe) Dispatch = NULL; /* to help with debugging */ else Dispatch = dispatch; @@ -196,7 +196,7 @@ struct _glapi_table * _glapi_get_dispatch(void) { #if defined(THREADS) - if (_glapi_ThreadSafe) { + if (ThreadSafe) { return (struct _glapi_table *) _glthread_GetTSD(&DispatchTSD); } else { @@ -505,14 +505,9 @@ _glapi_check_table(const struct _glapi_table *table) #define NAME(func) gl##func #endif -#define DISPATCH_SETUP \ - const struct _glapi_table *dispatch; \ - if (_glapi_ThreadSafe) { \ - dispatch = _glapi_get_dispatch(); \ - } \ - else { \ - dispatch = Dispatch; \ - } +#define DISPATCH_SETUP \ + const struct _glapi_table *dispatch; \ + dispatch = Dispatch ? Dispatch : _glapi_get_dispatch(); #define DISPATCH(FUNC, ARGS) (dispatch->FUNC) ARGS diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 5486819da53..8673ee887ad 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -1,4 +1,4 @@ -/* $Id: glapi.h,v 1.11 1999/12/17 14:51:29 brianp Exp $ */ +/* $Id: glapi.h,v 1.12 2000/01/05 04:36:17 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -34,8 +34,6 @@ struct _glapi_table; -extern GLboolean _glapi_ThreadSafe; - extern void *_glapi_CurrentContext; diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 540b0a6ff44..c31f524fccd 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -1,4 +1,4 @@ -/* $Id: context.h,v 1.8 1999/12/17 17:01:31 brianp Exp $ */ +/* $Id: context.h,v 1.9 2000/01/05 04:36:17 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -123,9 +123,10 @@ extern GLcontext *gl_get_current_context(void); */ #ifdef THREADS -#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_ThreadSafe ? _glapi_get_current_context() : _glapi_CurrentContext) +#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_CurrentContext ? _glapi_CurrentContext : _glapi_get_current_context()) + +#define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_CurrentContext ? _glapi_CurrentContext : _glapi_get_current_context()))->input -#define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_ThreadSafe ? _glapi_get_current_context() : _glapi_CurrentContext))->input; #define SET_IMMEDIATE(ctx, im) \ do { \ ctx->input = im; \ @@ -134,8 +135,11 @@ do { \ #else extern struct immediate *CURRENT_INPUT; + #define GET_CURRENT_CONTEXT(C) GLcontext *C = _glapi_CurrentContext + #define GET_IMMEDIATE struct immediate *IM = CURRENT_INPUT + #define SET_IMMEDIATE(ctx, im) \ do { \ ctx->input = im; \ |