about summary refs log tree commit diff
path: root/nptl/pthread_mutex_trylock.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-02-16 10:57:38 +0000
committerUlrich Drepper <drepper@redhat.com>2003-02-16 10:57:38 +0000
commit0a37669aa5d98875e783df75681f035a905b7f31 (patch)
tree611caab21da3070beafe7c4739c2fae616321f04 /nptl/pthread_mutex_trylock.c
parent1564916ab9ef4e2ce673cd5fb3123c067e4a787d (diff)
downloadglibc-0a37669aa5d98875e783df75681f035a905b7f31.tar.gz
glibc-0a37669aa5d98875e783df75681f035a905b7f31.tar.xz
glibc-0a37669aa5d98875e783df75681f035a905b7f31.zip
Update.
	* tst-rwlock6.c: More pthread_rwlock_timedwrlock and
	pthread_rwlock_timedrdlock tests.
	* tst-rwlock7.c: More pthread_rwlock_timedwrlock tests.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedrdlock.S:
	Check for invalid tv_nsec field.
	* sysdeps/unix/sysv/linux/i386/i486/pthread_rwlock_timedwrlock.S:
	Likewise.

	* pthread_mutex_trylock.c (__pthread_mutex_trylock): Protect
	recursive mutex of overflow.

	* tst-attr1.c (do_test): Add test for pthread_mutexattr_setpshared.
Diffstat (limited to 'nptl/pthread_mutex_trylock.c')
-rw-r--r--nptl/pthread_mutex_trylock.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index aae506739f..394a9cba9b 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.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.
 
@@ -36,6 +36,10 @@ __pthread_mutex_trylock (mutex)
       if (mutex->__data.__owner == pd)
 	{
 	  /* Just bump the counter.  */
+	  if (__builtin_expect (mutex->__data.__count + 1 == 0, 0))
+	    /* Overflow of the counter.  */
+	    return EAGAIN;
+
 	  ++mutex->__data.__count;
 	  return 0;
 	}