]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/test/nptl/tst-rwlock1.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / test / nptl / tst-rwlock1.c
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.
4
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.
9
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.
14
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/>.  */
18
19 #include <pthread.h>
20 #include <stdio.h>
21
22
23 static int
24 do_test (void)
25 {
26   pthread_rwlock_t r;
27
28   if (pthread_rwlock_init (&r, NULL) != 0)
29     {
30       puts ("rwlock_init failed");
31       return 1;
32     }
33   puts ("rwlock_init succeeded");
34
35   if (pthread_rwlock_rdlock (&r) != 0)
36     {
37       puts ("1st rwlock_rdlock failed");
38       return 1;
39     }
40   puts ("1st rwlock_rdlock succeeded");
41
42   if (pthread_rwlock_rdlock (&r) != 0)
43     {
44       puts ("2nd rwlock_rdlock failed");
45       return 1;
46     }
47   puts ("2nd rwlock_rdlock succeeded");
48
49   if (pthread_rwlock_unlock (&r) != 0)
50     {
51       puts ("1st rwlock_unlock failed");
52       return 1;
53     }
54   puts ("1st rwlock_unlock succeeded");
55
56   if (pthread_rwlock_unlock (&r) != 0)
57     {
58       puts ("2nd rwlock_unlock failed");
59       return 1;
60     }
61   puts ("2nd rwlock_unlock succeeded");
62
63   if (pthread_rwlock_wrlock (&r) != 0)
64     {
65       puts ("1st rwlock_wrlock failed");
66       return 1;
67     }
68   puts ("1st rwlock_wrlock succeeded");
69
70   if (pthread_rwlock_unlock (&r) != 0)
71     {
72       puts ("3rd rwlock_unlock failed");
73       return 1;
74     }
75   puts ("3rd rwlock_unlock succeeded");
76
77   if (pthread_rwlock_wrlock (&r) != 0)
78     {
79       puts ("2nd rwlock_wrlock failed");
80       return 1;
81     }
82   puts ("2nd rwlock_wrlock succeeded");
83
84   if (pthread_rwlock_unlock (&r) != 0)
85     {
86       puts ("4th rwlock_unlock failed");
87       return 1;
88     }
89   puts ("4th rwlock_unlock succeeded");
90
91   if (pthread_rwlock_rdlock (&r) != 0)
92     {
93       puts ("3rd rwlock_rdlock failed");
94       return 1;
95     }
96   puts ("3rd rwlock_rdlock succeeded");
97
98   if (pthread_rwlock_unlock (&r) != 0)
99     {
100       puts ("5th rwlock_unlock failed");
101       return 1;
102     }
103   puts ("5th rwlock_unlock succeeded");
104
105   if (pthread_rwlock_destroy (&r) != 0)
106     {
107       puts ("rwlock_destroy failed");
108       return 1;
109     }
110   puts ("rwlock_destroy succeeded");
111
112   return 0;
113 }
114
115 #define TEST_FUNCTION do_test ()
116 #include "../test-skeleton.c"