This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

LinuxThreads TLS adjustment for ARM/MIPS


I've had this patch in my tree for most of the year.  Here's what I
originally wrote about it on libc-alpha:

> The problem is that libc.so and libpthread.so both know the layout of
> struct _pthread_descr_struct, in order for __errno_location to use the
> thread-specific errno.  The initial members of that structure are
> guarded by a conditional:
> 
>   #if !defined USE_TLS || !TLS_DTV_AT_TP
> 
> For Alpha, ia64, PowerPC, SH, and the MIPS and ARM ports I'm working
> on, TLS_DTV_AT_TP is set.  So if libc.so and linuxthreads.so don't
> agree on the value of USE_TLS, the structure won't match.  Alpha, ia64,
> and PowerPC only require toolchain support in order to use TLS, so this
> isn't a problem; linuxthreads is built with USE_TLS defined.  For i386,
> more is required, but they meet the !TLS_DTV_AT_TP check so these
> members are never included.
> 
> However, SH and ARM and MIPS require kernel support for TLS that we
> can't assume is present.  So, just like i386, they disable TLS while
> building libpthread.so unless the appropriate kernel is assumed.  This
> breaks __errno_location() in glibc.  This patch lets such ports request
> the initial elements to be consistently declared.

The relevant macro is already defined by MIPS and ARM (it leaked in when I
contributed them).  I can't test SH, so I'm leaving it alone, but I believe
that SH would need this in order for a LinuxThreads library for old
kernels (with --enable-tls --without-__thread) and an NPTL library for
new kernels to coexist.  Otherwise the LinuxThreads ld.so misses the NPTL
p_errno.

Tested on ARM, checked in.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-11-11  Daniel Jacobowitz  <dan@codesourcery.com>

	* descr.h (struct _pthread_descr_struct): Include padding if
	INCLUDE_TLS_PADDING.

Index: glibc/linuxthreads/descr.h
===================================================================
--- glibc.orig/linuxthreads/descr.h	2005-02-10 02:16:16.000000000 -0500
+++ glibc/linuxthreads/descr.h	2005-10-04 13:58:15.000000000 -0400
@@ -109,7 +109,7 @@ union dtv;
 
 struct _pthread_descr_struct
 {
-#if !defined USE_TLS || !TLS_DTV_AT_TP
+#if !defined USE_TLS || !TLS_DTV_AT_TP || INCLUDE_TLS_PADDING
   /* This overlaps tcbhead_t (see tls.h), as used for TLS without threads.  */
   union
   {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]