| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/untrusted/irt/irt_interfaces.h" | 7 #include "native_client/src/untrusted/irt/irt_interfaces.h" |
| 8 #include "native_client/src/untrusted/nacl/nacl_irt.h" | 8 #include "native_client/src/untrusted/nacl/nacl_irt.h" |
| 9 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h" | 9 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h" |
| 10 #include "native_client/src/untrusted/pthread/pthread_internal.h" | 10 #include "native_client/src/untrusted/pthread/pthread_internal.h" |
| 11 | 11 |
| 12 static int nacl_irt_thread_create(void (*start_func)(void), void *stack, | 12 static int nacl_irt_thread_create(void (*start_func)(void), void *stack, |
| 13 void *thread_ptr) { | 13 void *thread_ptr, nacl_irt_tid_t *tid) { |
| 14 #if defined(NACL_IN_IRT) | 14 #if defined(NACL_IN_IRT) |
| 15 /* | 15 /* |
| 16 * We want the first TLS to point to an unmapped location. The | 16 * We want the first TLS to point to an unmapped location. The |
| 17 * thread_create() syscall rejects a zero argument for the first | 17 * thread_create() syscall rejects a zero argument for the first |
| 18 * TLS, so use a non-zero value in the unmapped first 64k page. | 18 * TLS, so use a non-zero value in the unmapped first 64k page. |
| 19 */ | 19 */ |
| 20 void *user_tls = (void *) 0x1000; | 20 void *user_tls = (void *) 0x1000; |
| 21 return -NACL_SYSCALL(thread_create)((void *) start_func, stack, | 21 return -NACL_SYSCALL(thread_create)((void *) start_func, stack, |
| 22 user_tls, thread_ptr); | 22 user_tls, thread_ptr); |
| 23 #else | 23 #else |
| 24 return -NACL_SYSCALL(thread_create)((void *) start_func, stack, | 24 return -NACL_SYSCALL(thread_create)((void *) start_func, stack, |
| 25 thread_ptr, 0); | 25 thread_ptr, 0); |
| 26 #endif | 26 #endif |
| 27 } | 27 } |
| 28 | 28 |
| 29 static void nacl_irt_thread_exit(int32_t *stack_flag) { | 29 static void nacl_irt_thread_exit(int32_t *stack_flag) { |
| 30 NACL_SYSCALL(thread_exit)(stack_flag); | 30 NACL_SYSCALL(thread_exit)(stack_flag); |
| 31 __builtin_trap(); | 31 __builtin_trap(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 static int nacl_irt_thread_nice(const int nice) { | 34 static int nacl_irt_thread_nice(const int nice) { |
| 35 return -NACL_SYSCALL(thread_nice)(nice); | 35 return -NACL_SYSCALL(thread_nice)(nice); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void __nc_initialize_interfaces(void) { | 38 void __nc_initialize_interfaces(void) { |
| 39 const struct nacl_irt_thread init = { | 39 const struct nacl_irt_thread_v0_2 init = { |
| 40 nacl_irt_thread_create, | 40 nacl_irt_thread_create, |
| 41 nacl_irt_thread_exit, | 41 nacl_irt_thread_exit, |
| 42 nacl_irt_thread_nice, | 42 nacl_irt_thread_nice, |
| 43 }; | 43 }; |
| 44 __libnacl_irt_thread = init; | 44 __libnacl_irt_thread = init; |
| 45 } | 45 } |
| OLD | NEW |