瀏覽代碼

linuxthreads: check TLS_DTV_AT_TP define correctly

Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Austin Foxley 16 年之前
父節點
當前提交
4596f46020
共有 3 個文件被更改,包括 11 次插入11 次删除
  1. 4 4
      libpthread/linuxthreads/manager.c
  2. 5 5
      libpthread/linuxthreads/pthread.c
  3. 2 2
      libpthread/linuxthreads_db/td_thr_tlsbase.c

+ 4 - 4
libpthread/linuxthreads/manager.c

@@ -601,7 +601,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
   new_thread = _dl_allocate_tls (NULL);
   new_thread = _dl_allocate_tls (NULL);
   if (new_thread == NULL)
   if (new_thread == NULL)
     return EAGAIN;
     return EAGAIN;
-# if TLS_DTV_AT_TP
+# if defined(TLS_DTV_AT_TP)
   /* pthread_descr is below TP.  */
   /* pthread_descr is below TP.  */
   new_thread = (pthread_descr) ((char *) new_thread - TLS_PRE_TCB_SIZE);
   new_thread = (pthread_descr) ((char *) new_thread - TLS_PRE_TCB_SIZE);
 # endif
 # endif
@@ -622,7 +622,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
       if (sseg >= PTHREAD_THREADS_MAX)
       if (sseg >= PTHREAD_THREADS_MAX)
 	{
 	{
 #ifdef USE_TLS
 #ifdef USE_TLS
-# if TLS_DTV_AT_TP
+# if defined(TLS_DTV_AT_TP)
 	  new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);
 	  new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);
 # endif
 # endif
 	  _dl_deallocate_tls (new_thread, true);
 	  _dl_deallocate_tls (new_thread, true);
@@ -824,7 +824,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
 #endif
 #endif
       }
       }
 #ifdef USE_TLS
 #ifdef USE_TLS
-# if TLS_DTV_AT_TP
+# if defined(TLS_DTV_AT_TP)
     new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);
     new_thread = (pthread_descr) ((char *) new_thread + TLS_PRE_TCB_SIZE);
 # endif
 # endif
     _dl_deallocate_tls (new_thread, true);
     _dl_deallocate_tls (new_thread, true);
@@ -917,7 +917,7 @@ static void pthread_free(pthread_descr th)
     }
     }
 
 
 #ifdef USE_TLS
 #ifdef USE_TLS
-# if TLS_DTV_AT_TP
+# if defined(TLS_DTV_AT_TP)
   th = (pthread_descr) ((char *) th + TLS_PRE_TCB_SIZE);
   th = (pthread_descr) ((char *) th + TLS_PRE_TCB_SIZE);
 # endif
 # endif
   _dl_deallocate_tls (th, true);
   _dl_deallocate_tls (th, true);

+ 5 - 5
libpthread/linuxthreads/pthread.c

@@ -474,10 +474,10 @@ __libc_dl_error_tsd (void)
 static __inline__ void __attribute__((always_inline))
 static __inline__ void __attribute__((always_inline))
 init_one_static_tls (pthread_descr descr, struct link_map *map)
 init_one_static_tls (pthread_descr descr, struct link_map *map)
 {
 {
-# if TLS_TCB_AT_TP
+# if defined(TLS_TCB_AT_TP)
   dtv_t *dtv = GET_DTV (descr);
   dtv_t *dtv = GET_DTV (descr);
   void *dest = (char *) descr - map->l_tls_offset;
   void *dest = (char *) descr - map->l_tls_offset;
-# elif TLS_DTV_AT_TP
+# elif defined(TLS_DTV_AT_TP)
   dtv_t *dtv = GET_DTV ((pthread_descr) ((char *) descr + TLS_PRE_TCB_SIZE));
   dtv_t *dtv = GET_DTV ((pthread_descr) ((char *) descr + TLS_PRE_TCB_SIZE));
   void *dest = (char *) descr + map->l_tls_offset + TLS_PRE_TCB_SIZE;
   void *dest = (char *) descr + map->l_tls_offset + TLS_PRE_TCB_SIZE;
 # else
 # else
@@ -669,9 +669,9 @@ int __pthread_initialize_manager(void)
     return -1;
     return -1;
   }
   }
 
 
-# if TLS_TCB_AT_TP
+# if defined(TLS_TCB_AT_TP)
   mgr = (pthread_descr) tcbp;
   mgr = (pthread_descr) tcbp;
-# elif TLS_DTV_AT_TP
+# elif defined(TLS_DTV_AT_TP)
   /* pthread_descr is located right below tcbhead_t which _dl_allocate_tls
   /* pthread_descr is located right below tcbhead_t which _dl_allocate_tls
      returns.  */
      returns.  */
   mgr = (pthread_descr) ((char *) tcbp - TLS_PRE_TCB_SIZE);
   mgr = (pthread_descr) ((char *) tcbp - TLS_PRE_TCB_SIZE);
@@ -996,7 +996,7 @@ static void pthread_onexit_process(int retcode, void *arg)
            For mtrace, we'd like to print something though.  */
            For mtrace, we'd like to print something though.  */
 	/* #ifdef USE_TLS
 	/* #ifdef USE_TLS
 	   tcbhead_t *tcbp = (tcbhead_t *) manager_thread;
 	   tcbhead_t *tcbp = (tcbhead_t *) manager_thread;
-	   # if TLS_DTV_AT_TP
+	   # if defined(TLS_DTV_AT_TP)
 	   tcbp = (tcbhead_t) ((char *) tcbp + TLS_PRE_TCB_SIZE);
 	   tcbp = (tcbhead_t) ((char *) tcbp + TLS_PRE_TCB_SIZE);
 	   # endif
 	   # endif
 	   _dl_deallocate_tls (tcbp, true);
 	   _dl_deallocate_tls (tcbp, true);

+ 2 - 2
libpthread/linuxthreads_db/td_thr_tlsbase.c

@@ -36,9 +36,9 @@ td_thr_tlsbase (const td_thrhandle_t *th,
   LOG ("td_thr_tlsbase");
   LOG ("td_thr_tlsbase");
 
 
   psaddr_t dtvpp = th->th_unique;
   psaddr_t dtvpp = th->th_unique;
-#if TLS_TCB_AT_TP
+#if defined(TLS_TCB_AT_TP)
   dtvpp += offsetof (struct _pthread_descr_struct, p_header.data.dtvp);
   dtvpp += offsetof (struct _pthread_descr_struct, p_header.data.dtvp);
-#elif TLS_DTV_AT_TP
+#elif defined(TLS_DTV_AT_TP)
 /* Special case hack.  If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB
 /* Special case hack.  If TLS_TCB_SIZE == 0 (on PowerPC), there is no TCB
    containing the DTV at the TP, but actually the TCB lies behind the TP,
    containing the DTV at the TP, but actually the TCB lies behind the TP,
    i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE.  */
    i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE.  */