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 /* | 7 /* |
8 * Native Client threads library | 8 * Native Client threads library |
9 */ | 9 */ |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... | |
29 #include "native_client/src/untrusted/valgrind/dynamic_annotations.h" | 29 #include "native_client/src/untrusted/valgrind/dynamic_annotations.h" |
30 | 30 |
31 #if defined(NACL_IN_IRT) | 31 #if defined(NACL_IN_IRT) |
32 # include "native_client/src/untrusted/irt/irt_private.h" | 32 # include "native_client/src/untrusted/irt/irt_private.h" |
33 #endif | 33 #endif |
34 | 34 |
35 /* | 35 /* |
36 * ABI tables for underyling NaCl thread interfaces. This is declared to be | 36 * ABI tables for underyling NaCl thread interfaces. This is declared to be |
37 * global so that a user will be able to override it using the irt_ext API. | 37 * global so that a user will be able to override it using the irt_ext API. |
38 */ | 38 */ |
39 struct nacl_irt_thread __libnacl_irt_thread; | 39 struct nacl_irt_thread_v0_2 __libnacl_irt_thread; |
40 | 40 |
41 /* | 41 /* |
42 * These days, the thread_create() syscall/IRT call will align the | 42 * These days, the thread_create() syscall/IRT call will align the |
43 * stack for us, but for compatibility with older, released x86 | 43 * stack for us, but for compatibility with older, released x86 |
44 * versions of NaCl where thread_create() does not align the stack, we | 44 * versions of NaCl where thread_create() does not align the stack, we |
45 * align the stack ourselves. | 45 * align the stack ourselves. |
46 */ | 46 */ |
47 #if defined(__i386__) | 47 #if defined(__i386__) |
48 static const uint32_t kStackAlignment = 32; | 48 static const uint32_t kStackAlignment = 32; |
49 static const uint32_t kStackPadBelowAlign = 4; /* Return address size */ | 49 static const uint32_t kStackPadBelowAlign = 4; /* Return address size */ |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 * zero address of architecture-dependent width, needed to satisfy the | 408 * zero address of architecture-dependent width, needed to satisfy the |
409 * normal ABI alignment requirements for the stack. (On some machines | 409 * normal ABI alignment requirements for the stack. (On some machines |
410 * this is the dummy return address of the thread-start function.) | 410 * this is the dummy return address of the thread-start function.) |
411 * | 411 * |
412 * Both thread_stack and stacksize are multiples of 16. | 412 * Both thread_stack and stacksize are multiples of 16. |
413 */ | 413 */ |
414 esp = (void *) (thread_stack + stacksize - kStackPadBelowAlign); | 414 esp = (void *) (thread_stack + stacksize - kStackPadBelowAlign); |
415 memset(esp, 0, kStackPadBelowAlign); | 415 memset(esp, 0, kStackPadBelowAlign); |
416 | 416 |
417 /* Start the thread. */ | 417 /* Start the thread. */ |
418 retval = __libnacl_irt_thread.thread_create(nc_thread_starter, esp, new_tp); | 418 nacl_irt_tid_t native_tid; |
419 retval = __libnacl_irt_thread.thread_create(nc_thread_starter, esp, new_tp, | |
Mark Seaborn
2015/06/26 18:32:00
This isn't going to work for SFI NaCl, because you
Luis Héctor Chávez
2015/07/06 23:45:00
Done.
| |
420 &native_tid); | |
421 (*thread_id)->native_tid = native_tid; | |
Mark Seaborn
2015/06/26 18:32:00
BTW, assigning to (*thread_id)->native_tid as a se
Luis Héctor Chávez
2015/07/06 23:45:00
Done.
| |
419 if (0 != retval) { | 422 if (0 != retval) { |
420 pthread_mutex_lock(&__nc_thread_management_lock); | 423 pthread_mutex_lock(&__nc_thread_management_lock); |
421 /* TODO(gregoryd) : replace with atomic decrement? */ | 424 /* TODO(gregoryd) : replace with atomic decrement? */ |
422 --__nc_running_threads_counter; | 425 --__nc_running_threads_counter; |
423 pthread_mutex_unlock(&__nc_thread_management_lock); | 426 pthread_mutex_unlock(&__nc_thread_management_lock); |
424 goto ret; | 427 goto ret; |
425 } | 428 } |
426 | 429 |
427 assert(0 == retval); | 430 assert(0 == retval); |
428 | 431 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 | 813 |
811 /* | 814 /* |
812 * We include this directly in this file rather than compiling it | 815 * We include this directly in this file rather than compiling it |
813 * separately because there is some code (e.g. libstdc++) that uses weak | 816 * separately because there is some code (e.g. libstdc++) that uses weak |
814 * references to all pthread functions, but conditionalizes its calls only | 817 * references to all pthread functions, but conditionalizes its calls only |
815 * on one symbol. So if these functions are in another file in a library | 818 * on one symbol. So if these functions are in another file in a library |
816 * archive, they might not be linked in by static linking. | 819 * archive, they might not be linked in by static linking. |
817 */ | 820 */ |
818 /* @IGNORE_LINES_FOR_CODE_HYGIENE[1] */ | 821 /* @IGNORE_LINES_FOR_CODE_HYGIENE[1] */ |
819 #include "native_client/src/untrusted/pthread/nc_tsd.c" | 822 #include "native_client/src/untrusted/pthread/nc_tsd.c" |
OLD | NEW |