Index: src/nonsfi/irt/irt_interfaces.c |
diff --git a/src/nonsfi/irt/irt_interfaces.c b/src/nonsfi/irt/irt_interfaces.c |
index 9852311f9b8989853bbea82e5df8cbc783457475..82b28c805ef74a043f73777a1596a687082cc44c 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,7 +43,9 @@ |
#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" |
+# include "native_client/src/public/nonsfi/irt_signal_handling.h" |
Mark Seaborn
2015/08/12 01:43:06
This one is not needed, I think?
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
|
#endif |
/* |
@@ -356,9 +357,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) { |
Mark Seaborn
2015/08/12 01:43:07
Nit: align indentation
Luis Héctor Chávez
2015/08/12 22:14:26
Done.
|
struct thread_args *args = malloc(sizeof(struct thread_args)); |
if (args == NULL) { |
return ENOMEM; |
@@ -366,10 +367,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 |
@@ -401,7 +417,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); |
@@ -612,6 +632,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, |
@@ -672,6 +700,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_signal_set_handler, |
+ nacl_signal_send_async_signal, |
+}; |
#endif |
#if defined(__native_client__) && defined(__arm__) |
@@ -696,6 +729,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__) |
@@ -708,6 +745,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 }, |