Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: src/trusted/service_runtime/osx/mach_thread_map.c

Issue 12207165: Mac x86_64: Mach exception support (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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 #include "native_client/src/trusted/service_runtime/osx/mach_thread_map.h"
8
9 #include <pthread.h>
10
11 #include "native_client/src/shared/platform/nacl_check.h"
12 #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h"
13 #include "native_client/src/trusted/service_runtime/nacl_globals.h"
14
15 #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 64
16
17 static mach_port_t mach_threads[NACL_THREAD_MAX];
18
19 uint32_t NaClGetThreadIndexForMachThread(mach_port_t mach_thread) {
20 uint32_t nacl_thread_index;
21
22 DCHECK(mach_thread != MACH_PORT_NULL);
23
24 CHECK(NACL_TLS_INDEX_INVALID < NACL_THREAD_MAX); /* Skip the invalid slot. */
25 for (nacl_thread_index = NACL_TLS_INDEX_INVALID + 1;
26 nacl_thread_index < NACL_THREAD_MAX;
27 ++nacl_thread_index) {
28 if (mach_threads[nacl_thread_index] == mach_thread) {
29 break;
30 }
31 }
32
33 return nacl_thread_index == NACL_THREAD_MAX ? NACL_TLS_INDEX_INVALID :
34 nacl_thread_index;
35 }
36
37 void NaClSetCurrentMachThreadForThreadIndex(uint32_t nacl_thread_index) {
38 mach_port_t mach_thread = pthread_mach_thread_np(pthread_self());
39 CHECK(mach_thread != MACH_PORT_NULL);
40
41 DCHECK(nacl_thread_index > NACL_TLS_INDEX_INVALID &&
42 nacl_thread_index < NACL_THREAD_MAX);
43 DCHECK(mach_threads[nacl_thread_index] == MACH_PORT_NULL);
44 DCHECK(NaClGetThreadIndexForMachThread(mach_thread) ==
45 NACL_TLS_INDEX_INVALID);
46
47 mach_threads[nacl_thread_index] = mach_thread;
48 }
49
50 void NaClClearMachThreadForThreadIndex(uint32_t nacl_thread_index) {
51 DCHECK(nacl_thread_index > NACL_TLS_INDEX_INVALID &&
52 nacl_thread_index < NACL_THREAD_MAX);
53 DCHECK(mach_threads[nacl_thread_index] ==
54 pthread_mach_thread_np(pthread_self()));
55
56 mach_threads[nacl_thread_index] = MACH_PORT_NULL;
57 }
58
59 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698