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

Unified Diff: src/nonsfi/irt/irt_interfaces.c

Issue 1212613002: Non-SFI mode: Add Linux asynchronous signal support (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Added a TODO to remove code after roll Created 5 years, 4 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/nonsfi/irt/irt.gyp ('k') | src/nonsfi/linux/irt_exception_handling.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/nonsfi/irt/irt_interfaces.c
diff --git a/src/nonsfi/irt/irt_interfaces.c b/src/nonsfi/irt/irt_interfaces.c
index f0e0c01c0a312330a4b37aa46c18401b97af339f..6294cda080fff86dac79d2ac58f7378f3a91540a 100644
--- a/src/nonsfi/irt/irt_interfaces.c
+++ b/src/nonsfi/irt/irt_interfaces.c
@@ -28,7 +28,6 @@
#include "native_client/src/include/nacl/nacl_exception.h"
#include "native_client/src/include/nacl_macros.h"
#include "native_client/src/public/irt_core.h"
-#include "native_client/src/public/nonsfi/irt_exception_handling.h"
#include "native_client/src/trusted/service_runtime/include/machine/_types.h"
#include "native_client/src/trusted/service_runtime/include/sys/mman.h"
#include "native_client/src/trusted/service_runtime/include/sys/stat.h"
@@ -44,6 +43,7 @@
#endif
#if defined(__native_client__)
+# include "native_client/src/nonsfi/linux/irt_signal_handling.h"
# include "native_client/src/nonsfi/linux/linux_pthread_private.h"
#endif
@@ -366,9 +366,9 @@ static void *start_thread(void *arg) {
abort();
}
-static int thread_create(void (*start_func)(void), void *stack,
- void *thread_ptr) {
#if defined(__native_client__)
+static int thread_create_nonsfi(void (*start_func)(void), void *stack,
+ void *thread_ptr, nacl_irt_tid_t *child_tid) {
struct thread_args *args = malloc(sizeof(struct thread_args));
if (args == NULL) {
return ENOMEM;
@@ -376,10 +376,25 @@ static int thread_create(void (*start_func)(void), void *stack,
args->start_func = start_func;
args->thread_ptr = thread_ptr;
/* In Linux, it is possible to use the provided stack directly. */
- int error = nacl_user_thread_create(start_thread, stack, args);
+ int error = nacl_user_thread_create(start_thread, stack, args, child_tid);
if (error != 0)
free(args);
return error;
+}
+
+static void thread_exit_nonsfi(int32_t *stack_flag) {
+ nacl_user_thread_exit(stack_flag);
+}
+#endif
+
+static int thread_create(void (*start_func)(void), void *stack,
+ void *thread_ptr) {
+#if defined(__native_client__)
+ /*
+ * When available, use the nonsfi version that does allow the |stack| to be
+ * set in the new thread.
+ */
+ return thread_create_nonsfi(start_func, stack, thread_ptr, NULL);
#else
/*
* For now, we ignore the stack that user code provides and just use
@@ -411,7 +426,11 @@ static int thread_create(void (*start_func)(void), void *stack,
static void thread_exit(int32_t *stack_flag) {
#if defined(__native_client__)
- nacl_user_thread_exit(stack_flag);
+ /*
+ * Since we used the nonsfi version of thread_create, we must also call the
+ * nonsfi version of thread_exit to correctly clean it up.
+ */
+ thread_exit_nonsfi(stack_flag);
#else
*stack_flag = 0; /* Indicate that the user code's stack can be freed. */
pthread_exit(NULL);
@@ -662,6 +681,14 @@ const struct nacl_irt_thread nacl_irt_thread = {
thread_nice,
};
+#if defined(__native_client__)
+const struct nacl_irt_thread_v0_2 nacl_irt_thread_v0_2 = {
+ thread_create_nonsfi,
+ thread_exit_nonsfi,
+ thread_nice,
+};
+#endif
+
#if defined(__linux__)
const struct nacl_irt_futex nacl_irt_futex = {
futex_wait_abs,
@@ -721,6 +748,11 @@ const struct nacl_irt_exception_handling nacl_irt_exception_handling = {
nacl_exception_set_stack,
nacl_exception_clear_flag,
};
+
+const struct nacl_irt_async_signal_handling nacl_irt_async_signal_handling = {
+ nacl_async_signal_set_handler,
+ nacl_async_signal_send_async_signal,
+};
#endif
#if defined(__native_client__) && defined(__arm__)
@@ -747,6 +779,10 @@ static const struct nacl_irt_interface irt_interfaces[] = {
{ NACL_IRT_MEMORY_v0_3, &nacl_irt_memory, sizeof(nacl_irt_memory), NULL },
{ NACL_IRT_TLS_v0_1, &nacl_irt_tls, sizeof(nacl_irt_tls), NULL },
{ NACL_IRT_THREAD_v0_1, &nacl_irt_thread, sizeof(nacl_irt_thread), NULL },
+#if defined(__native_client__)
+ { NACL_IRT_THREAD_v0_2, &nacl_irt_thread_v0_2,
+ sizeof(nacl_irt_thread_v0_2), NULL },
+#endif
{ NACL_IRT_FUTEX_v0_1, &nacl_irt_futex, sizeof(nacl_irt_futex), NULL },
{ NACL_IRT_RANDOM_v0_1, &nacl_irt_random, sizeof(nacl_irt_random), NULL },
#if defined(__linux__) || defined(__native_client__)
@@ -759,6 +795,8 @@ static const struct nacl_irt_interface irt_interfaces[] = {
#if defined(__native_client__)
{ NACL_IRT_EXCEPTION_HANDLING_v0_1, &nacl_irt_exception_handling,
sizeof(nacl_irt_exception_handling), NULL },
+ { NACL_IRT_ASYNC_SIGNAL_HANDLING_v0_1, &nacl_irt_async_signal_handling,
+ sizeof(nacl_irt_async_signal_handling), NULL },
#endif
#if defined(__native_client__) && defined(__arm__)
{ NACL_IRT_ICACHE_v0_1, &nacl_irt_icache, sizeof(nacl_irt_icache), NULL },
« no previous file with comments | « src/nonsfi/irt/irt.gyp ('k') | src/nonsfi/linux/irt_exception_handling.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698