This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc 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]

Allow linuxthreads --with-tls to work with TLS_DTV_AT_TP


I originally posted this as part of the MIPS NPTL support, but since it
isn't MIPS specific I'm reposting it separately.

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.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

2005-03-27  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-03-27 10:48:37.948125931 -0500
+++ glibc/linuxthreads/descr.h	2005-03-27 10:48:56.816618126 -0500
@@ -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]