diff -urN nptl-0.36/nptl/sysdeps/powerpc/tls.h libc23/nptl/sysdeps/powerpc/tls.h --- nptl-0.36/nptl/sysdeps/powerpc/tls.h 2003-03-20 02:53:01.000000000 -0600 +++ libc23/nptl/sysdeps/powerpc/tls.h 2003-04-28 13:58:43.000000000 -0500 @@ -69,19 +69,21 @@ } tcbhead_t; /* This is the size of the initial TCB. */ -# define TLS_INIT_TCB_SIZE sizeof (tcbhead_t) +# define TLS_INIT_TCB_SIZE 0 /* Alignment requirements for the initial TCB. */ -# define TLS_INIT_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_INIT_TCB_ALIGN __alignof__ (struct pthread) /* This is the size of the TCB. */ -# define TLS_TCB_SIZE sizeof (tcbhead_t) +# define TLS_TCB_SIZE 0 /* Alignment requirements for the TCB. */ -# define TLS_TCB_ALIGN __alignof__ (tcbhead_t) +# define TLS_TCB_ALIGN __alignof__ (struct pthread) /* This is the size we need before TCB. */ -# define TLS_PRE_TCB_SIZE sizeof (struct pthread) +# define TLS_PRE_TCB_SIZE \ + (sizeof (struct pthread) \ + + ((sizeof (tcbhead_t) + TLS_TCB_ALIGN - 1) & ~(TLS_TCB_ALIGN - 1))) /* XXX if __alignof__ (struct pthread) > __alignof (tcbhead_t) we could be in trouble. -- paulus */ @@ -98,37 +100,37 @@ /* The following assumes that TP (R2 or R13) points to the end of the TCB + 0x7000 (per the ABI). This implies that TCB address is - TP-(TLS_TCB_SIZE + 0x7000). As we define TLS_DTV_AT_TP we can + TP - 0x7000. As we define TLS_DTV_AT_TP we can assume that the pthread struct is allocated immediately ahead of the TCB. This implies that the pthread_descr address is - TP-(TLS_PRE_TCB_SIZE + TLS_TCB_SIZE + 0x7000). */ + TP - (TLS_PRE_TCB_SIZE + 0x7000). */ # define TLS_TCB_OFFSET 0x7000 /* Install the dtv pointer. The pointer passed is to the element with index -1 which contain the length. */ -# define INSTALL_DTV(tcbp, dtvp) \ - ((tcbhead_t *) (tcbp))->dtv = dtvp + 1 +# define INSTALL_DTV(TCBP, DTVP) \ + ((tcbhead_t *) (TCBP))[-1].dtv = (DTVP) + 1 /* Install new dtv for current thread. */ -# define INSTALL_NEW_DTV(dtv) (THREAD_DTV() = (dtv)) +# define INSTALL_NEW_DTV(DTV) (THREAD_DTV() = (DTV)) /* Return dtv of given thread descriptor. */ -# define GET_DTV(tcbp) (((tcbhead_t *) (tcbp))->dtv) +# define GET_DTV(TCBP) (((tcbhead_t *) (TCBP))[-1].dtv) /* Code to initially initialize the thread pointer. This might need special attention since 'errno' is not yet available and if the operation can cause a failure 'errno' must not be touched. */ -# define TLS_INIT_TP(tcbp, secondcall) \ - (__thread_register = (void *) (tcbp) + TLS_TCB_OFFSET + TLS_TCB_SIZE, NULL) +# define TLS_INIT_TP(TCBP, secondcall) \ + (__thread_register = (void *) (TCBP) + TLS_TCB_OFFSET, NULL) /* Return the address of the dtv for the current thread. */ # define THREAD_DTV() \ - (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET - TLS_TCB_SIZE))->dtv) + (((tcbhead_t *) (__thread_register - TLS_TCB_OFFSET))[-1].dtv) /* Return the thread descriptor for the current thread. */ # define THREAD_SELF \ ((struct pthread *) (__thread_register \ - - TLS_TCB_OFFSET - TLS_TCB_SIZE - TLS_PRE_TCB_SIZE)) + - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)) /* Read member of the thread descriptor directly. */ # define THREAD_GETMEM(descr, member) ((void)(descr), (THREAD_SELF)->member)