]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(pthread_initialize): Instead of on_exit use __cxa_atexit if __dso_label is
authorUlrich Drepper <drepper@redhat.com>
Tue, 21 Mar 2000 05:07:44 +0000 (05:07 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 21 Mar 2000 05:07:44 +0000 (05:07 +0000)
available to allow unloading the libpthread shared library.

linuxthreads/pthread.c

index 0dfdf693b80b0c9ea79351620af5a20119340736..6a6d915d18fdc62a635da44f744270ba7fe3b890 100644 (file)
@@ -298,6 +298,8 @@ __libc_allocate_rtsig (int high)
 
 static void pthread_initialize(void) __attribute__((constructor));
 
+extern void *__dso_handle __attribute__ ((weak));
+
 static void pthread_initialize(void)
 {
   struct sigaction sa;
@@ -370,7 +372,13 @@ static void pthread_initialize(void)
   /* Register an exit function to kill all other threads. */
   /* Do it early so that user-registered atexit functions are called
      before pthread_exit_process. */
-  __on_exit(pthread_exit_process, NULL);
+  if (__dso_handle)
+    /* The cast is a bit unclean.  The function expects two arguments but
+       we can only pass one.  Fortunately this is not a problem since the
+       second argument of `pthread_exit_process' is simply ignored.  */
+    __cxa_atexit((void (*) (void *)) pthread_exit_process, NULL, __dso_handle);
+  else
+    on_exit (pthread_exit_process, NULL);
 }
 
 void __pthread_initialize(void)