summaryrefslogtreecommitdiffstats
path: root/src/mapi
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2010-08-21 12:10:02 +0800
committerChia-I Wu <[email protected]>2010-08-21 14:13:59 +0800
commitdf98423f24bca147b36076e39fe53f42028052ef (patch)
tree71ba561949eae4b13070a39b426a731410b34945 /src/mapi
parent760451baaec42bced6ade5026546ed3759495d70 (diff)
mapi: Prefix functions in u_current.h by u_current.
That is, replace the old _glapi_* names by new names that start with u_current_. When MAPI_GLAPI_CURRENT is defined, u_current.h defines rename macros to restore the old names. That is done for ABI compatibility.
Diffstat (limited to 'src/mapi')
-rw-r--r--src/mapi/mapi/entry_x86-64_tls.h4
-rw-r--r--src/mapi/mapi/entry_x86_tls.h2
-rw-r--r--src/mapi/mapi/entry_x86_tsd.h4
-rw-r--r--src/mapi/mapi/u_current.c93
-rw-r--r--src/mapi/mapi/u_current.h70
5 files changed, 94 insertions, 79 deletions
diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h
index d4c9907b895..0f6e8125e84 100644
--- a/src/mapi/mapi/entry_x86-64_tls.h
+++ b/src/mapi/mapi/entry_x86-64_tls.h
@@ -33,7 +33,7 @@
__asm__(".text");
__asm__("x86_64_current_tls:\n\t"
- "movq _glapi_tls_Dispatch@GOTTPOFF(%rip), %rax\n\t"
+ "movq u_current_table_tls@GOTTPOFF(%rip), %rax\n\t"
"ret");
#define STUB_ASM_ENTRY(func) \
@@ -43,7 +43,7 @@ __asm__("x86_64_current_tls:\n\t"
func ":"
#define STUB_ASM_CODE(slot) \
- "movq _glapi_tls_Dispatch@GOTTPOFF(%rip), %rax\n\t" \
+ "movq u_current_table_tls@GOTTPOFF(%rip), %rax\n\t" \
"movq %fs:(%rax), %r11\n\t" \
"jmp *(8 * " slot ")(%r11)"
diff --git a/src/mapi/mapi/entry_x86_tls.h b/src/mapi/mapi/entry_x86_tls.h
index de0498181de..ff2b9575f67 100644
--- a/src/mapi/mapi/entry_x86_tls.h
+++ b/src/mapi/mapi/entry_x86_tls.h
@@ -37,7 +37,7 @@ __asm__("x86_current_tls:\n\t"
"1:\n\t"
"popl %eax\n\t"
"addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t"
- "movl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax\n\t"
+ "movl u_current_table_tls@GOTNTPOFF(%eax), %eax\n\t"
"ret");
#ifndef GLX_X86_READONLY_TEXT
diff --git a/src/mapi/mapi/entry_x86_tsd.h b/src/mapi/mapi/entry_x86_tsd.h
index d31e0676f07..fbf4ec54971 100644
--- a/src/mapi/mapi/entry_x86_tsd.h
+++ b/src/mapi/mapi/entry_x86_tsd.h
@@ -41,12 +41,12 @@ __asm__(".text");
func ":"
#define STUB_ASM_CODE(slot) \
- "movl _glapi_Dispatch, %eax\n\t" \
+ "movl u_current_table, %eax\n\t" \
"testl %eax, %eax\n\t" \
"je 1f\n\t" \
"jmp *(4 * " slot ")(%eax)\n" \
"1:\n\t" \
- "call _glapi_get_dispatch\n\t" \
+ "call u_current_get_internal\n\t"\
"jmp *(4 * " slot ")(%eax)"
#define MAPI_TMP_STUB_ASM_GCC
diff --git a/src/mapi/mapi/u_current.c b/src/mapi/mapi/u_current.c
index 91547c48301..ed9ccfe2299 100644
--- a/src/mapi/mapi/u_current.c
+++ b/src/mapi/mapi/u_current.c
@@ -99,25 +99,25 @@ extern void (*__glapi_noop_table[])(void);
/*@{*/
#if defined(GLX_USE_TLS)
-__thread struct _glapi_table *_glapi_tls_Dispatch
+__thread struct mapi_table *u_current_table_tls
__attribute__((tls_model("initial-exec")))
- = (struct _glapi_table *) table_noop_array;
+ = (struct mapi_table *) table_noop_array;
-__thread void * _glapi_tls_Context
+__thread void *u_current_user_tls
__attribute__((tls_model("initial-exec")));
-const struct _glapi_table *_glapi_Dispatch;
-const void *_glapi_Context;
+const struct mapi_table *u_current_table;
+const void *u_current_user;
#else
-struct _glapi_table *_glapi_Dispatch =
- (struct _glapi_table *) table_noop_array;
-void *_glapi_Context;
+struct mapi_table *u_current_table =
+ (struct mapi_table *) table_noop_array;
+void *u_current_user;
#ifdef THREADS
-struct u_tsd _gl_DispatchTSD;
-static struct u_tsd ContextTSD;
+struct u_tsd u_current_table_tsd;
+static struct u_tsd u_current_user_tsd;
static int ThreadSafe;
#endif /* THREADS */
@@ -126,11 +126,11 @@ static int ThreadSafe;
void
-_glapi_destroy_multithread(void)
+u_current_destroy(void)
{
#if defined(THREADS) && defined(WIN32_THREADS)
- u_tsd_destroy(&_gl_DispatchTSD);
- u_tsd_destroy(&ContextTSD);
+ u_tsd_destroy(&u_current_table_tsd);
+ u_tsd_destroy(&u_current_user_tsd);
#endif
}
@@ -138,10 +138,10 @@ _glapi_destroy_multithread(void)
#if defined(THREADS) && !defined(GLX_USE_TLS)
static void
-_glapi_init_multithread(void)
+u_current_init_tsd(void)
{
- u_tsd_init(&_gl_DispatchTSD);
- u_tsd_init(&ContextTSD);
+ u_tsd_init(&u_current_table_tsd);
+ u_tsd_init(&u_current_user_tsd);
}
/**
@@ -162,7 +162,7 @@ u_mutex_declare_static(ThreadCheckMutex);
* in order to test if multiple threads are being used.
*/
void
-_glapi_check_multithread(void)
+u_current_init(void)
{
static unsigned long knownID;
static int firstCall = 1;
@@ -172,15 +172,15 @@ _glapi_check_multithread(void)
CHECK_MULTITHREAD_LOCK();
if (firstCall) {
- _glapi_init_multithread();
+ u_current_init_tsd();
knownID = u_thread_self();
firstCall = 0;
}
else if (knownID != u_thread_self()) {
ThreadSafe = 1;
- _glapi_set_dispatch(NULL);
- _glapi_set_context(NULL);
+ u_current_set_internal(NULL);
+ u_current_set_user_internal(NULL);
}
CHECK_MULTITHREAD_UNLOCK();
}
@@ -188,7 +188,7 @@ _glapi_check_multithread(void)
#else
void
-_glapi_check_multithread(void)
+u_current_init(void)
{
}
@@ -202,15 +202,17 @@ _glapi_check_multithread(void)
* void from the real context pointer type.
*/
void
-_glapi_set_context(void *context)
+u_current_set_user_internal(void *ptr)
{
+ u_current_init();
+
#if defined(GLX_USE_TLS)
- _glapi_tls_Context = context;
+ u_current_user_tls = ptr;
#elif defined(THREADS)
- u_tsd_set(&ContextTSD, context);
- _glapi_Context = (ThreadSafe) ? NULL : context;
+ u_tsd_set(&u_current_user_tsd, ptr);
+ u_current_user = (ThreadSafe) ? NULL : ptr;
#else
- _glapi_Context = context;
+ u_current_user = ptr;
#endif
}
@@ -220,16 +222,16 @@ _glapi_set_context(void *context)
* void to the real context pointer type.
*/
void *
-_glapi_get_context(void)
+u_current_get_user_internal(void)
{
#if defined(GLX_USE_TLS)
- return _glapi_tls_Context;
+ return u_current_user_tls;
#elif defined(THREADS)
return (ThreadSafe)
- ? u_tsd_get(&ContextTSD)
- : _glapi_Context;
+ ? u_tsd_get(&u_current_user_tsd)
+ : u_current_user;
#else
- return _glapi_Context;
+ return u_current_user;
#endif
}
@@ -239,36 +241,37 @@ _glapi_get_context(void)
* table (__glapi_noop_table).
*/
void
-_glapi_set_dispatch(struct _glapi_table *dispatch)
+u_current_set_internal(struct mapi_table *tbl)
{
+ u_current_init();
+
stub_init_once();
- if (!dispatch)
- dispatch = (struct _glapi_table *) table_noop_array;
+ if (!tbl)
+ tbl = (struct mapi_table *) table_noop_array;
#if defined(GLX_USE_TLS)
- _glapi_tls_Dispatch = dispatch;
+ u_current_table_tls = tbl;
#elif defined(THREADS)
- u_tsd_set(&_gl_DispatchTSD, (void *) dispatch);
- _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch;
+ u_tsd_set(&u_current_table_tsd, (void *) tbl);
+ u_current_table = (ThreadSafe) ? NULL : tbl;
#else
- _glapi_Dispatch = dispatch;
+ u_current_table = tbl;
#endif
}
/**
* Return pointer to current dispatch table for calling thread.
*/
-struct _glapi_table *
-_glapi_get_dispatch(void)
+struct mapi_table *
+u_current_get_internal(void)
{
#if defined(GLX_USE_TLS)
- return _glapi_tls_Dispatch;
+ return u_current_table_tls;
#elif defined(THREADS)
- return (ThreadSafe)
- ? (struct _glapi_table *) u_tsd_get(&_gl_DispatchTSD)
- : _glapi_Dispatch;
+ return (struct mapi_table *) ((ThreadSafe) ?
+ u_tsd_get(&u_current_table_tsd) : (void *) u_current_table);
#else
- return _glapi_Dispatch;
+ return u_current_table;
#endif
}
diff --git a/src/mapi/mapi/u_current.h b/src/mapi/mapi/u_current.h
index a6bd9f08385..62e54c6c93d 100644
--- a/src/mapi/mapi/u_current.h
+++ b/src/mapi/mapi/u_current.h
@@ -1,87 +1,99 @@
#ifndef _U_CURRENT_H_
#define _U_CURRENT_H_
-#include "u_compiler.h"
-
#ifdef MAPI_GLAPI_CURRENT
#include "glapi/glapi.h"
+/* ugly renames to match glapi.h */
+#define mapi_table _glapi_table
+
+#define u_current_table_tls _glapi_tls_Dispatch
+#define u_current_user_tls _glapi_tls_Context
+#define u_current_table _glapi_Dispatch
+#define u_current_user _glapi_Context
+
+#define u_current_destroy _glapi_destroy_multithread
+#define u_current_init _glapi_check_multithread
+#define u_current_set_internal _glapi_set_dispatch
+#define u_current_get_internal _glapi_get_dispatch
+#define u_current_set_user_internal _glapi_set_context
+#define u_current_get_user_internal _glapi_get_context
+
+#define u_current_table_tsd _gl_DispatchTSD
+
#else /* MAPI_GLAPI_CURRENT */
-struct _glapi_table;
+#include "u_compiler.h"
+
+struct mapi_table;
#ifdef GLX_USE_TLS
-extern __thread struct _glapi_table *_glapi_tls_Dispatch
+extern __thread struct mapi_table *u_current_table_tls
__attribute__((tls_model("initial-exec")));
-extern __thread void *_glapi_tls_Context
+extern __thread void *u_current_user_tls
__attribute__((tls_model("initial-exec")));
-extern const struct _glapi_table *_glapi_Dispatch;
-extern const void *_glapi_Context;
+extern const struct mapi_table *u_current_table;
+extern const void *u_current_user;
#else /* GLX_USE_TLS */
-extern struct _glapi_table *_glapi_Dispatch;
-extern void *_glapi_Context;
+extern struct mapi_table *u_current_table;
+extern void *u_current_user;
#endif /* GLX_USE_TLS */
void
-_glapi_check_multithread(void);
+u_current_init(void);
void
-_glapi_set_context(void *context);
-
-void *
-_glapi_get_context(void);
+u_current_destroy(void);
void
-_glapi_set_dispatch(struct _glapi_table *dispatch);
+u_current_set_internal(struct mapi_table *tbl);
-struct _glapi_table *
-_glapi_get_dispatch(void);
+struct mapi_table *
+u_current_get_internal(void);
void
-_glapi_destroy_multithread(void);
+u_current_set_user_internal(void *ptr);
-
-struct mapi_table;
+void *
+u_current_get_user_internal(void);
static INLINE void
u_current_set(const struct mapi_table *tbl)
{
- _glapi_check_multithread();
- _glapi_set_dispatch((struct _glapi_table *) tbl);
+ u_current_set_internal((struct mapi_table *) tbl);
}
static INLINE const struct mapi_table *
u_current_get(void)
{
#ifdef GLX_USE_TLS
- return (const struct mapi_table *) _glapi_tls_Dispatch;
+ return (const struct mapi_table *) u_current_table_tls;
#else
- return (const struct mapi_table *) (likely(_glapi_Dispatch) ?
- _glapi_Dispatch : _glapi_get_dispatch());
+ return (likely(u_current_table) ?
+ (const struct mapi_table *) u_current_table : u_current_get_internal());
#endif
}
static INLINE void
u_current_set_user(void *ptr)
{
- _glapi_check_multithread();
- _glapi_set_context(ptr);
+ u_current_set_internal(ptr);
}
static INLINE void *
u_current_get_user(void)
{
#ifdef GLX_USE_TLS
- return _glapi_tls_Context;
+ return u_current_user_tls;
#else
- return likely(_glapi_Context) ? _glapi_Context : _glapi_get_context();
+ return likely(u_current_user) ? u_current_user : u_current_get_user_internal();
#endif
}