Maarten Lankhorst : loader: Implement setting %gs for amd64.
Alexandre Julliard
julliard at winehq.org
Mon Dec 1 07:34:21 CST 2008
Module: wine
Branch: master
Commit: 0a393d7eb412cf840d225537cb75ba7fe6ea99ba
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0a393d7eb412cf840d225537cb75ba7fe6ea99ba
Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date: Tue Nov 25 08:50:37 2008 +0100
loader: Implement setting %gs for amd64.
---
loader/pthread.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/loader/pthread.c b/loader/pthread.c
index 4951d97..4c0c892 100644
--- a/loader/pthread.c
+++ b/loader/pthread.c
@@ -48,10 +48,15 @@
static int init_done;
static int nb_threads = 1;
-#ifndef __i386__
+#if !defined(__i386__) && !defined(__x86_64__)
static pthread_key_t teb_key;
#endif
+#if defined(__x86_64__) && defined(__linux__)
+#include <asm/prctl.h>
+extern int arch_prctl(int func, void *ptr);
+#endif
+
/***********************************************************************
* init_process
*
@@ -141,6 +146,13 @@ static void init_current_teb( struct wine_pthread_thread_info *info )
wine_ldt_set_limit( &fs_entry, info->teb_size - 1 );
wine_ldt_set_flags( &fs_entry, WINE_LDT_FLAGS_DATA|WINE_LDT_FLAGS_32BIT );
wine_ldt_init_fs( info->teb_sel, &fs_entry );
+#elif defined(__x86_64__)
+ /* On x86_64, it's in %gs */
+# ifdef __linux__
+ arch_prctl(ARCH_SET_GS, info->teb_base);
+# else
+# error Please define setting %gs for your architecture
+# endif
#else
if (!init_done) /* first thread */
pthread_key_create( &teb_key, NULL );
@@ -174,6 +186,10 @@ static void *get_current_teb(void)
void *ret;
__asm__( ".byte 0x64\n\tmovl 0x18,%0" : "=r" (ret) );
return ret;
+#elif defined(__x86_64__)
+ void *ret;
+ __asm__( ".byte 0x65\n\tmovq 0x30,%0" : "=r" (ret) );
+ return ret;
#else
return pthread_getspecific( teb_key );
#endif
More information about the wine-cvs
mailing list