Folded glapinoop.c code into glapi.c. Added code to glapitemp.h to fill in dispatch tables. Updated Makefiles.tags/mesa_3_5
@@ -1,8 +1,8 @@ | |||
# $Id: Makefile.X11,v 1.47 2001/03/19 02:25:35 keithw Exp $ | |||
# $Id: Makefile.X11,v 1.48 2001/03/28 17:19:58 brianp Exp $ | |||
# Mesa 3-D graphics library | |||
# Version: 3.5 | |||
# Copyright (C) 1995-2000 Brian Paul | |||
# Copyright (C) 1995-2001 Brian Paul | |||
# Makefile for core library | |||
@@ -74,7 +74,6 @@ CORE_SOURCES = \ | |||
fog.c \ | |||
get.c \ | |||
glapi.c \ | |||
glapinoop.c \ | |||
glthread.c \ | |||
hash.c \ | |||
highpc.c \ |
@@ -1,4 +1,4 @@ | |||
/* $Id: glapi.c,v 1.51 2001/03/12 00:48:38 gareth Exp $ */ | |||
/* $Id: glapi.c,v 1.52 2001/03/28 17:19:58 brianp Exp $ */ | |||
/* | |||
* Mesa 3-D graphics library | |||
@@ -48,31 +48,128 @@ | |||
#include "glheader.h" | |||
#include "glapi.h" | |||
#include "glapinoop.h" | |||
#include "glapioffsets.h" | |||
#include "glapitable.h" | |||
#include "glthread.h" | |||
/* This is used when thread safety is disabled */ | |||
struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; | |||
struct _glapi_table *_glapi_RealDispatch = (struct _glapi_table *) __glapi_noop_table; | |||
/* Used when thread safety disabled */ | |||
void *_glapi_Context = NULL; | |||
/***** BEGIN NO-OP DISPATCH *****/ | |||
static GLboolean WarnFlag = GL_FALSE; | |||
void | |||
_glapi_noop_enable_warnings(GLboolean enable) | |||
{ | |||
WarnFlag = enable; | |||
} | |||
static GLboolean | |||
warn(void) | |||
{ | |||
if (WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) | |||
return GL_TRUE; | |||
else | |||
return GL_FALSE; | |||
} | |||
#define KEYWORD1 static | |||
#define KEYWORD2 | |||
#define NAME(func) NoOp##func | |||
#define F stderr | |||
#define DISPATCH(func, args, msg) \ | |||
if (warn()) { \ | |||
fprintf(stderr, "GL User Error: calling "); \ | |||
fprintf msg; \ | |||
fprintf(stderr, " without a current context\n"); \ | |||
} | |||
#define RETURN_DISPATCH(func, args, msg) \ | |||
if (warn()) { \ | |||
fprintf(stderr, "GL User Error: calling "); \ | |||
fprintf msg; \ | |||
fprintf(stderr, " without a current context\n"); \ | |||
} \ | |||
return 0 | |||
#define DISPATCH_TABLE_NAME __glapi_noop_table | |||
#define UNUSED_TABLE_NAME __usused_noop_functions | |||
#define TABLE_ENTRY(name) (void *) NoOp##name | |||
static int NoOpUnused(void) | |||
{ | |||
if (warn()) { | |||
fprintf(stderr, "GL User Error: calling extension function without a current context\n"); | |||
} | |||
return 0; | |||
} | |||
#include "glapitemp.h" | |||
/***** END NO-OP DISPATCH *****/ | |||
/***** BEGIN THREAD-SAFE DISPATCH *****/ | |||
/* if we support thread-safety, build a special dispatch table for use | |||
* in thread-safety mode (ThreadSafe == GL_TRUE). Each entry in the | |||
* dispatch table will call _glthread_GetTSD() to get the actual dispatch | |||
* table bound to the current thread, then jump through that table. | |||
*/ | |||
#if defined(THREADS) | |||
/* Flag to indicate whether thread-safe dispatch is enabled */ | |||
static GLboolean ThreadSafe = GL_FALSE; | |||
static GLboolean ThreadSafe = GL_FALSE; /* In thread-safe mode? */ | |||
static _glthread_TSD DispatchTSD; /* Per-thread dispatch pointer */ | |||
static _glthread_TSD RealDispatchTSD; /* only when using override */ | |||
static _glthread_TSD ContextTSD; /* Per-thread context pointer */ | |||
static _glthread_TSD DispatchTSD; | |||
static _glthread_TSD RealDispatchTSD; /* only when using override */ | |||
#define KEYWORD1 static | |||
#define KEYWORD2 GLAPIENTRY | |||
#define NAME(func) _ts_##func | |||
static _glthread_TSD ContextTSD; | |||
#define DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
struct _glapi_table *dispatch; \ | |||
dispatch = (struct _glapi_table *) _glthread_GetTSD(&DispatchTSD); \ | |||
if (!dispatch) \ | |||
dispatch = (struct _glapi_table *) __glapi_noop_table; \ | |||
(dispatch->FUNC) ARGS | |||
#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
struct _glapi_table *dispatch; \ | |||
dispatch = (struct _glapi_table *) _glthread_GetTSD(&DispatchTSD); \ | |||
if (!dispatch) \ | |||
dispatch = (struct _glapi_table *) __glapi_noop_table; \ | |||
return (dispatch->FUNC) ARGS | |||
#define DISPATCH_TABLE_NAME __glapi_threadsafe_table | |||
#define UNUSED_TABLE_NAME __usused_threadsafe_functions | |||
#define TABLE_ENTRY(name) (void *) _ts_##name | |||
static int _ts_Unused(void) | |||
{ | |||
return 0; | |||
} | |||
#include "glapitemp.h" | |||
#endif | |||
/***** END THREAD-SAFE DISPATCH *****/ | |||
struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; | |||
struct _glapi_table *_glapi_RealDispatch = (struct _glapi_table *) __glapi_noop_table; | |||
/* Used when thread safety disabled */ | |||
void *_glapi_Context = NULL; | |||
static GLuint MaxDispatchOffset = sizeof(struct _glapi_table) / sizeof(void *) - 1; | |||
@@ -81,10 +178,11 @@ static GLboolean GetSizeCalled = GL_FALSE; | |||
static GLboolean DispatchOverride = GL_FALSE; | |||
/* strdup is actually not a standard ANSI C or POSIX routine | |||
Irix will not define it if ANSI mode is in effect. */ | |||
static char *str_dup(const char *str) | |||
/* strdup() is actually not a standard ANSI C or POSIX routine. | |||
* Irix will not define it if ANSI mode is in effect. | |||
*/ | |||
static char * | |||
str_dup(const char *str) | |||
{ | |||
char *copy; | |||
copy = (char*) malloc(strlen(str) + 1); | |||
@@ -113,6 +211,7 @@ _glapi_check_multithread(void) | |||
firstCall = GL_FALSE; | |||
} | |||
else if (knownID != _glthread_GetID()) { | |||
printf("Going thread-safe\n"); | |||
ThreadSafe = GL_TRUE; | |||
} | |||
} | |||
@@ -190,7 +289,7 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) | |||
if (DispatchOverride) { | |||
_glthread_SetTSD(&RealDispatchTSD, (void *) dispatch); | |||
if (ThreadSafe) | |||
_glapi_RealDispatch = NULL; | |||
_glapi_RealDispatch = (struct _glapi_table*) __glapi_threadsafe_table; | |||
else | |||
_glapi_RealDispatch = dispatch; | |||
} | |||
@@ -198,7 +297,7 @@ _glapi_set_dispatch(struct _glapi_table *dispatch) | |||
/* normal operation */ | |||
_glthread_SetTSD(&DispatchTSD, (void *) dispatch); | |||
if (ThreadSafe) | |||
_glapi_Dispatch = NULL; | |||
_glapi_Dispatch = (struct _glapi_table *) __glapi_threadsafe_table; | |||
else | |||
_glapi_Dispatch = dispatch; | |||
} | |||
@@ -280,7 +379,7 @@ _glapi_begin_dispatch_override(struct _glapi_table *override) | |||
#if defined(THREADS) | |||
_glthread_SetTSD(&DispatchTSD, (void *) override); | |||
if (ThreadSafe) | |||
_glapi_Dispatch = NULL; | |||
_glapi_Dispatch = (struct _glapi_table *) __glapi_threadsafe_table; | |||
else | |||
_glapi_Dispatch = override; | |||
#else |
@@ -1,4 +1,4 @@ | |||
/* $Id: glapi.h,v 1.18 2001/01/23 23:35:47 brianp Exp $ */ | |||
/* $Id: glapi.h,v 1.19 2001/03/28 17:20:20 brianp Exp $ */ | |||
/* | |||
* Mesa 3-D graphics library | |||
@@ -39,6 +39,10 @@ extern void *_glapi_Context; | |||
extern struct _glapi_table *_glapi_Dispatch; | |||
extern void | |||
_glapi_noop_enable_warnings(GLboolean enable); | |||
extern void | |||
_glapi_check_multithread(void); | |||
@@ -1,29 +1,12 @@ | |||
# $Id: Makefile.DJ,v 1.9 2000/09/26 21:22:20 brianp Exp $ | |||
# $Id: Makefile.DJ,v 1.10 2001/03/28 17:19:58 brianp Exp $ | |||
# Mesa 3-D graphics library | |||
# Version: 3.5 | |||
# Copyright (C) 1995-1998 Brian Paul | |||
# | |||
# This library is free software; you can redistribute it and/or | |||
# modify it under the terms of the GNU Library General Public | |||
# License as published by the Free Software Foundation; either | |||
# version 2 of the License, or (at your option) any later version. | |||
# | |||
# This library is distributed in the hope that it will be useful, | |||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
# Library General Public License for more details. | |||
# | |||
# You should have received a copy of the GNU Library General Public | |||
# License along with this library; if not, write to the Free | |||
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
# Copyright (C) 1995-2001 Brian Paul | |||
# Makefile for core library for MS-DOS using djgpp | |||
##### MACROS ##### | |||
VPATH = RCS | |||
@@ -67,7 +50,6 @@ CORE_SOURCES = \ | |||
fog.c \ | |||
get.c \ | |||
glapi.c \ | |||
glapinoop.c \ | |||
glthread.c \ | |||
hash.c \ | |||
hint.c \ |
@@ -1,8 +1,8 @@ | |||
# $Id: Makefile.X11,v 1.47 2001/03/19 02:25:35 keithw Exp $ | |||
# $Id: Makefile.X11,v 1.48 2001/03/28 17:19:58 brianp Exp $ | |||
# Mesa 3-D graphics library | |||
# Version: 3.5 | |||
# Copyright (C) 1995-2000 Brian Paul | |||
# Copyright (C) 1995-2001 Brian Paul | |||
# Makefile for core library | |||
@@ -74,7 +74,6 @@ CORE_SOURCES = \ | |||
fog.c \ | |||
get.c \ | |||
glapi.c \ | |||
glapinoop.c \ | |||
glthread.c \ | |||
hash.c \ | |||
highpc.c \ |
@@ -1,4 +1,4 @@ | |||
/* $Id: context.c,v 1.130 2001/03/24 06:01:27 gareth Exp $ */ | |||
/* $Id: context.c,v 1.131 2001/03/28 17:20:20 brianp Exp $ */ | |||
/* | |||
* Mesa 3-D graphics library | |||
@@ -39,7 +39,6 @@ | |||
#include "extensions.h" | |||
#include "fog.h" | |||
#include "get.h" | |||
#include "glapinoop.h" | |||
#include "glthread.h" | |||
#include "hash.h" | |||
#include "imports.h" |
@@ -1,4 +1,4 @@ | |||
/* $Id: dispatch.c,v 1.21 2001/03/26 23:36:51 brianp Exp $ */ | |||
/* $Id: dispatch.c,v 1.22 2001/03/28 17:20:20 brianp Exp $ */ | |||
/* | |||
* Mesa 3-D graphics library | |||
@@ -28,9 +28,7 @@ | |||
/* | |||
* This file generates all the gl* function entyrpoints. | |||
* But if we're using X86-optimized dispatch (X86/glapi_x86.S) then | |||
* each of the entrypoints will be prefixed with _glapi_fallback_* | |||
* and will be called by the glapi_x86.S code when we're in thread- | |||
* safe mode. | |||
* we don't use this file's code. | |||
* | |||
* Eventually this file may be replaced by automatically generated | |||
* code from an API spec file. | |||
@@ -41,7 +39,6 @@ | |||
*/ | |||
#ifdef PC_HEADER | |||
#include "all.h" | |||
#else | |||
@@ -51,64 +48,21 @@ | |||
#include "glthread.h" | |||
#endif | |||
#if !defined(USE_X86_ASM) | |||
#define KEYWORD1 | |||
#define KEYWORD2 GLAPIENTRY | |||
#if defined(USE_X86_ASM) && !defined(__WIN32__) && !defined(XF86DRI) | |||
#define NAME(func) _glapi_fallback_##func | |||
#elif defined(USE_MGL_NAMESPACE) | |||
#if defined(USE_MGL_NAMESPACE) | |||
#define NAME(func) mgl##func | |||
#else | |||
#define NAME(func) gl##func | |||
#endif | |||
#ifdef DEBUG | |||
#if 0 | |||
static int | |||
trace(void) | |||
{ | |||
static int trace = -1; | |||
if (trace < 0) | |||
trace = getenv("MESA_TRACE") ? 1 : 0; | |||
return trace > 0; | |||
} | |||
#endif | |||
#define F stderr | |||
#define DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
const struct _glapi_table *dispatch; \ | |||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ | |||
(dispatch->FUNC) ARGS | |||
#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
const struct _glapi_table *dispatch; \ | |||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ | |||
return (dispatch->FUNC) ARGS | |||
#if 0 | |||
/* From both macros above... */ | |||
if (trace()) { \ | |||
fprintf MESSAGE; \ | |||
fprintf(F, "\n"); \ | |||
} | |||
#endif | |||
#else | |||
#define DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
const struct _glapi_table *dispatch; \ | |||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ | |||
(dispatch->FUNC) ARGS | |||
#define DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
(_glapi_Dispatch->FUNC) ARGS | |||
#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
const struct _glapi_table *dispatch; \ | |||
dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\ | |||
return (dispatch->FUNC) ARGS | |||
#endif | |||
#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ | |||
return (_glapi_Dispatch->FUNC) ARGS | |||
#ifndef GLAPIENTRY | |||
@@ -116,3 +70,6 @@ trace(void) | |||
#endif | |||
#include "glapitemp.h" | |||
#endif /* USE_X86_ASM */ |