]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/csky/abiv2/tls-macros.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / csky / abiv2 / tls-macros.h
1 /* Macros for accessing thread-local storage. C-SKY ABIV2 version.
2 Copyright (C) 2018-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19 # define TLS_LE(x) \
20 ({ int *__result; \
21 __asm__ ("lrw %0, " #x "@TPOFF\n\t" \
22 "add %0, tls, %0" \
23 : "=&r" (__result)); \
24 __result; })
25
26 # define TLS_IE(x) \
27 ({ int *__result; \
28 __asm__ ("grs a1, 1f\n" \
29 "1:\tlrw %0, " #x "@GOTTPOFF\n\t" \
30 "ldr.w %0, (a1, %0 << 0)\n\t" \
31 "add %0, tls, %0" \
32 : "=&r" (__result): : "a1"); \
33 __result; })
34
35 # define TLS_LD(x) \
36 ({ char *__result; \
37 int __offset; \
38 extern void *__tls_get_addr (void *); \
39 __asm__ ("grs a1, 1f\n" \
40 "1:\tlrw %0, " #x "@TLSLDM32;\n\t" \
41 "add %0, a1, %0" \
42 : "=r" (__result) : : "a1"); \
43 __result = (char *)__tls_get_addr (__result); \
44 __asm__ ("lrw %0, " #x "@TLSLDO32" \
45 : "=r" (__offset)); \
46 (int *) (__result + __offset); })
47
48 # define TLS_GD(x) \
49 ({ int *__result; \
50 extern void *__tls_get_addr (void *); \
51 __asm__ ("grs a1, 1f\n" \
52 "1:\tlrw %0, " #x "@TLSGD32\n\t" \
53 "add %0, a1, %0" \
54 : "=r" (__result) : : "a1"); \
55 (int *)__tls_get_addr (__result); })