summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-12-08 03:13:06 +0000
committerUlrich Drepper <drepper@redhat.com>2002-12-08 03:13:06 +0000
commit09efc3ba1269f79b78ee0724501fc762c2d5ab49 (patch)
tree840ca5c526b221f3510f23b1f17c9e379b84129f
parent6ccb3834ebf1cb65d180144442a68cd1c24f1dd5 (diff)
downloadglibc-09efc3ba1269f79b78ee0724501fc762c2d5ab49.tar.gz
glibc-09efc3ba1269f79b78ee0724501fc762c2d5ab49.tar.xz
glibc-09efc3ba1269f79b78ee0724501fc762c2d5ab49.zip
Update.
2002-12-07  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/generic/bits/stdio-lock.h (_IO_lock_trylock): New define.
-rw-r--r--ChangeLog4
-rw-r--r--bits/stdio-lock.h3
-rw-r--r--nptl/Banner2
-rw-r--r--nptl/ChangeLog41
-rw-r--r--nptl/Makefile1
-rw-r--r--nptl/cleanup.c5
-rw-r--r--nptl/ftrylockfile.c5
-rw-r--r--nptl/pthreadP.h25
-rw-r--r--nptl/pthread_cancel.c2
-rw-r--r--nptl/pthread_cond_timedwait.c4
-rw-r--r--nptl/pthread_cond_wait.c4
-rw-r--r--nptl/pthread_mutex_lock.c1
-rw-r--r--nptl/pthread_mutex_unlock.c1
-rw-r--r--nptl/pthread_setcanceltype.c3
-rw-r--r--nptl/sem_open.c8
-rw-r--r--nptl/sem_unlink.c2
-rw-r--r--nptl/sysdeps/pthread/bits/libc-lock.h9
-rw-r--r--nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S3
-rw-r--r--nptl/sysdeps/unix/sysv/linux/pthread_kill.c3
-rw-r--r--sysdeps/generic/bits/stdio-lock.h3
20 files changed, 101 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 467b3b5172..e5457609bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-12-07  Ulrich Drepper  <drepper@redhat.com>
+
+	* sysdeps/generic/bits/stdio-lock.h (_IO_lock_trylock): New define.
+
 2002-12-07  Roland McGrath  <roland@redhat.com>
 
 	* sysdeps/generic/libc-tls.c (__libc_setup_tls): Reintroduce changes
