file kaio_read64.c was initially added on branch fedora-branch.
[glibc/history.git] / sysdeps / s390 / dl-tls.h
blob0560462857e27960846c0dca560e16afbf4a9e66
1 /* Thread-local storage handling in the ELF dynamic linker. s390 version.
2 Copyright (C) 2003, 2004 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
21 /* Type used for the representation of TLS information in the GOT. */
22 typedef struct
24 unsigned long int ti_module;
25 unsigned long int ti_offset;
26 } tls_index;
29 #ifdef SHARED
30 /* This is the prototype for the GNU version. */
31 extern void *__tls_get_addr (tls_index *ti) attribute_hidden;
32 extern unsigned long __tls_get_offset (unsigned long got_offset);
34 # ifdef IS_IN_rtld
35 /* The special thing about the s390 TLS ABI is that we do not have the
36 standard __tls_get_addr function but the __tls_get_offset function
37 which differs in two important aspects:
38 1) __tls_get_offset gets a got offset instead of a pointer to the
39 tls_index structure
40 2) __tls_get_offset returns the offset of the requested variable to
41 the thread descriptor instead of a pointer to the variable.
43 # ifdef __s390x__
44 asm("\n\
45 .text\n\
46 .globl __tls_get_offset\n\
47 .type __tls_get_offset, @function\n\
48 .align 4\n\
49 __tls_get_offset:\n\
50 la %r2,0(%r2,%r12)\n\
51 jg __tls_get_addr\n\
52 ");
53 # elif defined __s390__
54 asm("\n\
55 .text\n\
56 .globl __tls_get_offset\n\
57 .type __tls_get_offset, @function\n\
58 .align 4\n\
59 __tls_get_offset:\n\
60 basr %r3,0\n\
61 0: la %r2,0(%r2,%r12)\n\
62 l %r4,1f-0b(%r3)\n\
63 b 0(%r4,%r3)\n\
64 1: .long __tls_get_addr - 0b\n\
65 ");
66 # endif
67 # endif
69 # define GET_ADDR_OFFSET \
70 (ti->ti_offset - (unsigned long) __builtin_thread_pointer ())
72 # define __TLS_GET_ADDR(__ti) \
73 ({ extern char _GLOBAL_OFFSET_TABLE_[] attribute_hidden; \
74 (void *) __tls_get_offset ((char *) (__ti) - _GLOBAL_OFFSET_TABLE_) \
75 + (unsigned long) __builtin_thread_pointer (); })
77 #endif