| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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. | |
| 5 */ | |
| 6 | |
| 7 #include <unistd.h> | |
| 8 | |
| 9 #include "native_client/src/untrusted/nacl/nacl_irt.h" | |
| 10 #include "native_client/src/untrusted/nacl/nacl_thread.h" | |
| 11 #include "native_client/src/untrusted/nacl/tls.h" | |
| 12 #include "native_client/src/untrusted/nacl/tls_params.h" | |
| 13 | |
| 14 /* | |
| 15 * This initialization happens early in startup with or without libpthread. | |
| 16 * It must make it safe for vanilla newlib code to run. | |
| 17 */ | |
| 18 void __pthread_initialize_minimal(size_t tdb_size) { | |
| 19 /* | |
| 20 * ld.so does most of the work for us, e.g. | |
| 21 * allocating and initialzing the tls area. | |
| 22 * For x86 we still need put the tdb in a | |
| 23 * state which our libpthread expects. | |
| 24 * This relies heavily on our tdb being "compatible" with | |
| 25 * glibc's tdb. | |
| 26 * C.f src/untrusted/pthread/pthread_types.h | |
| 27 */ | |
| 28 | |
| 29 /* | |
| 30 * the extra initialization is only needed for x86 | |
| 31 */ | |
| 32 if (__nacl_tp_tdb_offset(tdb_size) == 0) { | |
| 33 char *tp = __nacl_read_tp(); | |
| 34 void *tdb = (char *) tp + __nacl_tp_tdb_offset(tdb_size); | |
| 35 *(void **) tdb = tdb; | |
| 36 } | |
| 37 | |
| 38 /* | |
| 39 * Initialize newlib's thread-specific pointer. | |
| 40 */ | |
| 41 __newlib_thread_init(); | |
| 42 } | |
| OLD | NEW |