[Mesa-dev] [PATCH 1/2] shared-glapi: implement _glapi_get_proc_name().

Matt Turner mattst88 at gmail.com
Wed Oct 24 14:25:22 PDT 2012


On Tue, Oct 23, 2012 at 12:37 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> Previously this function was only implemented for non-shared-glapi
> builds.  Since the function is only intended for debugging purposes we
> use a simple O(n) algorithm.
> ---
>  src/mapi/mapi/mapi_glapi.c |  4 ++--
>  src/mapi/mapi/stub.c       | 22 ++++++++++++++++++++++
>  src/mapi/mapi/stub.h       |  3 +++
>  3 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/src/mapi/mapi/mapi_glapi.c b/src/mapi/mapi/mapi_glapi.c
> index adfc0cb..4627c4d 100644
> --- a/src/mapi/mapi/mapi_glapi.c
> +++ b/src/mapi/mapi/mapi_glapi.c
> @@ -219,8 +219,8 @@ _glapi_get_proc_address(const char *funcName)
>  const char *
>  _glapi_get_proc_name(unsigned int offset)
>  {
> -   /* not implemented */
> -   return NULL;
> +   const struct mapi_stub *stub = stub_find_by_slot(offset);
> +   return stub ? stub_get_name(stub) : NULL;
>  }
>
>  unsigned long
> diff --git a/src/mapi/mapi/stub.c b/src/mapi/mapi/stub.c
> index 6fb8556..688dc81 100644
> --- a/src/mapi/mapi/stub.c
> +++ b/src/mapi/mapi/stub.c
> @@ -153,6 +153,28 @@ stub_find_dynamic(const char *name, int generate)
>     return stub;
>  }
>
> +static const struct mapi_stub *
> +search_table_by_slot(const struct mapi_stub *table, size_t num_entries,
> +                     int slot)
> +{
> +   size_t i;
> +   for (i = 0; i < num_entries; ++i) {
> +      if (table[i].slot == slot)
> +         return &table[i];
> +   }
> +   return NULL;
> +}
> +
> +const struct mapi_stub *
> +stub_find_by_slot(int slot)
> +{
> +   const struct mapi_stub *stub =
> +      search_table_by_slot(public_stubs, ARRAY_SIZE(public_stubs), slot);
> +   if (stub)
> +      return stub;
> +   return search_table_by_slot(dynamic_stubs, num_dynamic_stubs, slot);
> +}
> +
>  void
>  stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias)
>  {
> diff --git a/src/mapi/mapi/stub.h b/src/mapi/mapi/stub.h
> index b2b6f18..98e2553 100644
> --- a/src/mapi/mapi/stub.h
> +++ b/src/mapi/mapi/stub.h
> @@ -42,6 +42,9 @@ stub_find_public(const char *name);
>  struct mapi_stub *
>  stub_find_dynamic(const char *name, int generate);
>
> +const struct mapi_stub *
> +stub_find_by_slot(int slot);
> +
>  void
>  stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias);
>
> --
> 1.7.12.4

Thanks for doing this.

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list