diff options
author | Brian Paul <[email protected]> | 2015-03-13 10:20:29 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2015-03-18 09:01:50 -0600 |
commit | 201e36e77d6ca616f75f14d5f1c31f0062ae4366 (patch) | |
tree | 757c6cfd8dee3d9c6bac6a2c612f2da0c8299a47 /src/mapi/mapi_glapi.c | |
parent | aee26d292f165438577426f5e62a62ec2a1514c9 (diff) |
mapi: add new _glapi_new_nop_table() and _glapi_set_nop_handler()
_glapi_new_nop_table() creates a new dispatch table populated with
pointers to no-op functions.
_glapi_set_nop_handler() is used to register a callback function which
will be called from each of the no-op functions.
Now we always generate a separate no-op function for each GL entrypoint.
This allows us to do proper stack clean-up for Windows __stdcall and
lets us report the actual function name in error messages. Before this
change, for non-Windows release builds we used a single no-op function
for all entrypoints.
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/mapi/mapi_glapi.c')
-rw-r--r-- | src/mapi/mapi_glapi.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c index 127dfafac30..70605f3dfa1 100644 --- a/src/mapi/mapi_glapi.c +++ b/src/mapi/mapi_glapi.c @@ -27,6 +27,7 @@ */ #include <string.h> +#include <stdlib.h> #include "glapi/glapi.h" #include "u_current.h" #include "table.h" /* for MAPI_TABLE_NUM_SLOTS */ @@ -222,6 +223,28 @@ _glapi_get_proc_name(unsigned int offset) return stub ? stub_get_name(stub) : NULL; } +/** Return pointer to new dispatch table filled with no-op functions */ +struct _glapi_table * +_glapi_new_nop_table(unsigned num_entries) +{ + struct _glapi_table *table; + + if (num_entries > MAPI_TABLE_NUM_SLOTS) + num_entries = MAPI_TABLE_NUM_SLOTS; + + table = malloc(num_entries * sizeof(mapi_func)); + if (table) { + memcpy(table, table_noop_array, num_entries * sizeof(mapi_func)); + } + return table; +} + +void +_glapi_set_nop_handler(_glapi_nop_handler_proc func) +{ + table_set_noop_handler(func); +} + /** * This is a deprecated function which should not be used anymore. * It's only present to satisfy linking with older versions of libGL. |