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..496582678625c849fb7d7a81ff758bd07414a40d 100644 |
--- a/src/nonsfi/irt/irt_interfaces.c |
+++ b/src/nonsfi/irt/irt_interfaces.c |
@@ -26,9 +26,9 @@ |
#include "native_client/src/include/elf32.h" |
#include "native_client/src/include/elf_auxv.h" |
#include "native_client/src/include/nacl/nacl_exception.h" |
+#include "native_client/src/include/nacl/nacl_signal.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" |
@@ -45,6 +45,7 @@ |
#if defined(__native_client__) |
# include "native_client/src/nonsfi/linux/linux_pthread_private.h" |
+# include "native_client/src/public/nonsfi/irt_signal_handling.h" |
#endif |
/* |
@@ -358,19 +359,6 @@ static void *start_thread(void *arg) { |
static int thread_create(void (*start_func)(void), void *stack, |
void *thread_ptr) { |
-#if defined(__native_client__) |
Mark Seaborn
2015/07/16 23:21:16
By removing this, you're changing NACL_IRT_THREAD_
Luis Héctor Chávez
2015/07/20 18:13:47
Done.
|
- struct thread_args *args = malloc(sizeof(struct thread_args)); |
- if (args == NULL) { |
- return ENOMEM; |
- } |
- 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); |
- if (error != 0) |
- free(args); |
- return error; |
-#else |
/* |
* For now, we ignore the stack that user code provides and just use |
* the stack that the host libpthread allocates. |
@@ -396,18 +384,34 @@ static int thread_create(void (*start_func)(void), void *stack, |
cleanup: |
pthread_attr_destroy(&attr); |
return error; |
-#endif |
} |
static void thread_exit(int32_t *stack_flag) { |
-#if defined(__native_client__) |
- nacl_user_thread_exit(stack_flag); |
-#else |
*stack_flag = 0; /* Indicate that the user code's stack can be freed. */ |
pthread_exit(NULL); |
-#endif |
} |
+#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; |
+ } |
+ 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, 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_nice(const int nice) { |
return 0; |
} |
@@ -612,6 +616,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 +684,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 +713,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 +729,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 }, |