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

Unified Diff: src/trusted/service_runtime/osx/mach_thread_map.h

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 side-by-side diff with in-line comments
Download patch
Index: src/trusted/service_runtime/osx/mach_thread_map.h
===================================================================
--- src/trusted/service_runtime/osx/mach_thread_map.h (revision 0)
+++ src/trusted/service_runtime/osx/mach_thread_map.h (revision 0)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2013 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_
+#define NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_ 1
+
+#if NACL_OSX
+
+#include <mach/mach.h>
+
+#include "native_client/src/include/nacl_base.h"
+#include "native_client/src/include/nacl_compiler_annotations.h"
+#include "native_client/src/shared/platform/nacl_check.h"
+#include "native_client/src/trusted/service_runtime/nacl_tls.h"
+
+EXTERN_C_BEGIN
+
+#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
+
+/*
+ * Retrieves the Native Client thread index for a given Mach thread, or
+ * NACL_TLS_INDEX_INVALID if the Mach thread is unknown to Native Client.
+ */
+size_t NaClGetThreadIndexForMachThread(mach_port_t mach_thread);
+
+/*
+ * Establishes a mapping from the currently executing Mach thread to the
+ * given Native Client thread index.
+ */
+void NaClSetCurrentMachThreadForThreadIndex(size_t nacl_thread_index);
Mark Seaborn 2013/02/14 23:55:02 Elsewhere, thread indexes are all uint32_t
+
+/*
+ * Clears any existing mapping to any Mach thread for the given Native Client
+ * thread index. A thread's mapping must be cleared by itself, not by another
+ * thread.
+ */
+void NaClClearMachThreadForThreadIndex(size_t nacl_thread_index);
+
+#else
+
+static INLINE size_t NaClGetThreadIndexForMachThread(mach_port_t mach_thread) {
+ /*
+ * This could be implemented for 32-bit x86 by using thread_get_state to
+ * obtain the thread's state and returning %gs >> 3. It's left unimplemented
+ * because the only prospective call sites already have access to the thread
+ * state and thus %gs themselves, and directing them through this function
+ * would add system call overhead for a redundant thread_get_state.
+ */
+ UNREFERENCED_PARAMETER(mach_thread);
+ CHECK(0);
Mark Seaborn 2013/02/14 23:55:02 I'd suggest omitting this function definition sinc
+ /* NOTREACHED */
+ return NACL_TLS_INDEX_INVALID;
+}
+
+static INLINE void NaClSetCurrentMachThreadForThreadIndex(
+ size_t nacl_thread_index) {
+ /* 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
+ UNREFERENCED_PARAMETER(nacl_thread_index);
+}
+
+static INLINE void NaClClearMachThreadForThreadIndex(size_t nacl_thread_index) {
+ /* No-op for 32-bit x86. */
+ UNREFERENCED_PARAMETER(nacl_thread_index);
+}
+
+#endif
+
+EXTERN_C_END
+
+#endif /* NACL_OSX */
+
+#endif /* NATIVE_CLIENT_SERVICE_RUNTIME_OSX_MACH_THREAD_MAP_H_ */
Property changes on: src/trusted/service_runtime/osx/mach_thread_map.h
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698