summaryrefslogtreecommitdiff
path: root/src/mesa/glapi
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-06-21 14:14:24 -0700
committerEric Anholt <eric@anholt.net>2007-06-21 14:14:24 -0700
commit4fe48b4e8568896cdbc822323aeec0a41c72ff2a (patch)
treea32edaa514931bad2364b3877302eeaa3847131e /src/mesa/glapi
parent5d9dc02cbecd94f822f853fd01878784596f4eba (diff)
parented5ed6fe2f64f45eb3a43f9c57037d9e9b7fa5ea (diff)
Merge branch 'origin' into i915-unification
Diffstat (limited to 'src/mesa/glapi')
-rw-r--r--src/mesa/glapi/gl_x86_asm.py15
-rw-r--r--src/mesa/glapi/glapi.c20
2 files changed, 23 insertions, 12 deletions
diff --git a/src/mesa/glapi/gl_x86_asm.py b/src/mesa/glapi/gl_x86_asm.py
index 650331a0c5..403e87261b 100644
--- a/src/mesa/glapi/gl_x86_asm.py
+++ b/src/mesa/glapi/gl_x86_asm.py
@@ -82,12 +82,18 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print ''
print '#ifdef GLX_USE_TLS'
print ''
+ print '#ifdef GLX_X86_READONLY_TEXT'
+ print '# define CTX_INSNS MOV_L(GS:(EAX), EAX)'
+ print '#else'
+ print '# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */'
+ print '#endif'
+ print ''
print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
print '\tCALL(_x86_get_dispatch) ;\t\t\t\\'
- print '\tNOP ;\t\t\t\t\t\t\\'
+ print '\tCTX_INSNS ; \\'
print '\tJMP(GL_OFFSET(off))'
print ''
print '#elif defined(PTHREADS)'
@@ -138,7 +144,10 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '\tHIDDEN(GLNAME(_x86_get_dispatch))'
print 'ALIGNTEXT16'
print 'GLNAME(_x86_get_dispatch):'
- print '\tmovl\t%gs:_glapi_tls_Dispatch@NTPOFF, %eax'
+ print '\tcall 1f'
+ print '1:\tpopl %eax'
+ print '\taddl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax'
+ print '\tmovl _glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax'
print '\tret'
print ''
print '#elif defined(PTHREADS)'
@@ -158,7 +167,7 @@ class PrintGenericStubs(gl_XML.gl_print_base):
print '#endif'
print ''
- print '#if defined( GLX_USE_TLS )'
+ print '#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )'
print '\t\t.section\twtext, "awx", @progbits'
print '#endif /* defined( GLX_USE_TLS ) */'
diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
index 5815dbff84..47c5782273 100644
--- a/src/mesa/glapi/glapi.c
+++ b/src/mesa/glapi/glapi.c
@@ -1028,22 +1028,24 @@ _glapi_check_table(const struct _glapi_table *table)
#if defined(PTHREADS) || defined(GLX_USE_TLS)
/**
* Perform platform-specific GL API entry-point fixups.
- *
- *
*/
static void
init_glapi_relocs( void )
{
-#if defined( USE_X86_ASM ) && defined( GLX_USE_TLS )
- extern void * _x86_get_dispatch(void);
- const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch;
+#if defined(USE_X86_ASM) && defined(GLX_USE_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 */
+ };
+ GLuint *offset = (GLuint *) &run_time_patch[2]; /* 32-bits for x86/32 */
+ const GLubyte * const get_disp = (const GLubyte *) run_time_patch;
GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start;
-
+ *offset = _x86_get_dispatch();
while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) {
- (void) memcpy( curr_func, get_disp, 6 );
+ (void) memcpy( curr_func, get_disp, sizeof(run_time_patch));
curr_func += DISPATCH_FUNCTION_SIZE;
}
-#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */
-}
#endif
+}
+#endif /* defined(PTHREADS) || defined(GLX_USE_TLS) */