-/* $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
/* 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;
_glapi_check_multithread(void)
{
#if defined(THREADS)
- if (!_glapi_ThreadSafe) {
+ if (!ThreadSafe) {
static unsigned long knownID;
static GLboolean firstCall = GL_TRUE;
if (firstCall) {
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);
{
#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;
_glapi_get_current_context(void)
{
#if defined(THREADS)
- if (_glapi_ThreadSafe) {
+ if (ThreadSafe) {
return _glthread_GetTSD(&ContextTSD);
}
else {
#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;
_glapi_get_dispatch(void)
{
#if defined(THREADS)
- if (_glapi_ThreadSafe) {
+ if (ThreadSafe) {
return (struct _glapi_table *) _glthread_GetTSD(&DispatchTSD);
}
else {
#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
-/* $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
*/
#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; \
#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; \