[Mesa-dev] [PATCH 1/3] mapi: replace mapi_table abstraction

Emil Velikov emil.l.velikov at gmail.com
Fri Apr 28 12:15:19 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

Replace all instances of mapi_table with the actual struct _glapi_table.
The former may have been needed when the OpenVG was around. But since
that one is long gone, there' no point in having the current confusing
mix of the two.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/mapi/entry.c       |  2 +-
 src/mapi/glapi/glapi.c |  2 +-
 src/mapi/mapi_abi.py   |  2 +-
 src/mapi/mapi_glapi.c  |  2 +-
 src/mapi/table.h       | 10 +++++-----
 src/mapi/u_current.c   | 20 ++++++++++----------
 src/mapi/u_current.h   | 15 ++++++---------
 7 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/src/mapi/entry.c b/src/mapi/entry.c
index 27d0db40efc..167386d8a9a 100644
--- a/src/mapi/entry.c
+++ b/src/mapi/entry.c
@@ -53,7 +53,7 @@
 
 #include <stdlib.h>
 
-static inline const struct mapi_table *
+static inline const struct _glapi_table *
 entry_current_get(void)
 {
 #ifdef MAPI_MODE_BRIDGE
diff --git a/src/mapi/glapi/glapi.c b/src/mapi/glapi/glapi.c
index 194b9ee865d..55258a476c7 100644
--- a/src/mapi/glapi/glapi.c
+++ b/src/mapi/glapi/glapi.c
@@ -60,5 +60,5 @@ _glapi_set_context(void *context)
 void
 _glapi_set_dispatch(struct _glapi_table *dispatch)
 {
-   u_current_set_table((const struct mapi_table *) dispatch);
+   u_current_set_table((const struct _glapi_table *) dispatch);
 }
diff --git a/src/mapi/mapi_abi.py b/src/mapi/mapi_abi.py
index 2343182d116..adb5d77126d 100644
--- a/src/mapi/mapi_abi.py
+++ b/src/mapi/mapi_abi.py
@@ -437,7 +437,7 @@ class ABIPrinter(object):
             if ent.ret:
                 ret = 'return '
             stmt1 = self.indent
-            stmt1 += 'const struct mapi_table *_tbl = %s();' % (
+            stmt1 += 'const struct _glapi_table *_tbl = %s();' % (
                     self.current_get)
             stmt2 = self.indent
             stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % (
diff --git a/src/mapi/mapi_glapi.c b/src/mapi/mapi_glapi.c
index 9f02edb7cd3..3a376e81bdd 100644
--- a/src/mapi/mapi_glapi.c
+++ b/src/mapi/mapi_glapi.c
@@ -65,7 +65,7 @@ _glapi_set_context(void *context)
 void
 _glapi_set_dispatch(struct _glapi_table *dispatch)
 {
-   u_current_set_table((const struct mapi_table *) dispatch);
+   u_current_set_table((const struct _glapi_table *) dispatch);
 }
 
 /**
diff --git a/src/mapi/table.h b/src/mapi/table.h
index a1af40c6fc1..f488b6d8a75 100644
--- a/src/mapi/table.h
+++ b/src/mapi/table.h
@@ -37,7 +37,7 @@
 #define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC)
 #define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func))
 
-struct mapi_table;
+struct _glapi_table;
 
 extern const mapi_func table_noop_array[];
 
@@ -52,17 +52,17 @@ table_set_noop_handler(nop_handler_proc func);
 /**
  * Get the no-op dispatch table.
  */
-static inline const struct mapi_table *
+static inline const struct _glapi_table *
 table_get_noop(void)
 {
-   return (const struct mapi_table *) table_noop_array;
+   return (const struct _glapi_table *) table_noop_array;
 }
 
 /**
  * Set the function of a slot.
  */
 static inline void
-table_set_func(struct mapi_table *tbl, int slot, mapi_func func)
+table_set_func(struct _glapi_table *tbl, int slot, mapi_func func)
 {
    mapi_func *funcs = (mapi_func *) tbl;
    funcs[slot] = func;
@@ -72,7 +72,7 @@ table_set_func(struct mapi_table *tbl, int slot, mapi_func func)
  * Return the function of a slot.
  */
 static inline mapi_func
-table_get_func(const struct mapi_table *tbl, int slot)
+table_get_func(const struct _glapi_table *tbl, int slot)
 {
    const mapi_func *funcs = (const mapi_func *) tbl;
    return funcs[slot];
diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c
index 7e7e275f2e3..1402cea45d5 100644
--- a/src/mapi/u_current.c
+++ b/src/mapi/u_current.c
@@ -99,17 +99,17 @@ extern void (*__glapi_noop_table[])(void);
 /*@{*/
 #if defined(GLX_USE_TLS)
 
-__thread struct mapi_table *u_current_table
+__thread struct _glapi_table *u_current_table
     __attribute__((tls_model("initial-exec")))
-    = (struct mapi_table *) table_noop_array;
+    = (struct _glapi_table *) table_noop_array;
 
 __thread void *u_current_context
     __attribute__((tls_model("initial-exec")));
 
 #else
 
-struct mapi_table *u_current_table =
-   (struct mapi_table *) table_noop_array;
+struct _glapi_table *u_current_table =
+   (struct _glapi_table *) table_noop_array;
 void *u_current_context;
 
 tss_t u_current_table_tsd;
@@ -259,17 +259,17 @@ u_current_get_context_internal(void)
  * table (__glapi_noop_table).
  */
 void
-u_current_set_table(const struct mapi_table *tbl)
+u_current_set_table(const struct _glapi_table *tbl)
 {
    u_current_init();
 
    stub_init_once();
 
    if (!tbl)
-      tbl = (const struct mapi_table *) table_noop_array;
+      tbl = (const struct _glapi_table *) table_noop_array;
 
 #if defined(GLX_USE_TLS)
-   u_current_table = (struct mapi_table *) tbl;
+   u_current_table = (struct _glapi_table *) tbl;
 #else
    tss_set(u_current_table_tsd, (void *) tbl);
    u_current_table = (ThreadSafe) ? NULL : (void *) tbl;
@@ -279,15 +279,15 @@ u_current_set_table(const struct mapi_table *tbl)
 /**
  * Return pointer to current dispatch table for calling thread.
  */
-struct mapi_table *
+struct _glapi_table *
 u_current_get_table_internal(void)
 {
 #if defined(GLX_USE_TLS)
    return u_current_table;
 #else
    if (ThreadSafe)
-      return (struct mapi_table *) tss_get(u_current_table_tsd);
+      return (struct _glapi_table *) tss_get(u_current_table_tsd);
    else
-      return (struct mapi_table *) u_current_table;
+      return (struct _glapi_table *) u_current_table;
 #endif
 }
diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h
index ea4f8172346..3c9a414ee84 100644
--- a/src/mapi/u_current.h
+++ b/src/mapi/u_current.h
@@ -10,9 +10,6 @@
 
 #include "glapi/glapi.h"
 
-/* ugly renames to match glapi.h */
-#define mapi_table _glapi_table
-
 #ifdef GLX_USE_TLS
 #define u_current_table _glapi_tls_Dispatch
 #define u_current_context _glapi_tls_Context
@@ -28,11 +25,11 @@
 
 #else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
 
-struct mapi_table;
+struct _glapi_table;
 
 #ifdef GLX_USE_TLS
 
-extern __thread struct mapi_table *u_current_table
+extern __thread struct _glapi_table *u_current_table
     __attribute__((tls_model("initial-exec")));
 
 extern __thread void *u_current_context
@@ -40,7 +37,7 @@ extern __thread void *u_current_context
 
 #else /* GLX_USE_TLS */
 
-extern struct mapi_table *u_current_table;
+extern struct _glapi_table *u_current_table;
 extern void *u_current_context;
 
 #endif /* GLX_USE_TLS */
@@ -54,9 +51,9 @@ void
 u_current_destroy(void);
 
 void
-u_current_set_table(const struct mapi_table *tbl);
+u_current_set_table(const struct _glapi_table *tbl);
 
-struct mapi_table *
+struct _glapi_table *
 u_current_get_table_internal(void);
 
 void
@@ -65,7 +62,7 @@ u_current_set_context(const void *ptr);
 void *
 u_current_get_context_internal(void);
 
-static inline const struct mapi_table *
+static inline const struct _glapi_table *
 u_current_get_table(void)
 {
 #ifdef GLX_USE_TLS
-- 
2.12.2



More information about the mesa-dev mailing list