OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #ifndef NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_ |
| 8 #define NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_ 1 |
| 9 |
| 10 #if NACL_OSX |
| 11 |
| 12 #include <mach/mach.h> |
| 13 #include <stdint.h> |
| 14 |
| 15 #include "native_client/src/include/nacl_base.h" |
| 16 #include "native_client/src/include/nacl_compiler_annotations.h" |
| 17 #include "native_client/src/trusted/service_runtime/nacl_tls.h" |
| 18 |
| 19 EXTERN_C_BEGIN |
| 20 |
| 21 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 64 |
| 22 |
| 23 /* |
| 24 * Retrieves the Native Client thread index for a given Mach thread, or |
| 25 * NACL_TLS_INDEX_INVALID if the Mach thread is unknown to Native Client. |
| 26 */ |
| 27 uint32_t NaClGetThreadIndexForMachThread(mach_port_t mach_thread); |
| 28 |
| 29 /* |
| 30 * Establishes a mapping from the currently executing Mach thread to the |
| 31 * given Native Client thread index. |
| 32 */ |
| 33 void NaClSetCurrentMachThreadForThreadIndex(uint32_t nacl_thread_index); |
| 34 |
| 35 /* |
| 36 * Clears any existing mapping to any Mach thread for the given Native Client |
| 37 * thread index. A thread's mapping must be cleared by itself, not by another |
| 38 * thread. |
| 39 */ |
| 40 void NaClClearMachThreadForThreadIndex(uint32_t nacl_thread_index); |
| 41 |
| 42 #else |
| 43 |
| 44 /* |
| 45 * NaClGetThreadIndexForMachThread is not implemented for x86-32, although it |
| 46 * it could be implemented by using thread_get_state to obtain the thread's |
| 47 * state and returning %gs >> 3. It's left unimplemented because the only |
| 48 * prospective call sites already have access to the thread state and thus %gs |
| 49 * themselves, and directing them through this function would add system call |
| 50 * overhead for a redundant thread_get_state. |
| 51 */ |
| 52 |
| 53 static INLINE void NaClSetCurrentMachThreadForThreadIndex( |
| 54 uint32_t nacl_thread_index) { |
| 55 /* No-op for x86-32. */ |
| 56 UNREFERENCED_PARAMETER(nacl_thread_index); |
| 57 } |
| 58 |
| 59 static INLINE void NaClClearMachThreadForThreadIndex( |
| 60 uint32_t nacl_thread_index) { |
| 61 /* No-op for x86-32. */ |
| 62 UNREFERENCED_PARAMETER(nacl_thread_index); |
| 63 } |
| 64 |
| 65 #endif |
| 66 |
| 67 EXTERN_C_END |
| 68 |
| 69 #endif /* NACL_OSX */ |
| 70 |
| 71 #endif /* NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_ */ |
OLD | NEW |