about summary refs log tree commit diff
path: root/sysdeps/s390/s390-32/tls-macros.h
blob: a592d81585cdc4b979ea113b640105bc8bc3ac9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#define TLS_LE(x) \
  ({ unsigned long __offset;						      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long " #x "@ntpoff\n"					      \
	  "1:\tl %0,0(%0)"						      \
	  : "=a" (__offset) : : "cc" );					      \
     (int *) (__builtin_thread_pointer() + __offset); })

#ifdef PIC
# define TLS_IE(x) \
  ({ unsigned long __offset, __got;					      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t"			      \
	  ".long " #x "@gotntpoff\n"					      \
	  "1:\tl %1,0(%0)\n\t"						      \
	  "la %1,0(%1,%0)\n\t"						      \
	  "l %0,4(%0)\n\t"						      \
	  "l %0,0(%0,%1):tls_load:" #x "\n"				      \
	  : "=&a" (__offset), "=&a" (__got) : : "cc" );			      \
     (int *) (__builtin_thread_pointer() + __offset); })
#else
# define TLS_IE(x) \
  ({ unsigned long  __offset;						      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long " #x "@indntpoff\n"				      \
	  "1:\t l %0,0(%0)\n\t"						      \
	  "l %0,0(%0):tls_load:" #x					      \
	  : "=&a" (__offset) : : "cc" );				      \
     (int *) (__builtin_thread_pointer() + __offset); })
#endif

#ifdef PIC
# define TLS_LD(x) \
  ({ unsigned long __offset, __save12;					      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t"			      \
	  ".long __tls_get_offset@plt-0b\n\t"				      \
	  ".long " #x "@tlsldm\n\t"					      \
	  ".long " #x "@dtpoff\n"					      \
	  "1:\tlr %1,%%r12\n\t"						      \
	  "l %%r12,0(%0)\n\t"						      \
	  "la %%r12,0(%%r12,%0)\n\t"					      \
	  "l %%r1,4(%0)\n\t"						      \
	  "l %%r2,8(%0)\n\t"						      \
	  "bas %%r14,0(%%r1,%0):tls_ldcall:" #x "\n\t"			      \
	  "l %0,12(%0)\n\t"						      \
	  "alr %0,%%r2\n\t"						      \
	  "lr %%r12,%1"							      \
	  : "=&a" (__offset), "=&a" (__save12)				      \
	  : : "cc", "0", "1", "2", "3", "4", "5" );			      \
     (int *) (__builtin_thread_pointer() + __offset); })
#else
# define TLS_LD(x) \
  ({ unsigned long __offset;						      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t"				      \
	  ".long __tls_get_offset@plt\n\t"				      \
	  ".long " #x "@tlsldm\n\t"					      \
	  ".long " #x "@dtpoff\n"					      \
	  "1:\tl %%r12,0(%0)\n\t"					      \
	  "l %%r1,4(%0)\n\t"						      \
	  "l %%r2,8(%0)\n\t"						      \
	  "bas %%r14,0(%%r1):tls_ldcall:" #x "\n\t"			      \
	  "l %0,12(%0)\n\t"						      \
	  "alr %0,%%r2"							      \
	  : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" );  \
     (int *) (__builtin_thread_pointer() + __offset); })
#endif

#ifdef PIC
# define TLS_GD(x) \
  ({ unsigned long __offset, __save12;					      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long _GLOBAL_OFFSET_TABLE_-0b\n\t"			      \
	  ".long __tls_get_offset@plt-0b\n\t"				      \
	  ".long " #x "@tlsgd\n"					      \
	  "1:\tlr %1,%%r12\n\t"						      \
	  "l %%r12,0(%0)\n\t"						      \
	  "la %%r12,0(%%r12,%0)\n\t"					      \
	  "l %%r1,4(%0)\n\t"						      \
	  "l %%r2,8(%0)\n\t"						      \
	  "bas %%r14,0(%%r1,%0):tls_gdcall:" #x "\n\t"			      \
	  "lr %0,%%r2\n\t"						      \
	  "lr %%r12,%1"							      \
	  : "=&a" (__offset), "=&a" (__save12)				      \
	  : : "cc", "0", "1", "2", "3", "4", "5" );			      \
     (int *) (__builtin_thread_pointer() + __offset); })
#else
# define TLS_GD(x) \
  ({ unsigned long __offset;						      \
     asm ("bras %0,1f\n"						      \
	  "0:\t.long _GLOBAL_OFFSET_TABLE_\n\t"				      \
	  ".long __tls_get_offset@plt\n\t"				      \
	  ".long " #x "@tlsgd\n"					      \
	  "1:\tl %%r12,0(%0)\n\t"					      \
	  "l %%r1,4(%0)\n\t"						      \
	  "l %%r2,8(%0)\n\t"						      \
	  "bas %%r14,0(%%r1):tls_gdcall:" #x "\n\t"			      \
	  "lr %0,%%r2"							      \
	  : "=&a" (__offset) : : "cc", "0", "1", "2", "3", "4", "5", "12" );  \
     (int *) (__builtin_thread_pointer() + __offset); })
#endif