OSDN Git Service

Patch from Stefan Allius and Edie C. Dost:
authorEric Andersen <andersen@codepoet.org>
Thu, 8 Aug 2002 15:44:46 +0000 (15:44 -0000)
committerEric Andersen <andersen@codepoet.org>
Thu, 8 Aug 2002 15:44:46 +0000 (15:44 -0000)
In linuxthreads/errno.h the functions __errno_location and
__h_errno_location wasn't safe against calling before the
library is initialized.

libpthread/linuxthreads/errno.c
libpthread/linuxthreads/pthread.c

index ad43be4..46e2fbb 100644 (file)
 #include <netdb.h>
 #include "pthread.h"
 #include "internals.h"
+#include <stdio.h>
+extern int _errno;
+extern int _h_errno;
 
 int * __errno_location()
 {
-  pthread_descr self = thread_self();
-  return THREAD_GETMEM (self, p_errnop);
+  /* 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()
 {
-  pthread_descr self = thread_self();
-  return THREAD_GETMEM (self, p_h_errnop);
+  /* 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;        
 }
index 90c7708..548f83a 100644 (file)
@@ -349,8 +349,10 @@ int __pthread_initialize_manager(void)
   NOMMU_INITIAL_THREAD_BOUNDS(__pthread_manager_thread_tos,__pthread_manager_thread_bos);
   PDEBUG("manager stack: size=%d, bos=%p, tos=%p\n", THREAD_MANAGER_STACK_SIZE,
         __pthread_manager_thread_bos, __pthread_manager_thread_tos);
+#if 0
   PDEBUG("initial stack: estimate bos=%p, tos=%p\n",
-        __pthread_initial_thread_bos, __pthread_initial_thread_tos);
+        __pthread_initial_thread_bos, __pthread_initial_thread_tos);
+#endif
 
   /* Setup pipe to communicate with thread manager */
   if (pipe(manager_pipe) == -1) {