OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 return -NACL_SYSCALL(second_tls_set)(thread_ptr); | 30 return -NACL_SYSCALL(second_tls_set)(thread_ptr); |
31 } | 31 } |
32 | 32 |
33 void *nacl_tls_get(void) { | 33 void *nacl_tls_get(void) { |
34 #if defined(__i386__) | 34 #if defined(__i386__) |
35 /* | 35 /* |
36 * Calling second_tls_get() works on x86-32, but reading %gs:4 is a | 36 * Calling second_tls_get() works on x86-32, but reading %gs:4 is a |
37 * lot faster. | 37 * lot faster. |
38 */ | 38 */ |
39 void *result; | 39 void *result; |
40 __asm__("mov %%gs:4, %0" : "=r"(result)); | 40 __asm__("mov %%gs:0, %0" : "=r"(result)); |
41 return result; | 41 return result; |
42 #else | 42 #else |
43 return NACL_SYSCALL(second_tls_get)(); | 43 return NACL_SYSCALL(second_tls_get)(); |
44 #endif | 44 #endif |
45 } | 45 } |
46 | 46 |
47 void *__nacl_read_tp(void) { | 47 void *__nacl_read_tp(void) { |
48 return nacl_tls_get(); | 48 return nacl_tls_get(); |
49 } | 49 } |
OLD | NEW |