diff options
author | Brian Paul <[email protected]> | 2000-02-12 16:44:24 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2000-02-12 16:44:24 +0000 |
commit | ef5d084d3c86beb132ddf9829d28ea78cb9f0197 (patch) | |
tree | b612723e39532d91707872628ecc9bd9620a9930 /src/mesa/glapi | |
parent | e39ed58116bec6c938cbda42e2021ff29823a122 (diff) |
clean-up
Diffstat (limited to 'src/mesa/glapi')
-rw-r--r-- | src/mesa/glapi/glapi.c | 82 | ||||
-rw-r--r-- | src/mesa/glapi/glapitable.h | 8 |
2 files changed, 67 insertions, 23 deletions
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index 51c24f980cc..65acafb246d 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -1,4 +1,4 @@ -/* $Id: glapi.c,v 1.32 2000/02/10 21:27:48 brianp Exp $ */ +/* $Id: glapi.c,v 1.33 2000/02/12 16:44:25 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -272,13 +272,16 @@ get_static_proc_address(const char *funcName) */ +#define MAX_EXTENSION_FUNCS 1000 + + struct _glapi_ext_entrypoint { const char *Name; /* the extension function's name */ GLuint Offset; /* relative to start of dispatch table */ GLvoid *Address; /* address of dispatch function */ }; -static struct _glapi_ext_entrypoint ExtEntryTable[_GLAPI_EXTRA_SLOTS]; +static struct _glapi_ext_entrypoint ExtEntryTable[MAX_EXTENSION_FUNCS]; static GLuint NumExtEntryPoints = 0; @@ -354,10 +357,8 @@ _glapi_add_entrypoint(const char *funcName, GLuint offset) index = get_static_proc_offset(funcName); if (index >= 0) { - assert(index == offset); - return GL_TRUE; + return (GLboolean) (index == offset); /* bad offset! */ } - /* else if (offset < _glapi_get_dispatch_table_size()) { */ else { /* be sure index and name match known data */ GLuint i; @@ -372,24 +373,73 @@ _glapi_add_entrypoint(const char *funcName, GLuint offset) } } } - assert(NumExtEntryPoints < _GLAPI_EXTRA_SLOTS); - ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName); - ExtEntryTable[NumExtEntryPoints].Offset = offset; - ExtEntryTable[NumExtEntryPoints].Address = generate_entrypoint(offset); - NumExtEntryPoints++; - if (offset > MaxDispatchOffset) - MaxDispatchOffset = offset; + /* make sure we have space */ + if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS) { + return GL_FALSE; + } + else { + void *entrypoint = generate_entrypoint(offset); + if (!entrypoint) + return GL_FALSE; + + ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName); + ExtEntryTable[NumExtEntryPoints].Offset = offset; + ExtEntryTable[NumExtEntryPoints].Address = entrypoint; + NumExtEntryPoints++; + + if (offset > MaxDispatchOffset) + MaxDispatchOffset = offset; - return GL_TRUE; + return GL_TRUE; /* success */ + } } + + /* should never get here, but play it safe */ + return GL_FALSE; +} + + + +#if 0000 /* prototype code for dynamic extension slot allocation */ + +static int NextFreeOffset = 409; /*XXX*/ +#define MAX_DISPATCH_TABLE_SIZE 1000 + /* - else { - return GL_FALSE; + * Dynamically allocate a dispatch slot for an extension entrypoint + * and generate the assembly language dispatch stub. + * Return the dispatch offset for the function or -1 if no room or error. + */ +GLint +_glapi_add_entrypoint2(const char *funcName) +{ + int offset; + + /* first see if extension func is already known */ + offset = _glapi_get_proc_offset(funcName); + if (offset >= 0) + return offset; + + if (NumExtEntryPoints < MAX_EXTENSION_FUNCS + && NextFreeOffset < MAX_DISPATCH_TABLE_SIZE) { + void *entryPoint; + offset = NextFreeOffset; + entryPoint = generate_entrypoint(offset); + if (entryPoint) { + NextFreeOffset++; + ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName); + ExtEntryTable[NumExtEntryPoints].Offset = offset; + ExtEntryTable[NumExtEntryPoints].Address = entryPoint; + NumExtEntryPoints++; + return offset; + } } -*/ + return -1; } +#endif + /* diff --git a/src/mesa/glapi/glapitable.h b/src/mesa/glapi/glapitable.h index ecdbb5d35b6..cd4349536f9 100644 --- a/src/mesa/glapi/glapitable.h +++ b/src/mesa/glapi/glapitable.h @@ -1,4 +1,4 @@ -/* $Id: glapitable.h,v 1.9 2000/02/11 21:14:28 brianp Exp $ */ +/* $Id: glapitable.h,v 1.10 2000/02/12 16:44:24 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -44,9 +44,6 @@ #include "GL/gl.h" -#define _GLAPI_EXTRA_SLOTS 1000 - - /* * This struct contains pointers for all the GL API entrypoints * plus some reserved slots for dynamic extensions. @@ -851,9 +848,6 @@ struct _glapi_table void (*MultTransposeMatrixdARB)(const GLdouble m[16]); void (*MultTransposeMatrixfARB)(const GLfloat m[16]); -#if 0 - void *ExtensionFuncs[_GLAPI_EXTRA_SLOTS]; -#endif }; |