Chromium Code Reviews| Index: src/nonsfi/irt/irt_interfaces.c |
| diff --git a/src/nonsfi/irt/irt_interfaces.c b/src/nonsfi/irt/irt_interfaces.c |
| index 220d5b8747abe5ac3fc4a66f97ff479e7b0eb3f6..7788cd3fe58e1cf9cb2f7f63275e1fb6c3450558 100644 |
| --- a/src/nonsfi/irt/irt_interfaces.c |
| +++ b/src/nonsfi/irt/irt_interfaces.c |
| @@ -26,9 +26,10 @@ |
| #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/public/nonsfi/irt_signal_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" |
| @@ -38,6 +39,7 @@ |
| #include "native_client/src/untrusted/irt/irt_dev.h" |
| #include "native_client/src/untrusted/irt/irt_interfaces.h" |
| #include "native_client/src/untrusted/nacl/nacl_random.h" |
| +#include "native_client/src/untrusted/pthread/pthread_types.h" |
|
Mark Seaborn
2015/06/26 18:31:59
Not used? irt_interfaces.c shouldn't depend on sr
Luis Héctor Chávez
2015/07/06 23:44:59
Removed.
|
| #if defined(__native_client__) && defined(__arm__) |
| #include "native_client/src/nonsfi/irt/irt_icache.h" |
| @@ -353,7 +355,7 @@ static void *start_thread(void *arg) { |
| } |
| static int thread_create(void (*start_func)(void), void *stack, |
| - void *thread_ptr) { |
| + void *thread_ptr, nacl_irt_tid_t *child_tid) { |
| /* |
| * For now, we ignore the stack that user code provides and just use |
| * the stack that the host libpthread allocates. |
| @@ -374,13 +376,21 @@ static int thread_create(void (*start_func)(void), void *stack, |
| args->thread_ptr = thread_ptr; |
| pthread_t tid; |
| error = pthread_create(&tid, &attr, start_thread, args); |
| - if (error != 0) |
| + if (error != 0) { |
| free(args); |
| + } else if (child_tid != NULL) { |
| + *child_tid = tid->native_tid; |
|
Mark Seaborn
2015/06/26 18:31:59
This creates an unfortunate dependency on libpthre
Luis Héctor Chávez
2015/07/06 23:44:59
Split that off into https://codereview.chromium.or
|
| + } |
| cleanup: |
| pthread_attr_destroy(&attr); |
| return error; |
| } |
| +static int thread_create_v0_1(void (*start_func)(void), void *stack, |
| + void *thread_ptr) { |
| + return thread_create(start_func, stack, thread_ptr, NULL); |
| +} |
| + |
| static void thread_exit(int32_t *stack_flag) { |
| *stack_flag = 0; /* Indicate that the user code's stack can be freed. */ |
| pthread_exit(NULL); |
| @@ -585,6 +595,12 @@ const struct nacl_irt_tls nacl_irt_tls = { |
| }; |
| const struct nacl_irt_thread nacl_irt_thread = { |
| + thread_create_v0_1, |
| + thread_exit, |
| + thread_nice, |
| +}; |
| + |
| +const struct nacl_irt_thread_v0_2 nacl_irt_thread_v0_2 = { |
| thread_create, |
| thread_exit, |
| thread_nice, |
| @@ -650,6 +666,11 @@ const struct nacl_irt_exception_handling nacl_irt_exception_handling = { |
| nacl_exception_set_stack, |
| nacl_exception_clear_flag, |
| }; |
| + |
| +const struct nacl_irt_signal_handling nacl_irt_signal_handling = { |
| + nacl_signal_set_handler, |
| + nacl_signal_send_async_signal, |
| +}; |
| #endif |
| #if defined(__native_client__) && defined(__arm__) |
| @@ -674,6 +695,8 @@ 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 }, |
| + { NACL_IRT_THREAD_v0_2, &nacl_irt_thread_v0_2, |
| + sizeof(nacl_irt_thread_v0_2), NULL }, |
| { 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__) |
| @@ -686,6 +709,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_SIGNAL_HANDLING_v0_1, &nacl_irt_signal_handling, |
| + sizeof(nacl_irt_signal_handling), NULL }, |
| #endif |
| #if defined(__native_client__) && defined(__arm__) |
| { NACL_IRT_ICACHE_v0_1, &nacl_irt_icache, sizeof(nacl_irt_icache), NULL }, |