aboutsummaryrefslogtreecommitdiff
path: root/nptl/tst-rwlock6.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/tst-rwlock6.c
parent1564916ab9ef4e2ce673cd5fb3123c067e4a787d (diff)
downloadglibc-0a37669aa5d98875e783df75681f035a905b7f31.zip
glibc-0a37669aa5d98875e783df75681f035a905b7f31.tar.gz
glibc-0a37669aa5d98875e783df75681f035a905b7f31.tar.bz2
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/tst-rwlock6.c')
-rw-r--r--nptl/tst-rwlock6.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/nptl/tst-rwlock6.c b/nptl/tst-rwlock6.c
index f0a96e8..ea7f4ba 100644
--- a/nptl/tst-rwlock6.c
+++ b/nptl/tst-rwlock6.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.
@@ -76,6 +76,24 @@ tf (void *arg)
pthread_exit ((void *) 1l);
}
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ts.tv_sec += 10;
+ /* Note that the following operation makes ts invalid. */
+ ts.tv_nsec += 1000000000;
+
+ err = pthread_rwlock_timedrdlock (r, &ts);
+ if (err == 0)
+ {
+ puts ("2nd timedrdlock succeeded");
+ pthread_exit ((void *) 1l);
+ }
+ if (err != EINVAL)
+ {
+ puts ("2nd timedrdlock did not return EINVAL");
+ pthread_exit ((void *) 1l);
+ }
+
return NULL;
}
@@ -128,6 +146,36 @@ do_test (void)
exit (1);
}
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ++ts.tv_sec;
+ int e = pthread_rwlock_timedrdlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("timedrdlock succeeded");
+ exit (1);
+ }
+ if (e != EDEADLK)
+ {
+ puts ("timedrdlock did not return EDEADLK");
+ exit (1);
+ }
+
+ (void) gettimeofday (&tv, NULL);
+ TIMEVAL_TO_TIMESPEC (&tv, &ts);
+ ++ts.tv_sec;
+ e = pthread_rwlock_timedwrlock (&r, &ts);
+ if (e == 0)
+ {
+ puts ("2nd timedwrlock succeeded");
+ exit (1);
+ }
+ if (e != EDEADLK)
+ {
+ puts ("2nd timedwrlock did not return EDEADLK");
+ exit (1);
+ }
+
pthread_t th;
if (pthread_create (&th, NULL, tf, &r) != 0)
{