Procházet zdrojové kódy

Based on work by Stefan Allius, arrange for early initialization of
pthread stuff. Also, don't bother building libthread_db unless we
are debugging.
-Erik

Eric Andersen před 22 roky
rodič
revize
3358b761b1

+ 4 - 1
libpthread/Makefile

@@ -30,7 +30,10 @@ LIBTHREAD_DB_SHARED_FULLNAME=libthread_db-$(MAJOR_VERSION).$(MINOR_VERSION).$(SU
 
 DIRS=
 ifeq ($(strip $(INCLUDE_THREADS)),true)
-	DIRS+=linuxthreads linuxthreads_db
+	DIRS+=linuxthreads
+endif
+ifeq ($(strip $(DODEBUG)),true)
+	DIRS+=linuxthreads_db
 endif
 
 ALL_SUBDIRS = linuxthreads linuxthreads_db

+ 0 - 13
libpthread/linuxthreads/errno.c

@@ -21,28 +21,15 @@
 #include "pthread.h"
 #include "internals.h"
 #include <stdio.h>
-extern int _errno;
-extern int _h_errno;
 
 int * __errno_location()
 {
-  /* check, if the library is initilize */
-  if (__pthread_initial_thread_bos != NULL)
-  {
     pthread_descr self = thread_self();
     return THREAD_GETMEM (self, p_errnop);
-  }
-  return &_errno;
 }
 
 int * __h_errno_location()
 {
-  /* check, if the library is initilize */
-  if (__pthread_initial_thread_bos != NULL)
-  {
     pthread_descr self = thread_self();
-
     return THREAD_GETMEM (self, p_h_errnop);
-  }
-  return &_h_errno;        
 }

+ 2 - 0
libpthread/linuxthreads/events.c

@@ -19,6 +19,8 @@
 
 /* The functions contained here do nothing, they just return.  */
 
+#include "internals.h"
+
 void
 __linuxthreads_create_event (void)
 {

+ 1 - 0
libpthread/linuxthreads/internals.h

@@ -426,6 +426,7 @@ void __pthread_reset_main_thread(void);
 void __fresetlockfiles(void);
 void __pthread_manager_adjust_prio(int thread_prio);
 void __pthread_set_own_extricate_if(pthread_descr self, pthread_extricate_if *peif);
+void __pthread_initialize_minimal (void);
 
 extern int __pthread_attr_setguardsize __P ((pthread_attr_t *__attr,
 					     size_t __guardsize));

+ 12 - 0
libpthread/linuxthreads/pthread.c

@@ -236,6 +236,18 @@ void (*__pthread_suspend)(pthread_descr) = __pthread_suspend_old;
 
 static void pthread_initialize(void) __attribute__((constructor));
 
+ /* Do some minimal initialization which has to be done during the
+    startup of the C library.  */
+void __pthread_initialize_minimal(void)
+{
+    /* If we have special thread_self processing, initialize 
+     * that for the main thread now.  */
+#ifdef INIT_THREAD_SELF
+    INIT_THREAD_SELF(&__pthread_initial_thread, 0);
+#endif
+}
+
+
 static void pthread_initialize(void)
 {
   struct sigaction sa;