mesa: Rename GLX_USE_TLS to USE_ELF_TLS.

These days it is not GLX only and it does not work with all TLS
implementations.

Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
This commit is contained in:
Bas Nieuwenhuizen 2019-08-03 18:44:44 +02:00
parent d7ca1efc6c
commit 9f37c9903b
18 changed files with 57 additions and 57 deletions

View File

@ -166,8 +166,8 @@ extern __thread struct _glapi_table *_glapi_tls_Dispatch
</blockquote>
<p>Use of this path is controlled by the preprocessor define
<code>GLX_USE_TLS</code>. Any platform capable of using TLS should use this as
the default dispatch method.</p>
<code>USE_ELF_TLS</code>. Any platform capable of using ELF TLS should use this
as the default dispatch method.</p>
<h3>3.3. Assembly Language Dispatch Stubs</h3>
@ -204,7 +204,7 @@ terribly relevant.</p>
few preprocessor defines.</p>
<ul>
<li>If <code>GLX_USE_TLS</code> is defined, method #3 is used.</li>
<li>If <code>USE_ELF_TLS</code> is defined, method #3 is used.</li>
<li>If <code>HAVE_PTHREAD</code> is defined, method #2 is used.</li>
<li>If none of the preceding are defined, method #1 is used.</li>
</ul>

View File

