Back to index

glibc  2.9
dl-tls.h
Go to the documentation of this file.
00001 /* Thread-local storage handling in the ELF dynamic linker.  s390 version.
00002    Copyright (C) 2003, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 
00021 /* Type used for the representation of TLS information in the GOT.  */
00022 typedef struct
00023 {
00024   unsigned long int ti_module;
00025   unsigned long int ti_offset;
00026 } tls_index;
00027 
00028 
00029 #ifdef SHARED
00030 /* This is the prototype for the GNU version.  */
00031 extern void *__tls_get_addr (tls_index *ti) attribute_hidden;
00032 extern unsigned long __tls_get_offset (unsigned long got_offset);
00033 
00034 # ifdef IS_IN_rtld
00035 /* The special thing about the s390 TLS ABI is that we do not have the
00036    standard __tls_get_addr function but the __tls_get_offset function
00037    which differs in two important aspects:
00038    1) __tls_get_offset gets a got offset instead of a pointer to the
00039       tls_index structure
00040    2) __tls_get_offset returns the offset of the requested variable to
00041       the thread descriptor instead of a pointer to the variable.
00042  */
00043 #  ifdef __s390x__
00044 asm("\n\
00045        .text\n\
00046        .globl __tls_get_offset\n\
00047        .type __tls_get_offset, @function\n\
00048        .align 4\n\
00049 __tls_get_offset:\n\
00050        la     %r2,0(%r2,%r12)\n\
00051        jg     __tls_get_addr\n\
00052 ");
00053 #  elif defined __s390__
00054 asm("\n\
00055        .text\n\
00056        .globl __tls_get_offset\n\
00057        .type __tls_get_offset, @function\n\
00058        .align 4\n\
00059 __tls_get_offset:\n\
00060        basr   %r3,0\n\
00061 0:     la     %r2,0(%r2,%r12)\n\
00062        l      %r4,1f-0b(%r3)\n\
00063        b      0(%r4,%r3)\n\
00064 1:     .long  __tls_get_addr - 0b\n\
00065 ");
00066 #  endif
00067 # endif
00068 
00069 # define GET_ADDR_OFFSET \
00070   (ti->ti_offset - (unsigned long) __builtin_thread_pointer ())
00071 
00072 # define __TLS_GET_ADDR(__ti) \
00073   ({ extern char _GLOBAL_OFFSET_TABLE_[] attribute_hidden;              \
00074      (void *) __tls_get_offset ((char *) (__ti) - _GLOBAL_OFFSET_TABLE_)  \
00075      + (unsigned long) __builtin_thread_pointer (); }) 
00076 
00077 #endif