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

Unified Diff: src/untrusted/nacl/nacl_exception.c

Issue 14876015: Add wrapper library for the nacl_irt_exception_handling IRT interface (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Cleanup + remove minidump_generator.gyp for now because of pthread.h problem in Gyp build Created 7 years, 7 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
« no previous file with comments | « src/untrusted/nacl/nacl.scons ('k') | tests/exception_test/exception_crash_test.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/untrusted/nacl/nacl_exception.c
diff --git a/src/untrusted/nacl/nacl_exception.c b/src/untrusted/nacl/nacl_exception.c
new file mode 100644
index 0000000000000000000000000000000000000000..2d80bd875eb9e114745090a282d9c74fa22be803
--- /dev/null
+++ b/src/untrusted/nacl/nacl_exception.c
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#include "native_client/src/include/nacl/nacl_exception.h"
+
+#include <errno.h>
+#include <stdlib.h>
+
+#include "native_client/src/untrusted/irt/irt.h"
+
+
+static struct nacl_irt_exception_handling irt_exception_handling;
+
+/*
+ * We don't do any locking here, but simultaneous calls are harmless enough.
+ * They'll all be writing the same values to the same words.
+ */
+static int set_up_irt_exception_handling(void) {
+ return nacl_interface_query(NACL_IRT_EXCEPTION_HANDLING_v0_1,
+ &irt_exception_handling,
+ sizeof(irt_exception_handling))
+ == sizeof(irt_exception_handling);
+}
+
+int nacl_exception_set_handler(nacl_exception_handler_t handler) {
+ if (irt_exception_handling.exception_handler == NULL) {
+ if (!set_up_irt_exception_handling())
+ return ENOSYS;
+ }
+ return irt_exception_handling.exception_handler(handler, NULL);
+}
+
+int nacl_exception_set_stack(void *stack, size_t size) {
+ if (irt_exception_handling.exception_stack == NULL) {
+ if (!set_up_irt_exception_handling())
+ return ENOSYS;
+ }
+ return irt_exception_handling.exception_stack(stack, size);
+}
+
+int nacl_exception_clear_flag() {
+ if (irt_exception_handling.exception_clear_flag == NULL) {
+ if (!set_up_irt_exception_handling())
+ return ENOSYS;
+ }
+ return irt_exception_handling.exception_clear_flag();
+}
« no previous file with comments | « src/untrusted/nacl/nacl.scons ('k') | tests/exception_test/exception_crash_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698