diff --git a/bits/stdio-lock.h b/bits/stdio-lock.h
index 5b1c1b082e..b6eb98d921 100644
--- a/bits/stdio-lock.h
+++ b/bits/stdio-lock.h
@@ -1,5 +1,5 @@
 /* Thread package specific definitions of stream lock type.  Generic version.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -34,6 +34,7 @@ __libc_lock_define_recursive (typedef, _IO_lock_t)
 #define _IO_lock_init(_name)	__libc_lock_init_recursive (_name)
 #define _IO_lock_fini(_name)	__libc_lock_fini_recursive (_name)
 #define _IO_lock_lock(_name)	__libc_lock_lock_recursive (_name)
+#define _IO_lock_trylock(_name)	__libc_lock_trylock_recursive (_name)
 #define _IO_lock_unlock(_name)	__libc_lock_unlock_recursive (_name)
 
 
diff --git a/nptl/Banner b/nptl/Banner
index 99b45d9c1f..60acf42c6a 100644
--- a/nptl/Banner
+++ b/nptl/Banner
@@ -1 +1 @@
-nptl 0.11 by Ulrich Drepper
+nptl 0.12 by Ulrich Drepper
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 697086c996..d2544922a6 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,5 +1,46 @@
 2002-12-07  Ulrich Drepper  <drepper@redhat.com>
 
+	* Makefile (CFLAGS-ftrylockfile.c): Add -D_IO_MTSAFE_IO.
+
+	* cleanup.c: Move declarations of _GI_pthread_cleanup_push and
+	_GI_pthread_cleanup_pop to pthreadP.h.
+
+	* ftrylockfile.c: Use _IO_lock_trylock instead of
+	pthread_mutex_trylock.
+
+	* pthreadP.h (CANCEL_ASYNC): Use __pthread_setcanceltype.
+	(CANCEL_RESET): Likewise.
+	(__pthread_setcanceltype_): Declare.
+	(__pthread_mutex_lock_internal): Declare.
+	(__pthread_mutex_unlock_internal): Declare.
+	(__pthread_once_internal): Declare.
+	(pthread_cleanup_push): Redefine using _GI_pthread_cleanup_push.
+	(pthread_cleanup_pop): Redefine using _GI_pthread_cleanup_pop.
+
+	* pthread_cond_timedwait.c: Use INTUSE is calls to pthread_mutex_lock
+	and pthread_mutex_unlock.
+	* pthread_cond_wait.c: Likewise.
+	* pthread_mutex_lock.c: Use INTDEF to define alias if needed.
+	* pthread_mutex_unlock.c: Likewise.
+
+	* pthread_setcanceltype.c: Add additional alias
+	__pthread_setcanceltype.
+
+	* sem_unlink.c (sem_unlink): Use __pthread_once with INTDEF.
+	* sem_open.c (sem_open): Likewise.
+	Use __libc_open, __libc_write, and __libc_close instead of
+	open, write, and close respectively.
+
+	* sysdeps/pthread/bits/libc-lock.h (__libc_lock_trylock_internal):
+	Rewrite as statement expression since it must return a value.
+
+	* pthread_cancel.c: Use __pthread_kill instead of pthread_kill.
+	* sysdeps/unix/sysv/linux/pthread_kill.c: Define additional alias
+	__pthread_kill.
+
+	* sysdeps/unix/sysv/linux/i386/pthread_once.S: Define additional
+	alias __pthread_once_internal.
+
 	* sysdeps/unix/sysv/linux/raise.c: Use libc_hidden_def for raise.
 
 2002-12-06  Ulrich Drepper  <drepper@redhat.com>
diff --git a/nptl/Makefile b/nptl/Makefile
index 77541b8874..00c63d87e6 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -157,6 +157,7 @@ CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions
 endif
 
 CFLAGS-flockfile.c = -D_IO_MTSAFE_IO
+CFLAGS-ftrylockfile.c = -D_IO_MTSAFE_IO
 CFLAGS-funlockfile.c = -D_IO_MTSAFE_IO
 
 ifeq ($(build-static),yes)
diff --git a/nptl/cleanup.c b/nptl/cleanup.c
index 6c7ba6187b..68c0f1d3d9 100644
--- a/nptl/cleanup.c
+++ b/nptl/cleanup.c
@@ -38,9 +38,6 @@ _pthread_cleanup_push (buffer, routine, arg)
 
   THREAD_SETMEM (self, cleanup, buffer);
 }
-extern void _GI_pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
-				      void (*routine) (void *), void *arg)
-     attribute_hidden;
 strong_alias (_pthread_cleanup_push, _GI_pthread_cleanup_push)
 
 
@@ -58,6 +55,4 @@ _pthread_cleanup_pop (buffer, execute)
   if (execute)
     buffer->__routine (buffer->__arg);
 }
-extern void _GI_pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
-				     int execute) attribute_hidden;
 strong_alias (_pthread_cleanup_pop, _GI_pthread_cleanup_pop)
diff --git a/nptl/ftrylockfile.c b/nptl/ftrylockfile.c
index 9ed010ddfc..2266b251b4 100644
--- a/nptl/ftrylockfile.c
+++ b/nptl/ftrylockfile.c
@@ -17,15 +17,16 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <errno.h>
 #include <pthread.h>
 #include <stdio.h>
-#include <libio.h>
+#include <bits/stdio-lock.h>
 
 
 int
 ftrylockfile (stream)
      FILE *stream;
 {
-  return pthread_mutex_trylock (stream->_lock);
+  return _IO_lock_trylock (*stream->_lock);
 }
 strong_alias (ftrylockfile, _IO_ftrylockfile)
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index c6c1e49a53..74243d1382 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -80,10 +80,10 @@ extern int __pthread_debug attribute_hidden;
 
 /* Set cancellation mode to asynchronous.  */
 #define CANCEL_ASYNC(oldtype) \
