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 "native_client/src/include/portability.h" | 7 #include "native_client/src/include/portability.h" |
8 | 8 |
9 #include "native_client/src/shared/platform/nacl_check.h" | 9 #include "native_client/src/shared/platform/nacl_check.h" |
10 #include "native_client/src/trusted/service_runtime/arch/x86/nacl_ldt_x86.h" | 10 #include "native_client/src/trusted/service_runtime/arch/x86/nacl_ldt_x86.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 | 65 |
66 uint32_t NaClGetThreadIdx(struct NaClAppThread *natp) { | 66 uint32_t NaClGetThreadIdx(struct NaClAppThread *natp) { |
67 return natp->user.gs >> 3; | 67 return natp->user.gs >> 3; |
68 } | 68 } |
69 | 69 |
70 #if NACL_LINUX | 70 #if NACL_LINUX |
71 | 71 |
72 /* | 72 /* |
73 * This TLS variable mirrors nacl_thread_index in the x86-64 sandbox, | 73 * This TLS variable mirrors nacl_current_thread in the x86-64 sandbox, |
74 * except that, on x86-32, we only use it for getting the identity of | 74 * except that, on x86-32, we only use it for getting the identity of |
75 * the interrupted thread in a signal handler in the Linux | 75 * the interrupted thread in a signal handler in the Linux |
76 * implementation of thread suspension. | 76 * implementation of thread suspension. |
77 * | 77 * |
78 * We should not enable this code on Windows because TLS variables do | 78 * We should not enable this code on Windows because TLS variables do |
79 * not work inside dynamically-loaded DLLs -- such as chrome.dll -- on | 79 * not work inside dynamically-loaded DLLs -- such as chrome.dll -- on |
80 * Windows XP. | 80 * Windows XP. |
81 */ | 81 */ |
82 THREAD uint32_t nacl_thread_index; | 82 static THREAD struct NaClThreadContext *nacl_current_thread; |
83 | 83 |
84 void NaClTlsSetIdx(uint32_t tls_idx) { | 84 void NaClTlsSetCurrentThread(struct NaClAppThread *natp) { |
85 nacl_thread_index = tls_idx; | 85 nacl_current_thread = &natp->user; |
86 } | 86 } |
87 | 87 |
88 uint32_t NaClTlsGetIdx(void) { | 88 struct NaClAppThread *NaClTlsGetCurrentThread(void) { |
89 return nacl_thread_index; | 89 return NaClAppThreadFromThreadContext(nacl_current_thread); |
90 } | 90 } |
91 | 91 |
92 #else | 92 #else |
93 | 93 |
94 /* | 94 /* |
95 * This is a NOOP, since TLS (or TSD) is not used to keep the thread | 95 * This is a NOOP, since TLS (or TSD) is not used to keep the thread |
96 * index on the x86-32. We use segmentation (%gs) to provide access | 96 * index on the x86-32. We use segmentation (%gs) to provide access |
97 * to the per-thread data, and the segment selector itself tells us | 97 * to the per-thread data, and the segment selector itself tells us |
98 * the thread's identity. | 98 * the thread's identity. |
99 */ | 99 */ |
100 void NaClTlsSetIdx(uint32_t tls_idx) { | 100 void NaClTlsSetCurrentThread(struct NaClAppThread *natp) { |
101 UNREFERENCED_PARAMETER(tls_idx); | 101 UNREFERENCED_PARAMETER(natp); |
102 } | 102 } |
103 | 103 |
104 #endif | 104 #endif |
OLD | NEW |