build-many-glibcs.py: Add openrisc hard float glibc variant
[glibc.git] / sysdeps / x86_64 / dl-tls.c
blob869023bbba6f58176f8052da1432251b4667fe08
1 /* Thread-local storage handling in the ELF dynamic linker. x86-64 version.
2 Copyright (C) 2017-2024 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 <https://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 size_t gen = atomic_load_acquire (&GL(dl_tls_generation));
44 if (__glibc_unlikely (dtv[0].counter != gen))
45 return update_get_addr (GET_ADDR_PARAM, gen);
47 return tls_get_addr_tail (GET_ADDR_PARAM, dtv, NULL);
49 #else
51 /* No compatibility symbol needed. */
52 # include <elf/dl-tls.c>
54 #endif