1 /* Copyright (C) 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
30 if (pthread_rwlock_init (&r, NULL) != 0)
32 puts ("rwlock_init failed");
35 puts ("rwlock_init succeeded");
37 if (pthread_rwlock_wrlock (&r) != 0)
39 puts ("1st rwlock_wrlock failed");
42 puts ("1st rwlock_wrlock succeeded");
44 e = pthread_rwlock_tryrdlock (&r);
47 puts ("rwlock_tryrdlock on rwlock with writer succeeded");
52 puts ("rwlock_tryrdlock on rwlock with writer return value != EBUSY");
55 puts ("rwlock_tryrdlock on rwlock with writer failed with EBUSY");
57 e = pthread_rwlock_trywrlock (&r);
60 puts ("rwlock_trywrlock on rwlock with writer succeeded");
65 puts ("rwlock_trywrlock on rwlock with writer return value != EBUSY");
68 puts ("rwlock_trywrlock on rwlock with writer failed with EBUSY");
70 if (pthread_rwlock_unlock (&r) != 0)
72 puts ("1st rwlock_unlock failed");
75 puts ("1st rwlock_unlock succeeded");
77 if (pthread_rwlock_tryrdlock (&r) != 0)
79 puts ("rwlock_tryrdlock on unlocked rwlock failed");
82 puts ("rwlock_tryrdlock on unlocked rwlock succeeded");
84 e = pthread_rwlock_trywrlock (&r);
87 puts ("rwlock_trywrlock on rwlock with reader succeeded");
92 puts ("rwlock_trywrlock on rwlock with reader return value != EBUSY");
95 puts ("rwlock_trywrlock on rwlock with reader failed with EBUSY");
97 if (pthread_rwlock_unlock (&r) != 0)
99 puts ("2nd rwlock_unlock failed");
102 puts ("2nd rwlock_unlock succeeded");
104 if (pthread_rwlock_trywrlock (&r) != 0)
106 puts ("rwlock_trywrlock on unlocked rwlock failed");
109 puts ("rwlock_trywrlock on unlocked rwlock succeeded");
111 e = pthread_rwlock_tryrdlock (&r);
114 puts ("rwlock_tryrdlock on rwlock with writer succeeded");
119 puts ("rwlock_tryrdlock on rwlock with writer return value != EBUSY");
122 puts ("rwlock_tryrdlock on rwlock with writer failed with EBUSY");
124 if (pthread_rwlock_unlock (&r) != 0)
126 puts ("3rd rwlock_unlock failed");
129 puts ("3rd rwlock_unlock succeeded");
131 if (pthread_rwlock_destroy (&r) != 0)
133 puts ("rwlock_destroy failed");
136 puts ("rwlock_destroy succeeded");
141 #define TEST_FUNCTION do_test ()
142 #include "../test-skeleton.c"