-  pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)
+  __pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)
 /* Reset to previous cancellation mode.  */
 #define CANCEL_RESET(oldtype) \
-  pthread_setcanceltype (oldtype, NULL)
+  __pthread_setcanceltype (oldtype, NULL)
 
 /* Function performing the cancellation.  */
 extern void __do_cancel (char *currentframe)
@@ -147,7 +147,9 @@ extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
 extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
 extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex);
 extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
+extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex);
 extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
 extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
 extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
@@ -179,7 +181,26 @@ extern void *__pthread_getspecific (pthread_key_t key);
 extern int __pthread_setspecific (pthread_key_t key, const void *value);
 extern int __pthread_once (pthread_once_t *once_control,
 			   void (*init_routine) (void));
+extern int __pthread_once_internal (pthread_once_t *once_control,
+				    void (*init_routine) (void));
 extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
 			     void (*child) (void));
+extern int __pthread_kill (pthread_t threadid, int signo);
+extern int __pthread_setcanceltype (int type, int *oldtype);
+
+/* Special versions which use non-exported functions.  */
+extern void _GI_pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
+				      void (*routine) (void *), void *arg)
+     attribute_hidden;
+#undef pthread_cleanup_push
+#define pthread_cleanup_push(routine,arg) \
+  { struct _pthread_cleanup_buffer _buffer;				      \
+    _GI_pthread_cleanup_push (&_buffer, (routine), (arg));
+
+extern void _GI_pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
+				     int execute) attribute_hidden;
+#undef pthread_cleanup_pop
+#define pthread_cleanup_pop(execute) \
+    _GI_pthread_cleanup_pop (&_buffer, (execute)); }
 
 #endif	/* pthreadP.h */
diff --git a/nptl/pthread_cancel.c b/nptl/pthread_cancel.c
index 1fa20e087c..a189b6eac9 100644
--- a/nptl/pthread_cancel.c
+++ b/nptl/pthread_cancel.c
@@ -46,7 +46,7 @@ pthread_cancel (th)
 	{
 	  /* The cancellation handler will take care of marking the
 	     thread as canceled.  */
-	  pthread_kill (th, SIGCANCEL);
+	  __pthread_kill (th, SIGCANCEL);
 
 	  break;
 	}
diff --git a/nptl/pthread_cond_timedwait.c b/nptl/pthread_cond_timedwait.c
index 826d16fb02..b88d11d224 100644
--- a/nptl/pthread_cond_timedwait.c
+++ b/nptl/pthread_cond_timedwait.c
@@ -40,7 +40,7 @@ pthread_cond_timedwait (cond, mutex, abstime)
   lll_mutex_lock (cond->__data.__lock);
 
   /* Release the mutex.  This might fail.  */
