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.
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
__asm__(".text");
|
__asm__(".text");
|
||||||
|
|
||||||
__asm__("x86_64_current_tls:\n\t"
|
__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");
|
"ret");
|
||||||
|
|
||||||
#define STUB_ASM_ENTRY(func) \
|
#define STUB_ASM_ENTRY(func) \
|
||||||
@@ -43,7 +43,7 @@ __asm__("x86_64_current_tls:\n\t"
|
|||||||
func ":"
|
func ":"
|
||||||
|
|
||||||
#define STUB_ASM_CODE(slot) \
|
#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" \
|
"movq %fs:(%rax), %r11\n\t" \
|
||||||
"jmp *(8 * " slot ")(%r11)"
|
"jmp *(8 * " slot ")(%r11)"
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ __asm__("x86_current_tls:\n\t"
|
|||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"popl %eax\n\t"
|
"popl %eax\n\t"
|
||||||
"addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %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");
|
"ret");
|
||||||
|
|
||||||
#ifndef GLX_X86_READONLY_TEXT
|
#ifndef GLX_X86_READONLY_TEXT
|
||||||
|
@@ -41,12 +41,12 @@ __asm__(".text");
|
|||||||
func ":"
|
func ":"
|
||||||
|
|
||||||
#define STUB_ASM_CODE(slot) \
|
#define STUB_ASM_CODE(slot) \
|
||||||
"movl _glapi_Dispatch, %eax\n\t" \
|
"movl u_current_table, %eax\n\t" \
|
||||||
"testl %eax, %eax\n\t" \
|
"testl %eax, %eax\n\t" \
|
||||||
"je 1f\n\t" \
|
"je 1f\n\t" \
|
||||||
"jmp *(4 * " slot ")(%eax)\n" \
|
"jmp *(4 * " slot ")(%eax)\n" \
|
||||||
"1:\n\t" \
|
"1:\n\t" \
|
||||||
"call _glapi_get_dispatch\n\t" \
|
"call u_current_get_internal\n\t"\
|
||||||
"jmp *(4 * " slot ")(%eax)"
|
"jmp *(4 * " slot ")(%eax)"
|
||||||
|
|
||||||
#define MAPI_TMP_STUB_ASM_GCC
|
#define MAPI_TMP_STUB_ASM_GCC
|
||||||
|
@@ -99,25 +99,25 @@ extern void (*__glapi_noop_table[])(void);
|
|||||||
/*@{*/
|
/*@{*/
|
||||||
#if defined(GLX_USE_TLS)
|
#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")))
|
__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")));
|
__attribute__((tls_model("initial-exec")));
|
||||||
|
|
||||||
const struct _glapi_table *_glapi_Dispatch;
|
const struct mapi_table *u_current_table;
|
||||||
const void *_glapi_Context;
|
const void *u_current_user;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
struct _glapi_table *_glapi_Dispatch =
|
struct mapi_table *u_current_table =
|
||||||
(struct _glapi_table *) table_noop_array;
|
(struct mapi_table *) table_noop_array;
|
||||||
void *_glapi_Context;
|
void *u_current_user;
|
||||||
|
|
||||||
#ifdef THREADS
|
#ifdef THREADS
|
||||||
struct u_tsd _gl_DispatchTSD;
|
struct u_tsd u_current_table_tsd;
|
||||||
static struct u_tsd ContextTSD;
|
static struct u_tsd u_current_user_tsd;
|
||||||
static int ThreadSafe;
|
static int ThreadSafe;
|
||||||
#endif /* THREADS */
|
#endif /* THREADS */
|
||||||
|
|
||||||
@@ -126,11 +126,11 @@ static int ThreadSafe;
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_glapi_destroy_multithread(void)
|
u_current_destroy(void)
|
||||||
{
|
{
|
||||||
#if defined(THREADS) && defined(WIN32_THREADS)
|
#if defined(THREADS) && defined(WIN32_THREADS)
|
||||||
u_tsd_destroy(&_gl_DispatchTSD);
|
u_tsd_destroy(&u_current_table_tsd);
|
||||||
u_tsd_destroy(&ContextTSD);
|
u_tsd_destroy(&u_current_user_tsd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,10 +138,10 @@ _glapi_destroy_multithread(void)
|
|||||||
#if defined(THREADS) && !defined(GLX_USE_TLS)
|
#if defined(THREADS) && !defined(GLX_USE_TLS)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_glapi_init_multithread(void)
|
u_current_init_tsd(void)
|
||||||
{
|
{
|
||||||
u_tsd_init(&_gl_DispatchTSD);
|
u_tsd_init(&u_current_table_tsd);
|
||||||
u_tsd_init(&ContextTSD);
|
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.
|
* in order to test if multiple threads are being used.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_glapi_check_multithread(void)
|
u_current_init(void)
|
||||||
{
|
{
|
||||||
static unsigned long knownID;
|
static unsigned long knownID;
|
||||||
static int firstCall = 1;
|
static int firstCall = 1;
|
||||||
@@ -172,15 +172,15 @@ _glapi_check_multithread(void)
|
|||||||
|
|
||||||
CHECK_MULTITHREAD_LOCK();
|
CHECK_MULTITHREAD_LOCK();
|
||||||
if (firstCall) {
|
if (firstCall) {
|
||||||
_glapi_init_multithread();
|
u_current_init_tsd();
|
||||||
|
|
||||||
knownID = u_thread_self();
|
knownID = u_thread_self();
|
||||||
firstCall = 0;
|
firstCall = 0;
|
||||||
}
|
}
|
||||||
else if (knownID != u_thread_self()) {
|
else if (knownID != u_thread_self()) {
|
||||||
ThreadSafe = 1;
|
ThreadSafe = 1;
|
||||||
_glapi_set_dispatch(NULL);
|
u_current_set_internal(NULL);
|
||||||
_glapi_set_context(NULL);
|
u_current_set_user_internal(NULL);
|
||||||
}
|
}
|
||||||
CHECK_MULTITHREAD_UNLOCK();
|
CHECK_MULTITHREAD_UNLOCK();
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@ _glapi_check_multithread(void)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
void
|
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 from the real context pointer type.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_glapi_set_context(void *context)
|
u_current_set_user_internal(void *ptr)
|
||||||
{
|
{
|
||||||
|
u_current_init();
|
||||||
|
|
||||||
#if defined(GLX_USE_TLS)
|
#if defined(GLX_USE_TLS)
|
||||||
_glapi_tls_Context = context;
|
u_current_user_tls = ptr;
|
||||||
#elif defined(THREADS)
|
#elif defined(THREADS)
|
||||||
u_tsd_set(&ContextTSD, context);
|
u_tsd_set(&u_current_user_tsd, ptr);
|
||||||
_glapi_Context = (ThreadSafe) ? NULL : context;
|
u_current_user = (ThreadSafe) ? NULL : ptr;
|
||||||
#else
|
#else
|
||||||
_glapi_Context = context;
|
u_current_user = ptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,16 +222,16 @@ _glapi_set_context(void *context)
|
|||||||
* void to the real context pointer type.
|
* void to the real context pointer type.
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
_glapi_get_context(void)
|
u_current_get_user_internal(void)
|
||||||
{
|
{
|
||||||
#if defined(GLX_USE_TLS)
|
#if defined(GLX_USE_TLS)
|
||||||
return _glapi_tls_Context;
|
return u_current_user_tls;
|
||||||
#elif defined(THREADS)
|
#elif defined(THREADS)
|
||||||
return (ThreadSafe)
|
return (ThreadSafe)
|
||||||
? u_tsd_get(&ContextTSD)
|
? u_tsd_get(&u_current_user_tsd)
|
||||||
: _glapi_Context;
|
: u_current_user;
|
||||||
#else
|
#else
|
||||||
return _glapi_Context;
|
return u_current_user;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,36 +241,37 @@ _glapi_get_context(void)
|
|||||||
* table (__glapi_noop_table).
|
* table (__glapi_noop_table).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
_glapi_set_dispatch(struct _glapi_table *dispatch)
|
u_current_set_internal(struct mapi_table *tbl)
|
||||||
{
|
{
|
||||||
|
u_current_init();
|
||||||
|
|
||||||
stub_init_once();
|
stub_init_once();
|
||||||
|
|
||||||
if (!dispatch)
|
if (!tbl)
|
||||||
dispatch = (struct _glapi_table *) table_noop_array;
|
tbl = (struct mapi_table *) table_noop_array;
|
||||||
|
|
||||||
#if defined(GLX_USE_TLS)
|
#if defined(GLX_USE_TLS)
|
||||||
_glapi_tls_Dispatch = dispatch;
|
u_current_table_tls = tbl;
|
||||||
#elif defined(THREADS)
|
#elif defined(THREADS)
|
||||||
u_tsd_set(&_gl_DispatchTSD, (void *) dispatch);
|
u_tsd_set(&u_current_table_tsd, (void *) tbl);
|
||||||
_glapi_Dispatch = (ThreadSafe) ? NULL : dispatch;
|
u_current_table = (ThreadSafe) ? NULL : tbl;
|
||||||
#else
|
#else
|
||||||
_glapi_Dispatch = dispatch;
|
u_current_table = tbl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return pointer to current dispatch table for calling thread.
|
* Return pointer to current dispatch table for calling thread.
|
||||||
*/
|
*/
|
||||||
struct _glapi_table *
|
struct mapi_table *
|
||||||
_glapi_get_dispatch(void)
|
u_current_get_internal(void)
|
||||||
{
|
{
|
||||||
#if defined(GLX_USE_TLS)
|
#if defined(GLX_USE_TLS)
|
||||||
return _glapi_tls_Dispatch;
|
return u_current_table_tls;
|
||||||
#elif defined(THREADS)
|
#elif defined(THREADS)
|
||||||
return (ThreadSafe)
|
return (struct mapi_table *) ((ThreadSafe) ?
|
||||||
? (struct _glapi_table *) u_tsd_get(&_gl_DispatchTSD)
|
u_tsd_get(&u_current_table_tsd) : (void *) u_current_table);
|
||||||
: _glapi_Dispatch;
|
|
||||||
#else
|
#else
|
||||||
return _glapi_Dispatch;
|
return u_current_table;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -1,87 +1,99 @@
|
|||||||
#ifndef _U_CURRENT_H_
|
#ifndef _U_CURRENT_H_
|
||||||
#define _U_CURRENT_H_
|
#define _U_CURRENT_H_
|
||||||
|
|
||||||
#include "u_compiler.h"
|
|
||||||
|
|
||||||
#ifdef MAPI_GLAPI_CURRENT
|
#ifdef MAPI_GLAPI_CURRENT
|
||||||
|
|
||||||
#include "glapi/glapi.h"
|
#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 */
|
#else /* MAPI_GLAPI_CURRENT */
|
||||||
|
|
||||||
struct _glapi_table;
|
#include "u_compiler.h"
|
||||||
|
|
||||||
|
struct mapi_table;
|
||||||
|
|
||||||
#ifdef GLX_USE_TLS
|
#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")));
|
__attribute__((tls_model("initial-exec")));
|
||||||
|
|
||||||
extern __thread void *_glapi_tls_Context
|
extern __thread void *u_current_user_tls
|
||||||
__attribute__((tls_model("initial-exec")));
|
__attribute__((tls_model("initial-exec")));
|
||||||
|
|
||||||
extern const struct _glapi_table *_glapi_Dispatch;
|
extern const struct mapi_table *u_current_table;
|
||||||
extern const void *_glapi_Context;
|
extern const void *u_current_user;
|
||||||
|
|
||||||
#else /* GLX_USE_TLS */
|
#else /* GLX_USE_TLS */
|
||||||
|
|
||||||
extern struct _glapi_table *_glapi_Dispatch;
|
extern struct mapi_table *u_current_table;
|
||||||
extern void *_glapi_Context;
|
extern void *u_current_user;
|
||||||
|
|
||||||
#endif /* GLX_USE_TLS */
|
#endif /* GLX_USE_TLS */
|
||||||
|
|
||||||
void
|
void
|
||||||
_glapi_check_multithread(void);
|
u_current_init(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
_glapi_set_context(void *context);
|
u_current_destroy(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
u_current_set_internal(struct mapi_table *tbl);
|
||||||
|
|
||||||
|
struct mapi_table *
|
||||||
|
u_current_get_internal(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
u_current_set_user_internal(void *ptr);
|
||||||
|
|
||||||
void *
|
void *
|
||||||
_glapi_get_context(void);
|
u_current_get_user_internal(void);
|
||||||
|
|
||||||
void
|
|
||||||
_glapi_set_dispatch(struct _glapi_table *dispatch);
|
|
||||||
|
|
||||||
struct _glapi_table *
|
|
||||||
_glapi_get_dispatch(void);
|
|
||||||
|
|
||||||
void
|
|
||||||
_glapi_destroy_multithread(void);
|
|
||||||
|
|
||||||
|
|
||||||
struct mapi_table;
|
|
||||||
|
|
||||||
static INLINE void
|
static INLINE void
|
||||||
u_current_set(const struct mapi_table *tbl)
|
u_current_set(const struct mapi_table *tbl)
|
||||||
{
|
{
|
||||||
_glapi_check_multithread();
|
u_current_set_internal((struct mapi_table *) tbl);
|
||||||
_glapi_set_dispatch((struct _glapi_table *) tbl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE const struct mapi_table *
|
static INLINE const struct mapi_table *
|
||||||
u_current_get(void)
|
u_current_get(void)
|
||||||
{
|
{
|
||||||
#ifdef GLX_USE_TLS
|
#ifdef GLX_USE_TLS
|
||||||
return (const struct mapi_table *) _glapi_tls_Dispatch;
|
return (const struct mapi_table *) u_current_table_tls;
|
||||||
#else
|
#else
|
||||||
return (const struct mapi_table *) (likely(_glapi_Dispatch) ?
|
return (likely(u_current_table) ?
|
||||||
_glapi_Dispatch : _glapi_get_dispatch());
|
(const struct mapi_table *) u_current_table : u_current_get_internal());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void
|
static INLINE void
|
||||||
u_current_set_user(void *ptr)
|
u_current_set_user(void *ptr)
|
||||||
{
|
{
|
||||||
_glapi_check_multithread();
|
u_current_set_internal(ptr);
|
||||||
_glapi_set_context(ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void *
|
static INLINE void *
|
||||||
u_current_get_user(void)
|
u_current_get_user(void)
|
||||||
{
|
{
|
||||||
#ifdef GLX_USE_TLS
|
#ifdef GLX_USE_TLS
|
||||||
return _glapi_tls_Context;
|
return u_current_user_tls;
|
||||||
#else
|
#else
|
||||||
return likely(_glapi_Context) ? _glapi_Context : _glapi_get_context();
|
return likely(u_current_user) ? u_current_user : u_current_get_user_internal();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user