|
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 | |
14 #include "native_client/src/include/nacl_base.h" | |
15 #include "native_client/src/include/nacl_compiler_annotations.h" | |
16 #include "native_client/src/shared/platform/nacl_check.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 != 32 | |
Mark Seaborn
2013/02/14 23:55:02
Probably better to say:
#if NACL_ARCH(NACL_BUILD_A
| |
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 size_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(size_t nacl_thread_index); | |
Mark Seaborn
2013/02/14 23:55:02
Elsewhere, thread indexes are all uint32_t
| |
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(size_t nacl_thread_index); | |
41 | |
42 #else | |
43 | |
44 static INLINE size_t NaClGetThreadIndexForMachThread(mach_port_t mach_thread) { | |
45 /* | |
46 * This could be implemented for 32-bit x86 by using thread_get_state to | |
47 * obtain the thread's state and returning %gs >> 3. It's left unimplemented | |
48 * because the only prospective call sites already have access to the thread | |
49 * state and thus %gs themselves, and directing them through this function | |
50 * would add system call overhead for a redundant thread_get_state. | |
51 */ | |
52 UNREFERENCED_PARAMETER(mach_thread); | |
53 CHECK(0); | |
Mark Seaborn
2013/02/14 23:55:02
I'd suggest omitting this function definition sinc
| |
54 /* NOTREACHED */ | |
55 return NACL_TLS_INDEX_INVALID; | |
56 } | |
57 | |
58 static INLINE void NaClSetCurrentMachThreadForThreadIndex( | |
59 size_t nacl_thread_index) { | |
60 /* No-op for 32-bit x86. */ | |
Mark Seaborn
2013/02/14 23:55:02
Nit: '32-bit x86' -> 'x86-32' (since that's the us
| |
61 UNREFERENCED_PARAMETER(nacl_thread_index); | |
62 } | |
63 | |
64 static INLINE void NaClClearMachThreadForThreadIndex(size_t nacl_thread_index) { | |
65 /* No-op for 32-bit x86. */ | |
66 UNREFERENCED_PARAMETER(nacl_thread_index); | |
67 } | |
68 | |
69 #endif | |
70 | |
71 EXTERN_C_END | |
72 | |
73 #endif /* NACL_OSX */ | |
74 | |
75 #endif /* NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_ */ | |
OLD | NEW |