-  err = pthread_mutex_unlock (mutex);
+  err = INTUSE(__pthread_mutex_unlock) (mutex);
   if (__builtin_expect (err != 0, 0))
     {
       lll_mutex_unlock (cond->__data.__lock);
@@ -61,7 +61,7 @@ pthread_cond_timedwait (cond, mutex, abstime)
   lll_mutex_unlock (cond->__data.__lock);
 
   /* We have to get the mutex before returning.  */
-  err = pthread_mutex_lock (mutex);
+  err = INTUSE(__pthread_mutex_lock) (mutex);
   if (err != 0)
     /* XXX Unconditionally overwrite the result of the wait?  */
     result = err;
diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c
index 37c5ffe846..0e3e87fd61 100644
--- a/nptl/pthread_cond_wait.c
+++ b/nptl/pthread_cond_wait.c
@@ -36,7 +36,7 @@ pthread_cond_wait (cond, mutex)
   lll_mutex_lock (cond->__data.__lock);
 
   /* Release the mutex.  This might fail.  */
-  err = pthread_mutex_unlock (mutex);
+  err = INTUSE(__pthread_mutex_unlock) (mutex);
   if (__builtin_expect (err != 0, 0))
     {
       lll_mutex_unlock (cond->__data.__lock);
@@ -57,7 +57,7 @@ pthread_cond_wait (cond, mutex)
   lll_mutex_unlock (cond->__data.__lock);
 
   /* We have to get the mutex before returning.  */
-  err = pthread_mutex_lock (mutex);
+  err = INTUSE(__pthread_mutex_lock) (mutex);
 
   /* Cancellation handling.  */
   CANCELLATION_P (THREAD_SELF);
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 8398003d6d..991ef01ec7 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -75,3 +75,4 @@ __pthread_mutex_lock (mutex)
   return 0;
 }
 strong_alias (__pthread_mutex_lock, pthread_mutex_lock)
+INTDEF(__pthread_mutex_lock)
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index be510cb371..cd410e8f67 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -63,3 +63,4 @@ __pthread_mutex_unlock (mutex)
   return 0;
 }
 strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock)
+INTDEF(__pthread_mutex_unlock)
diff --git a/nptl/pthread_setcanceltype.c b/nptl/pthread_setcanceltype.c
index 8f84634888..63867d301b 100644
--- a/nptl/pthread_setcanceltype.c
+++ b/nptl/pthread_setcanceltype.c
@@ -23,7 +23,7 @@
 
 
 int
-pthread_setcanceltype (type, oldtype)
+__pthread_setcanceltype (type, oldtype)
      int type;
      int *oldtype;
 {
@@ -69,3 +69,4 @@ pthread_setcanceltype (type, oldtype)
 
   return 0;
 }
+strong_alias (__pthread_setcanceltype, pthread_setcanceltype)
diff --git a/nptl/sem_open.c b/nptl/sem_open.c
index 6fc72f7dc6..e8ef8f5f77 100644
--- a/nptl/sem_open.c
+++ b/nptl/sem_open.c
@@ -131,7 +131,7 @@ sem_open (const char *name, int oflag, ...)
   int fd;
 
   /* Determine where the shmfs is mounted.  */
-  pthread_once (&__namedsem_once, __where_is_shmfs);
+  INTUSE(__pthread_once) (&__namedsem_once, __where_is_shmfs);
 
   /* If we don't know the mount points there is nothing we can do.  Ever.  */
   if (mountpoint.dir == NULL)
@@ -160,7 +160,7 @@ sem_open (const char *name, int oflag, ...)
   /* If the semaphore object has to exist simply open it.  */
   if ((oflag & O_CREAT) == 0)
     {
-      fd = open (finalname, oflag | O_NOFOLLOW);
+      fd = __libc_open (finalname, oflag | O_NOFOLLOW);
 
       if (fd == -1)
 	/* Return.  errno is already set.  */
@@ -210,7 +210,7 @@ sem_open (const char *name, int oflag, ...)
       memset ((char *) &initsem + sizeof (struct sem), '\0',
 	      sizeof (sem_t) - sizeof (struct sem));
 
-      if (TEMP_FAILURE_RETRY (write (fd, &initsem, sizeof (sem_t)))
+      if (TEMP_FAILURE_RETRY (__libc_write (fd, &initsem, sizeof (sem_t)))
 	  != sizeof (sem_t)
 	  /* Adjust the permission.  */
 	  || fchmod (fd, mode) != 0)
@@ -252,7 +252,7 @@ sem_open (const char *name, int oflag, ...)
     }
 
   /* We don't need the file descriptor anymore.  */
-  close (fd);
+  __libc_close (fd);
 
   return result;
 }
