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/nacl/nacl_irt.h"
8 #include "native_client/src/untrusted/nacl/nacl_thread.h"
9 #include "native_client/src/untrusted/nacl/tls.h"
12 * The compiler generates calls to __nacl_read_tp() for TLS accesses.
13 * This is primarily used for x86-64. See src/untrusted/nacl/tls.h.
15 * __nacl_read_tp() is also used on x86-32 when compiling with
16 * "-mtls-use-call". This is for when TLS accesses need to be
17 * virtualised -- specifically, for object files that might get linked
18 * into the integrated runtime (IRT) library.
20 * NOTE: In the glibc build, this is defined in ld.so rather than here.
22 void *__nacl_read_tp(void) {
25 * Calling nacl_tls_get() works on x86-32, but reading %gs:0 is a
29 __asm__("mov %%gs:0, %0" : "=r"(result));
32 return nacl_tls_get();