@ -375,9 +375,9 @@ if with_egl and not (with_platform_drm or with_platform_surfaceless or with_plat
endif
endif
# Android uses emutls for versions <= P/28. For GLX_USE_TLS we need ELF TLS.
# Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS.
if not with_platform_android or get_option('platform-sdk-version') >= 29
pre_args += '-DGLX_USE_TLS'
pre_args += '-DUSE_ELF_TLS'
endif
if with_glx != 'disabled'

View File

@ -44,7 +44,7 @@ static EGLBoolean _egl_TSDInitialized;
static tss_t _egl_TSD;
static void _eglDestroyThreadInfo(_EGLThreadInfo *t);
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
static __thread const _EGLThreadInfo *_egl_TLS
__attribute__ ((tls_model("initial-exec")));
#endif
@ -52,14 +52,14 @@ static __thread const _EGLThreadInfo *_egl_TLS
static inline void _eglSetTSD(const _EGLThreadInfo *t)
{
tss_set(_egl_TSD, (void *) t);
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
_egl_TLS = t;
#endif
}
static inline _EGLThreadInfo *_eglGetTSD(void)
{
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
return (_EGLThreadInfo *) _egl_TLS;
#else
return (_EGLThreadInfo *) tss_get(_egl_TSD);

View File

@ -660,7 +660,7 @@ extern int __glXDebug;
extern void __glXSetCurrentContext(struct glx_context * c);
# if defined( GLX_USE_TLS )
# if defined( USE_ELF_TLS )
extern __thread void *__glX_tls_Context
__attribute__ ((tls_model("initial-exec")));
@ -671,7 +671,7 @@ extern __thread void *__glX_tls_Context
extern struct glx_context *__glXGetCurrentContext(void);
# endif /* defined( GLX_USE_TLS ) */
# endif /* defined( USE_ELF_TLS ) */
extern void __glXSetCurrentContextNull(void);

View File

@ -67,7 +67,7 @@ struct glx_context dummyContext = {
_X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
# if defined( GLX_USE_TLS )
# if defined( USE_ELF_TLS )
/**
* Per-thread GLX context pointer.
@ -132,7 +132,7 @@ __glXGetCurrentContext(void)
return (v == NULL) ? &dummyContext : (struct glx_context *) v;
}
# endif /* defined( GLX_USE_TLS ) */
# endif /* defined( USE_ELF_TLS ) */
_X_HIDDEN void

View File

@ -102,7 +102,7 @@ struct glx_context dummyContext = {
};
__thread void *__glX_tls_Context = &dummyContext;
#if !defined(GLX_USE_TLS)
#if !defined(USE_ELF_TLS)
extern "C" struct glx_context *
__glXGetCurrentContext()
{

View File

@ -552,7 +552,7 @@ loader_open_driver(const char *driver_name,
next = end;
len = next - p;
#if GLX_USE_TLS
#if USE_ELF_TLS
snprintf(path, sizeof(path), "%.*s/tls/%s_dri.so", len, p, driver_name);
driver = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
#endif

View File

@ -46,15 +46,15 @@
#endif
#if defined(USE_X86_ASM) && defined(__GNUC__)
# ifdef GLX_USE_TLS
# ifdef USE_ELF_TLS
# include "entry_x86_tls.h"
# else
# include "entry_x86_tsd.h"
# endif
#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS)
#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(USE_ELF_TLS)
# include "entry_x86-64_tls.h"
#elif defined(USE_PPC64LE_ASM) && defined(__GNUC__) && defined(PIPE_ARCH_LITTLE_ENDIAN)
# ifdef GLX_USE_TLS
# ifdef USE_ELF_TLS
# include "entry_ppc64le_tls.h"
# else
# include "entry_ppc64le_tsd.h"

View File

@ -77,7 +77,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('\t add\t%o7, %g2, %g2')
print('\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc')
print('')
print('#ifdef GLX_USE_TLS')
print('#ifdef USE_ELF_TLS')
print('')
print('\tGLOBL_FN(__glapi_sparc_get_dispatch)')
print('\tHIDDEN(__glapi_sparc_get_dispatch)')

View File

@ -143,7 +143,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('')
print('\t.text')
print('')
print('#ifdef GLX_USE_TLS')
print('#ifdef USE_ELF_TLS')
print('')
print('_x86_64_get_dispatch:')
print('\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax')
@ -227,7 +227,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
if not f.is_static_entry_point(f.name):
print('\tHIDDEN(GL_PREFIX(%s))' % (name))
print('GL_PREFIX(%s):' % (name))
print('#if defined(GLX_USE_TLS)')
print('#if defined(USE_ELF_TLS)')
print('\tcall\t_x86_64_get_dispatch@PLT')
print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
print('\tjmp\t*%r11')
@ -258,7 +258,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
print('\tjmp\t*%r11')
print('#endif /* defined(GLX_USE_TLS) */')
print('#endif /* defined(USE_ELF_TLS) */')
print('\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name))
print('')

View File

@ -81,7 +81,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('#endif')
print('')
print('')
print('#ifdef GLX_USE_TLS')
print('#ifdef USE_ELF_TLS')
print('')
print('#ifdef GLX_X86_READONLY_TEXT')
print('# define CTX_INSNS MOV_L(GS:(EAX), EAX)')
@ -132,7 +132,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('')
print('SEG_TEXT')
print('')
print('#ifdef GLX_USE_TLS')
print('#ifdef USE_ELF_TLS')
print('')
print('\tGLOBL\tGLNAME(_x86_get_dispatch)')
print('\tHIDDEN(GLNAME(_x86_get_dispatch))')
@ -161,9 +161,9 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print('#endif')
print('')
print('#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )')
print('#if defined( USE_ELF_TLS ) && !defined( GLX_X86_READONLY_TEXT )')
print('\t\t.section\twtext, "awx", @progbits')
print('#endif /* defined( GLX_USE_TLS ) */')
print('#endif /* defined( USE_ELF_TLS ) */')
print('')
print('\t\tALIGNTEXT16')

View File

@ -33,11 +33,11 @@
* u_current.c.
*/
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
/* not used, but defined for compatibility */
const struct _glapi_table *_glapi_Dispatch;
const void *_glapi_Context;
#endif /* GLX_USE_TLS */
#endif /* USE_ELF_TLS */
void
_glapi_destroy_multithread(void)

View File

@ -86,7 +86,7 @@ typedef void (*_glapi_nop_handler_proc)(const char *name);
struct _glapi_table;
#if defined (GLX_USE_TLS)
#if defined (USE_ELF_TLS)
_GLAPI_EXPORT extern __thread struct _glapi_table * _glapi_tls_Dispatch
__attribute__((tls_model("initial-exec")));
@ -111,7 +111,7 @@ _GLAPI_EXPORT extern void *_glapi_Context;
#define GET_CURRENT_CONTEXT(C) struct gl_context *C = (struct gl_context *) \
(likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
#endif /* defined (GLX_USE_TLS) */
#endif /* defined (USE_ELF_TLS) */
void

View File

@ -38,7 +38,7 @@
#ifdef USE_X86_ASM
#if defined( GLX_USE_TLS )
#if defined( USE_ELF_TLS )
extern GLubyte gl_dispatch_functions_start[];
extern GLubyte gl_dispatch_functions_end[];
#else
@ -68,7 +68,7 @@ get_entrypoint_address(unsigned int functionOffset)
static void
init_glapi_relocs( void )
{
#if defined(GLX_USE_TLS) && !defined(GLX_X86_READONLY_TEXT)
#if defined(USE_ELF_TLS) && !defined(GLX_X86_READONLY_TEXT)
extern unsigned long _x86_get_dispatch(void);
char run_time_patch[] = {
0x65, 0xa1, 0, 0, 0, 0 /* movl %gs:0,%eax */
@ -121,7 +121,7 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, unsigned int offset)
{
GLubyte * const code = (GLubyte *) entrypoint;
#if defined(GLX_USE_TLS)
#if defined(USE_ELF_TLS)
*((unsigned int *)(code + 8)) = 4 * offset;
#else
*((unsigned int *)(code + 11)) = 4 * offset;
@ -137,9 +137,9 @@ extern void __glapi_sparc_icache_flush(unsigned int *);
static void
init_glapi_relocs( void )
{
#if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS)
#if defined(HAVE_PTHREAD) || defined(USE_ELF_TLS)
static const unsigned int template[] = {
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
0x05000000, /* sethi %hi(_glapi_tls_Dispatch), %g2 */
0x8730e00a, /* srl %g3, 10, %g3 */
0x8410a000, /* or %g2, %lo(_glapi_tls_Dispatch), %g2 */
@ -190,7 +190,7 @@ init_glapi_relocs( void )
0x81e80000, /* --> restore */
#endif
};
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
extern unsigned int __glapi_sparc_tls_stub;
extern unsigned long __glapi_sparc_get_dispatch(void);
unsigned int *code = &__glapi_sparc_tls_stub;
@ -203,7 +203,7 @@ init_glapi_relocs( void )
int idx;
#endif
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
code[0] = template[0] | (dispatch >> 10);
code[1] = template[1];
__glapi_sparc_icache_flush(&code[0]);
@ -267,14 +267,14 @@ init_glapi_relocs( void )
_glapi_proc
generate_entrypoint(GLuint functionOffset)
{
#if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS)
#if defined(HAVE_PTHREAD) || defined(USE_ELF_TLS)
static const unsigned int template[] = {
0x07000000, /* sethi %hi(0), %g3 */
0x8210000f, /* mov %o7, %g1 */
0x40000000, /* call */
0x9e100001, /* mov %g1, %o7 */
};
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
extern unsigned int __glapi_sparc_tls_stub;
unsigned long call_dest = (unsigned long ) &__glapi_sparc_tls_stub;
#else
@ -338,7 +338,7 @@ fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
void
init_glapi_relocs_once( void )
{
#if defined(HAVE_PTHREAD) || defined(GLX_USE_TLS)
#if defined(HAVE_PTHREAD) || defined(USE_ELF_TLS)
static once_flag flag = ONCE_FLAG_INIT;
call_once(&flag, init_glapi_relocs);
#endif

View File

@ -62,7 +62,7 @@ get_entrypoint_address(unsigned int functionOffset);
* Size (in bytes) of dispatch function (entrypoint).
*/
#if defined(USE_X86_ASM)
# if defined(GLX_USE_TLS)
# if defined(USE_ELF_TLS)
# define DISPATCH_FUNCTION_SIZE 16
# else
# define DISPATCH_FUNCTION_SIZE 32
@ -70,7 +70,7 @@ get_entrypoint_address(unsigned int functionOffset);
#endif
#if defined(USE_X64_64_ASM)
# if defined(GLX_USE_TLS)
# if defined(USE_ELF_TLS)
# define DISPATCH_FUNCTION_SIZE 16
# endif
#endif

View File

@ -38,11 +38,11 @@
* u_current.c.
*/
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
/* not used, but defined for compatibility */
const struct _glapi_table *_glapi_Dispatch;
const void *_glapi_Context;
#endif /* GLX_USE_TLS */
#endif /* USE_ELF_TLS */
void
_glapi_destroy_multithread(void)

View File

@ -97,7 +97,7 @@ extern void (*__glapi_noop_table[])(void);
* between TLS enabled loaders and non-TLS DRI drivers.
*/
/*@{*/
#if defined(GLX_USE_TLS)
#if defined(USE_ELF_TLS)
__thread struct _glapi_table *u_current_table
__attribute__((tls_model("initial-exec")))
@ -116,21 +116,21 @@ tss_t u_current_table_tsd;
static tss_t u_current_context_tsd;
static int ThreadSafe;
#endif /* defined(GLX_USE_TLS) */
#endif /* defined(USE_ELF_TLS) */
/*@}*/
void
u_current_destroy(void)
{
#if !defined(GLX_USE_TLS)
#if !defined(USE_ELF_TLS)
tss_delete(u_current_table_tsd);
tss_delete(u_current_context_tsd);
#endif
}
#if !defined(GLX_USE_TLS)
#if !defined(USE_ELF_TLS)
static void
u_current_init_tsd(void)
@ -230,7 +230,7 @@ u_current_set_context(const void *ptr)
{
u_current_init();
#if defined(GLX_USE_TLS)
#if defined(USE_ELF_TLS)
u_current_context = (void *) ptr;
#else
tss_set(u_current_context_tsd, (void *) ptr);
@ -246,7 +246,7 @@ u_current_set_context(const void *ptr)
void *
u_current_get_context_internal(void)
{
#if defined(GLX_USE_TLS)
#if defined(USE_ELF_TLS)
return u_current_context;
#else
return ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context;
@ -268,7 +268,7 @@ u_current_set_table(const struct _glapi_table *tbl)
if (!tbl)
tbl = (const struct _glapi_table *) table_noop_array;
#if defined(GLX_USE_TLS)
#if defined(USE_ELF_TLS)
u_current_table = (struct _glapi_table *) tbl;
#else
tss_set(u_current_table_tsd, (void *) tbl);
@ -282,7 +282,7 @@ u_current_set_table(const struct _glapi_table *tbl)
struct _glapi_table *
u_current_get_table_internal(void)
{
#if defined(GLX_USE_TLS)
#if defined(USE_ELF_TLS)
return u_current_table;
#else
if (ThreadSafe)

View File

@ -10,7 +10,7 @@
#include "glapi/glapi.h"
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
#define u_current_table _glapi_tls_Dispatch
#define u_current_context _glapi_tls_Context
#else
@ -27,7 +27,7 @@
struct _glapi_table;
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
extern __thread struct _glapi_table *u_current_table
__attribute__((tls_model("initial-exec")));
@ -35,12 +35,12 @@ extern __thread struct _glapi_table *u_current_table
extern __thread void *u_current_context
__attribute__((tls_model("initial-exec")));
#else /* GLX_USE_TLS */
#else /* USE_ELF_TLS */
extern struct _glapi_table *u_current_table;
extern void *u_current_context;
#endif /* GLX_USE_TLS */
#endif /* USE_ELF_TLS */
#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */
@ -65,7 +65,7 @@ u_current_get_context_internal(void);
static inline const struct _glapi_table *
u_current_get_table(void)
{
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
return u_current_table;
#else
return (likely(u_current_table) ?
@ -76,7 +76,7 @@ u_current_get_table(void)
static inline const void *
u_current_get_context(void)
{
#ifdef GLX_USE_TLS
#ifdef USE_ELF_TLS
return u_current_context;
#else
return likely(u_current_context) ? u_current_context : u_current_get_context_internal();