about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/ChangeLog16
-rw-r--r--nptl/init.c9
-rw-r--r--nptl/pt-longjmp.c4
-rw-r--r--nptl/pthreadP.h3
-rw-r--r--nptl/sysdeps/pthread/bits/libc-lock.h22
5 files changed, 48 insertions, 6 deletions
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 3fd2f22f4d..dcf3815b02 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,19 @@
+2003-08-07  Jakub Jelinek  <jakub@redhat.com>
+
+	* sysdeps/pthread/bits/libc-lock.h [_LIBC && SHARED]
+	(__rtld_lock_default_lock_recursive,
+	__rtld_lock_default_unlock_recursive): Define.
+	[_LIBC && SHARED] (__rtld_lock_lock_recursive,
+	__rtld_lock_unlock_recursive): Define using
+	GL(_dl_rtld_*lock_recursive).
+	* init.c (__pthread_initialize_minimal_internal): Initialize
+	_dl_rtld_lock_recursive and _dl_rtld_unlock_recursive.
+	Lock GL(_dl_load_lock) the same number of times as
+	GL(_dl_load_lock) using non-mt implementation was nested.
+
+	* pthreadP.h (__pthread_cleanup_upto): Add hidden_proto.
+	* pt-longjmp.c (__pthread_cleanup_upto): Add hidden_def.
+
 2003-08-06  Jakub Jelinek  <jakub@redhat.com>
 
 	* tst-cancel17.c (do_test): Make len2 maximum of page size and
diff --git a/nptl/init.c b/nptl/init.c
index dae24f1eac..1f60e92aeb 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -270,6 +270,15 @@ __pthread_initialize_minimal_internal (void)
   /* Transfer the old value from the dynamic linker's internal location.  */
   *__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();
   GL(dl_error_catch_tsd) = &__libc_dl_error_tsd;
+
+  /* Make __rtld_lock_{,un}lock_recursive use pthread_mutex_{,un}lock,
+     keep the lock count from the ld.so implementation.  */
+  GL(dl_rtld_lock_recursive) = (void *) INTUSE (__pthread_mutex_lock);
+  GL(dl_rtld_unlock_recursive) = (void *) INTUSE (__pthread_mutex_unlock);
+  unsigned int rtld_lock_count = GL(dl_load_lock).mutex.__data.__count;
+  GL(dl_load_lock).mutex.__data.__count = 0;
+  while (rtld_lock_count-- > 0)
+    INTUSE (__pthread_mutex_lock) (&GL(dl_load_lock).mutex);
 #endif
 
   GL(dl_init_static_tls) = &__pthread_init_static_tls;
diff --git a/nptl/pt-longjmp.c b/nptl/pt-longjmp.c
index f333b8dfb0..f217e307f9 100644
--- a/nptl/pt-longjmp.c
+++ b/nptl/pt-longjmp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -54,7 +54,7 @@ __pthread_cleanup_upto (__jmp_buf target, char *targetframe)
 
   THREAD_SETMEM (self, cleanup, cbuf);
 }
-
+hidden_def (__pthread_cleanup_upto)
 
 
 void
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index b07c6da961..99b344489a 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -217,6 +217,9 @@ extern void __reclaim_stacks (void) attribute_hidden;
 
 /* longjmp handling.  */
 extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe);
+#if defined NOT_IN_libc && defined IS_IN_libpthread
+hidden_proto (__pthread_cleanup_upto)
+#endif
 
 
 /* Functions with versioned interfaces.  */
diff --git a/nptl/sysdeps/pthread/bits/libc-lock.h b/nptl/sysdeps/pthread/bits/libc-lock.h
index 35bc21b95a..f7ed88dae6 100644
--- a/nptl/sysdeps/pthread/bits/libc-lock.h
+++ b/nptl/sysdeps/pthread/bits/libc-lock.h
@@ -248,9 +248,6 @@ typedef pthread_key_t __libc_key_t;
   __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
 #endif
 
-#define __rtld_lock_lock_recursive(NAME) \
-  __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
-
 /* Try to lock the named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
 # define __libc_lock_trylock(NAME) \
@@ -319,8 +316,25 @@ typedef pthread_key_t __libc_key_t;
   __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)
 #endif
 
-#define __rtld_lock_unlock_recursive(NAME) \
+#if defined _LIBC && defined SHARED
+# define __rtld_lock_default_lock_recursive(lock) \
+  ++((pthread_mutex_t *)(lock))->__data.__count;
+
+# define __rtld_lock_default_unlock_recursive(lock) \
+  --((pthread_mutex_t *)(lock))->__data.__count;
+
+# define __rtld_lock_lock_recursive(NAME) \
+  GL(dl_rtld_lock_recursive) (&(NAME).mutex)
+
+# define __rtld_lock_unlock_recursive(NAME) \
+  GL(dl_rtld_unlock_recursive) (&(NAME).mutex)
+#else
+# define __rtld_lock_lock_recursive(NAME) \
+  __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
+
+# define __rtld_lock_unlock_recursive(NAME) \
   __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0)
+#endif
 
 /* Define once control variable.  */
 #if PTHREAD_ONCE_INIT == 0