| 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 #ifndef SERVICE_RUNTIME_NACL_THREAD_H__ | 7 #ifndef SERVICE_RUNTIME_NACL_THREAD_H__ |
| 8 #define SERVICE_RUNTIME_NACL_THREAD_H__ 1 | 8 #define SERVICE_RUNTIME_NACL_THREAD_H__ 1 |
| 9 | 9 |
| 10 /* | 10 /* |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 * Free a tls descriptor. | 45 * Free a tls descriptor. |
| 46 * This is called from NaClAppThreadDelete() which in turn is called | 46 * This is called from NaClAppThreadDelete() which in turn is called |
| 47 * after a thread terminates. | 47 * after a thread terminates. |
| 48 */ | 48 */ |
| 49 void NaClTlsFree(struct NaClAppThread *natp); | 49 void NaClTlsFree(struct NaClAppThread *natp); |
| 50 | 50 |
| 51 | 51 |
| 52 /* | 52 /* |
| 53 * Called in thread bootup code, to set TLS/TSD when the thread ID is not | 53 * Called in thread bootup code, to set TLS/TSD when the thread ID is not |
| 54 * saved in a reserved register (e.g., %gs in NaCl x86-32). | 54 * saved in a reserved register (e.g., %gs in NaCl x86-32). |
| 55 * | |
| 56 * No-op for x86-32 NaCl classic. | |
| 57 */ | 55 */ |
| 58 void NaClTlsSetIdx(uint32_t tls_idx); | 56 void NaClTlsSetCurrentThread(struct NaClAppThread *natp); |
| 59 | 57 |
| 60 /* | 58 /* |
| 61 * Gets the current thread's index value as set by NaClTlsSetIdx(). | 59 * Get the current thread as set by NaClTlsSetCurrentThread(). |
| 62 * Only implemented for x86-64 and ARM, since these are the only sandboxes | |
| 63 * where we use the host OS's TLS facility. | |
| 64 * Returns NACL_TLS_INDEX_INVALID if NaClTlsSetIdx() has not been | |
| 65 * called on this thread. | |
| 66 */ | 60 */ |
| 67 uint32_t NaClTlsGetIdx(void); | 61 struct NaClAppThread *NaClTlsGetCurrentThread(void); |
| 68 | 62 |
| 69 void NaClTlsSetTlsValue1(struct NaClAppThread *natp, uint32_t value); | 63 void NaClTlsSetTlsValue1(struct NaClAppThread *natp, uint32_t value); |
| 70 void NaClTlsSetTlsValue2(struct NaClAppThread *natp, uint32_t value); | 64 void NaClTlsSetTlsValue2(struct NaClAppThread *natp, uint32_t value); |
| 71 | 65 |
| 72 uint32_t NaClTlsGetTlsValue1(struct NaClAppThread *natp); | 66 uint32_t NaClTlsGetTlsValue1(struct NaClAppThread *natp); |
| 73 uint32_t NaClTlsGetTlsValue2(struct NaClAppThread *natp); | 67 uint32_t NaClTlsGetTlsValue2(struct NaClAppThread *natp); |
| 74 | 68 |
| 75 /* | 69 /* |
| 76 * Get the current thread index which is used to look up information in a | 70 * Get the current thread index which is used to look up information in a |
| 77 * number of internal structures, e.g. nacl_user[], nacl_thread_ids[] | 71 * number of internal structures, e.g. nacl_user[], nacl_thread_ids[] |
| 78 */ | 72 */ |
| 79 uint32_t NaClGetThreadIdx(struct NaClAppThread *natp); | 73 uint32_t NaClGetThreadIdx(struct NaClAppThread *natp); |
| 80 | 74 |
| 81 | 75 |
| 82 #if NACL_OSX | |
| 83 /* | |
| 84 * OSX does not have TLS and we emulate it on the trusted side using TSD. | |
| 85 */ | |
| 86 extern pthread_key_t nacl_thread_info_key; | |
| 87 extern uint32_t nacl_thread_index_tls_offset; | |
| 88 | |
| 89 #endif | |
| 90 | |
| 91 | |
| 92 #endif /* SERVICE_RUNTIME_NACL_THREAD_H__ */ | 76 #endif /* SERVICE_RUNTIME_NACL_THREAD_H__ */ |
| OLD | NEW |