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

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/trusted/service_runtime/arch/sel_ldr_arch.h"
12 #include "native_client/src/trusted/service_runtime/nacl_globals.h"
13
14 #if NACL_ARCH(NACL_BUILD_ARCH) != NACL_x86 || NACL_BUILD_SUBARCH != 32
Mark Seaborn 2013/02/14 23:55:02 Again, probably better to say: #if NACL_ARCH(NACL_
15
16 static mach_port_t mach_threads[NACL_THREAD_MAX];
17
18 size_t NaClGetThreadIndexForMachThread(mach_port_t mach_thread) {
19 size_t nacl_thread_index;
20
21 DCHECK(mach_thread != MACH_PORT_NULL);
22
23 CHECK(NACL_TLS_INDEX_INVALID < NACL_THREAD_MAX); /* Skip the invalid slot. */
24 for (nacl_thread_index = NACL_TLS_INDEX_INVALID + 1;
25 nacl_thread_index < NACL_THREAD_MAX;
26 ++nacl_thread_index) {
27 if (mach_threads[nacl_thread_index] == mach_thread) {
28 break;
29 }
30 }
31
32 return nacl_thread_index == NACL_THREAD_MAX ? NACL_TLS_INDEX_INVALID :
33 nacl_thread_index;
34 }
35
36 void NaClSetCurrentMachThreadForThreadIndex(size_t nacl_thread_index) {
37 mach_port_t mach_thread = pthread_mach_thread_np(pthread_self());
Mark Seaborn 2013/02/14 23:55:02 It might be worth commenting that: We assume that
Mark Mentovai 2013/02/15 17:36:42 Mark Seaborn wrote:
Mark Seaborn 2013/02/15 22:48:08 What's this interface called? Whether it's worth
38 CHECK(mach_thread != MACH_PORT_NULL);
39
40 DCHECK(nacl_thread_index > NACL_TLS_INDEX_INVALID &&
41 nacl_thread_index < NACL_THREAD_MAX);
42 DCHECK(mach_threads[nacl_thread_index] == MACH_PORT_NULL);
43 DCHECK(NaClGetThreadIndexForMachThread(mach_thread) ==
44 NACL_TLS_INDEX_INVALID);
45
46 mach_threads[nacl_thread_index] = mach_thread;
47 }
48
49 void NaClClearMachThreadForThreadIndex(size_t nacl_thread_index) {
50 DCHECK(nacl_thread_index > NACL_TLS_INDEX_INVALID &&
51 nacl_thread_index < NACL_THREAD_MAX);
52 DCHECK(mach_threads[nacl_thread_index] ==
53 pthread_mach_thread_np(pthread_self()));
54
55 mach_threads[nacl_thread_index] = MACH_PORT_NULL;
56 }
57
58 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698