1 /* Copyright (C) 2002-2014 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/>. */
28 if (pthread_rwlock_init (&r, NULL) != 0)
30 puts ("rwlock_init failed");
33 puts ("rwlock_init succeeded");
35 if (pthread_rwlock_rdlock (&r) != 0)
37 puts ("1st rwlock_rdlock failed");
40 puts ("1st rwlock_rdlock succeeded");
42 if (pthread_rwlock_rdlock (&r) != 0)
44 puts ("2nd rwlock_rdlock failed");
47 puts ("2nd rwlock_rdlock succeeded");
49 if (pthread_rwlock_unlock (&r) != 0)
51 puts ("1st rwlock_unlock failed");
54 puts ("1st rwlock_unlock succeeded");
56 if (pthread_rwlock_unlock (&r) != 0)
58 puts ("2nd rwlock_unlock failed");
61 puts ("2nd rwlock_unlock succeeded");
63 if (pthread_rwlock_wrlock (&r) != 0)
65 puts ("1st rwlock_wrlock failed");
68 puts ("1st rwlock_wrlock succeeded");
70 if (pthread_rwlock_unlock (&r) != 0)
72 puts ("3rd rwlock_unlock failed");
75 puts ("3rd rwlock_unlock succeeded");
77 if (pthread_rwlock_wrlock (&r) != 0)
79 puts ("2nd rwlock_wrlock failed");
82 puts ("2nd rwlock_wrlock succeeded");
84 if (pthread_rwlock_unlock (&r) != 0)
86 puts ("4th rwlock_unlock failed");
89 puts ("4th rwlock_unlock succeeded");
91 if (pthread_rwlock_rdlock (&r) != 0)
93 puts ("3rd rwlock_rdlock failed");
96 puts ("3rd rwlock_rdlock succeeded");
98 if (pthread_rwlock_unlock (&r) != 0)
100 puts ("5th rwlock_unlock failed");
103 puts ("5th rwlock_unlock succeeded");
105 if (pthread_rwlock_destroy (&r) != 0)
107 puts ("rwlock_destroy failed");
110 puts ("rwlock_destroy succeeded");
115 #define TEST_FUNCTION do_test ()
116 #include "../test-skeleton.c"