Linux: use reserved name __key in pkey_get [BZ #22797]
[glibc.git] / sysdeps / arm / tls-macros.h
blob25cd84931b0c0dd665e2be59a46ec87e1a29d7c1
1 #include <sysdep.h> /* For ARCH_HAS_T2. */
3 #ifdef __thumb2__
4 # define ARM_PC_OFFSET "4"
5 #else
6 # define ARM_PC_OFFSET "8"
7 #endif
9 /* Returns the address of data containing ".word SYMBOL(RELOC)". */
10 #if defined (ARCH_HAS_T2) && !defined (PIC)
11 # define GET_SPECIAL_RELOC(symbol, reloc) \
12 ({ \
13 int *__##symbol##_rodata; \
14 asm ("movw %0, #:lower16:1f\n" \
15 "movt %0, #:upper16:1f\n" \
16 ".pushsection .rodata.cst4, \"aM\", %%progbits, 4\n" \
17 ".balign 4\n" \
18 "1: .word " #symbol "(" #reloc ")\n" \
19 ".popsection" \
20 : "=r" (__##symbol##_rodata)); \
21 __##symbol##_rodata; \
23 #elif defined (ARCH_HAS_T2) && defined (PIC) && ARM_PCREL_MOVW_OK
24 # define GET_SPECIAL_RELOC(symbol, reloc) \
25 ({ \
26 int *__##symbol##_rodata; \
27 asm ("movw %0, #:lower16:1f - 2f - " ARM_PC_OFFSET "\n" \
28 "movt %0, #:upper16:1f - 2f - " ARM_PC_OFFSET "\n" \
29 ".pushsection .rodata.cst4, \"aM\", %%progbits, 4\n" \
30 ".balign 4\n" \
31 "1: .word " #symbol "(" #reloc ")\n" \
32 ".popsection\n" \
33 "2: add %0, %0, pc" \
34 : "=r" (__##symbol##_rodata)); \
35 __##symbol##_rodata; \
37 #else
38 # define GET_SPECIAL_RELOC(symbol, reloc) \
39 ({ \
40 int *__##symbol##_rodata; \
41 asm ("adr %0, 1f\n" \
42 "b 2f\n" \
43 ".balign 4\n" \
44 "1: .word " #symbol "(" #reloc ")\n" \
45 "2:" \
46 : "=r" (__##symbol##_rodata)); \
47 __##symbol##_rodata; \
49 #endif
51 /* Returns the pointer value (SYMBOL(RELOC) + pc - PC_OFS). */
52 #define GET_SPECIAL_PCREL(symbol, reloc) \
53 ({ \
54 int *__##symbol##_rodata = GET_SPECIAL_RELOC (symbol, reloc); \
55 (void *) ((int) __##symbol##_rodata + *__##symbol##_rodata); \
58 #define TLS_LE(x) \
59 (__builtin_thread_pointer () + *GET_SPECIAL_RELOC (x, tpoff))
61 #define TLS_IE(x) \
62 ((int *) (__builtin_thread_pointer () \
63 + *(int *) GET_SPECIAL_PCREL (x, gottpoff)))
65 extern void *__tls_get_addr (void *);
67 #define TLS_LD(x) \
68 ((int *) (__tls_get_addr (GET_SPECIAL_PCREL (x, tlsldm)) \
69 + *GET_SPECIAL_RELOC (x, tlsldo)))
71 #define TLS_GD(x) \
72 ((int *) __tls_get_addr (GET_SPECIAL_PCREL (x, tlsgd)))