diff --git a/nptl/sem_unlink.c b/nptl/sem_unlink.c
index b8e3de17d7..87440f6932 100644
--- a/nptl/sem_unlink.c
+++ b/nptl/sem_unlink.c
@@ -33,7 +33,7 @@ sem_unlink (name)
   size_t namelen;
 
   /* Determine where the shmfs is mounted.  */
-  pthread_once (&__namedsem_once, __where_is_shmfs);
+  INTDEF(__pthread_once) (&__namedsem_once, __where_is_shmfs);
 
   /* If we don't know the mount points there is nothing we can do.  Ever.  */
   if (mountpoint.dir == NULL)
diff --git a/nptl/sysdeps/pthread/bits/libc-lock.h b/nptl/sysdeps/pthread/bits/libc-lock.h
index 30e3410cbc..cb2154956b 100644
--- a/nptl/sysdeps/pthread/bits/libc-lock.h
+++ b/nptl/sysdeps/pthread/bits/libc-lock.h
@@ -1,4 +1,4 @@
-/* libc-internal interface for mutex locks.  LinuxThreads version.
+/* libc-internal interface for mutex locks.  NPTL version.
    Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -254,8 +254,8 @@ typedef pthread_key_t __libc_key_t;
 
 /* Try to lock the recursive named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
-# define __libc_lock_trylock_recursive(NAME)				      \
-  do {									      \
+# define __libc_lock_trylock_recursive(NAME) \
+  ({									      \
     int result = 0;							      \
     void *self = THREAD_SELF;						      \
     if ((NAME).owner != self)						      \
@@ -270,7 +270,8 @@ typedef pthread_key_t __libc_key_t;
       }									      \
     else								      \
       ++(NAME).cnt;							      \
-  } while (0)
+    result;								      \
+  })
 #else
 # define __libc_lock_trylock_recursive(NAME) \
   __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
diff --git a/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S b/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
index 747c8ec2d2..931e38bac3 100644
--- a/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
+++ b/nptl/sysdeps/unix/sysv/linux/i386/pthread_once.S
@@ -134,6 +134,9 @@ __pthread_once:
 
 	.size	__pthread_once,.-__pthread_once
 
+	.globl	__pthread_once_internal
+__pthread_once_internal = __pthread_once
+
 	.globl	pthread_once
 pthread_once = __pthread_once
 
diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
index f5c2377e7e..2c31dd667a 100644
--- a/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -25,7 +25,7 @@
 
 
 int
-pthread_kill (threadid, signo)
+__pthread_kill (threadid, signo)
      pthread_t threadid;
      int signo;
 {
@@ -34,3 +34,4 @@ pthread_kill (threadid, signo)
   /* We have a special syscall to do the work.  */
   return INLINE_SYSCALL (tkill, 2, pd->tid, signo);
 }
+strong_alias (__pthread_kill, pthread_kill)
diff --git a/sysdeps/generic/bits/stdio-lock.h b/sysdeps/generic/bits/stdio-lock.h
index 5b1c1b082e..b6eb98d921 100644
--- a/sysdeps/generic/bits/stdio-lock.h
+++ b/sysdeps/generic/bits/stdio-lock.h
@@ -1,5 +1,5 @@
 /* Thread package specific definitions of stream lock type.  Generic version.
-   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -34,6 +34,7 @@ __libc_lock_define_recursive (typedef, _IO_lock_t)
 #define _IO_lock_init(_name)	__libc_lock_init_recursive (_name)
 #define _IO_lock_fini(_name)	__libc_lock_fini_recursive (_name)
 #define _IO_lock_lock(_name)	__libc_lock_lock_recursive (_name)
+#define _IO_lock_trylock(_name)	__libc_lock_trylock_recursive (_name)
 #define _IO_lock_unlock(_name)	__libc_lock_unlock_recursive (_name)