Update copyright notices with scripts/update-copyrights.
[glibc.git] / sysdeps / s390 / dl-tls.h
blob68a5af41527a2df1d754ef3be9d9d9f1f0d8545c
1 /* Thread-local storage handling in the ELF dynamic linker. s390 version.
2 Copyright (C) 2003-2013 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/>. */
20 /* Type used for the representation of TLS information in the GOT. */
21 typedef struct
23 unsigned long int ti_module;
24 unsigned long int ti_offset;
25 } tls_index;
28 #ifdef SHARED
29 /* This is the prototype for the GNU version. */
30 extern void *__tls_get_addr (tls_index *ti) attribute_hidden;
31 extern unsigned long __tls_get_offset (unsigned long got_offset);
33 # ifdef IS_IN_rtld
34 /* The special thing about the s390 TLS ABI is that we do not have the
35 standard __tls_get_addr function but the __tls_get_offset function
36 which differs in two important aspects:
37 1) __tls_get_offset gets a got offset instead of a pointer to the
38 tls_index structure
39 2) __tls_get_offset returns the offset of the requested variable to
40 the thread descriptor instead of a pointer to the variable.
42 # ifdef __s390x__
43 asm("\n\
44 .text\n\
45 .globl __tls_get_offset\n\
46 .type __tls_get_offset, @function\n\
47 .align 4\n\
48 __tls_get_offset:\n\
49 la %r2,0(%r2,%r12)\n\
50 jg __tls_get_addr\n\
51 ");
52 # elif defined __s390__
53 asm("\n\
54 .text\n\
55 .globl __tls_get_offset\n\
56 .type __tls_get_offset, @function\n\
57 .align 4\n\
58 __tls_get_offset:\n\
59 basr %r3,0\n\
60 0: la %r2,0(%r2,%r12)\n\
61 l %r4,1f-0b(%r3)\n\
62 b 0(%r4,%r3)\n\
63 1: .long __tls_get_addr - 0b\n\
64 ");
65 # endif
66 # endif
68 # define GET_ADDR_OFFSET \
69 (ti->ti_offset - (unsigned long) __builtin_thread_pointer ())
71 # define __TLS_GET_ADDR(__ti) \
72 ({ extern char _GLOBAL_OFFSET_TABLE_[] attribute_hidden; \
73 (void *) __tls_get_offset ((char *) (__ti) - _GLOBAL_OFFSET_TABLE_) \
74 + (unsigned long) __builtin_thread_pointer (); })
76 #endif
78 /* Value used for dtv entries for which the allocation is delayed. */
79 #define TLS_DTV_UNALLOCATED ((void *) -1l)