diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:03:48 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:03:48 -0800 |
commit | 4e468ed2eb86a2406e14f1eca82072ee501d05fd (patch) | |
tree | 4e05b3c66eef86531e464521a3bf96a1864d4bf5 /libc/arch-x86/bionic/__set_tls.c | |
parent | a27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (diff) | |
download | bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.zip bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.gz bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'libc/arch-x86/bionic/__set_tls.c')
-rwxr-xr-x | libc/arch-x86/bionic/__set_tls.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libc/arch-x86/bionic/__set_tls.c b/libc/arch-x86/bionic/__set_tls.c index 8dff8d7..48b55f0 100755 --- a/libc/arch-x86/bionic/__set_tls.c +++ b/libc/arch-x86/bionic/__set_tls.c @@ -27,6 +27,7 @@ */ #include <pthread.h> + struct user_desc { unsigned int entry_number; unsigned long base_addr; @@ -40,6 +41,8 @@ struct user_desc { unsigned int empty:25; }; +extern int __set_thread_area(struct user_desc *u_info); + /* the following can't be const, since the first call will * update the 'entry_number' field */ @@ -57,7 +60,11 @@ static struct user_desc _tls_desc = 0 }; -/* we implement thread local storage through the fs: segment descriptor +struct _thread_area_head { + void *self; +}; + +/* we implement thread local storage through the gs: segment descriptor * we create a segment descriptor for the tls */ int __set_tls(void *ptr) @@ -66,6 +73,9 @@ int __set_tls(void *ptr) _tls_desc.base_addr = (unsigned long)ptr; + /* We also need to write the location of the tls to ptr[0] */ + ((struct _thread_area_head *)ptr)->self = ptr; + rc = __set_thread_area( &_tls_desc ); if (rc != 0) { @@ -76,7 +86,7 @@ int __set_tls(void *ptr) /* this weird computation comes from GLibc */ segment = _tls_desc.entry_number*8 + 3; asm __volatile__ ( - " movw %w0, %%fs" :: "r"(segment) + " movw %w0, %%gs" :: "q"(segment) ); return 0; } |