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
4 * found in the LICENSE file.
7 #include "native_client/src/untrusted/irt/irt_interfaces.h"
8 #include "native_client/src/untrusted/nacl/nacl_irt.h"
9 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
10 #include "native_client/src/untrusted/pthread/pthread_internal.h"
12 static int nacl_irt_thread_create(void (*start_func)(void), void *stack,
14 #if defined(NACL_IN_IRT)
16 * We want the first TLS to point to an unmapped location. The
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.
20 void *user_tls = (void *) 0x1000;
21 return -NACL_SYSCALL(thread_create)((void *) start_func, stack,
22 user_tls, thread_ptr);
24 return -NACL_SYSCALL(thread_create)((void *) start_func, stack,
29 static void nacl_irt_thread_exit(int32_t *stack_flag) {
30 NACL_SYSCALL(thread_exit)(stack_flag);
34 static int nacl_irt_thread_nice(const int nice) {
35 return -NACL_SYSCALL(thread_nice)(nice);
38 void __nc_initialize_interfaces(void) {
39 const struct nacl_irt_thread init = {
40 nacl_irt_thread_create,
44 __libnacl_irt_thread = init;