Fix build failure on tilepro due to unsupported atomics
[glibc.git] / sysdeps / x86_64 / dl-tls.c
blob3584805c8ecca59a03f44fdb013633fb9a37e1b2
1 /* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
2 Copyright (C) 2017 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifdef SHARED
20 /* Work around GCC PR58066, due to which __tls_get_addr may be called
21 with an unaligned stack. The compat implementation is in
22 tls_get_addr-compat.S. */
24 # include <dl-tls.h>
26 /* Define __tls_get_addr within elf/dl-tls.c under a different
27 name. */
28 extern __typeof__ (__tls_get_addr) ___tls_get_addr;
30 # define __tls_get_addr ___tls_get_addr
31 # include <elf/dl-tls.c>
32 # undef __tls_get_addr
34 hidden_ver (___tls_get_addr, __tls_get_addr)
36 /* Only handle slow paths for __tls_get_addr. */
37 attribute_hidden
38 void *
39 __tls_get_addr_slow (GET_ADDR_ARGS)
41 dtv_t *dtv = THREAD_DTV ();
43 if (__glibc_unlikely (dtv[0].counter != GL(dl_tls_generation)))
44 return update_get_addr (GET_ADDR_PARAM);
46 return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL);
48 #else
50 /* No compatibility symbol needed. */
51 # include <elf/dl-tls.c>
53 #endif