LoongArch: Use "$fcsr0" instead of "$r0" in _FPU_{GET,SET}CW
[glibc.git] / sysdeps / pthread / tst-rwlock1.c
blob43866e17ca17f207471f05589035e6a8dbf8d6bf
1 /* Copyright (C) 2002-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
18 #include <pthread.h>
19 #include <stdio.h>
22 static int
23 do_test (void)
25 pthread_rwlock_t r;
27 if (pthread_rwlock_init (&r, NULL) != 0)
29 puts ("rwlock_init failed");
30 return 1;
32 puts ("rwlock_init succeeded");
34 if (pthread_rwlock_rdlock (&r) != 0)
36 puts ("1st rwlock_rdlock failed");
37 return 1;
39 puts ("1st rwlock_rdlock succeeded");
41 if (pthread_rwlock_rdlock (&r) != 0)
43 puts ("2nd rwlock_rdlock failed");
44 return 1;
46 puts ("2nd rwlock_rdlock succeeded");
48 if (pthread_rwlock_unlock (&r) != 0)
50 puts ("1st rwlock_unlock failed");
51 return 1;
53 puts ("1st rwlock_unlock succeeded");
55 if (pthread_rwlock_unlock (&r) != 0)
57 puts ("2nd rwlock_unlock failed");
58 return 1;
60 puts ("2nd rwlock_unlock succeeded");
62 if (pthread_rwlock_wrlock (&r) != 0)
64 puts ("1st rwlock_wrlock failed");
65 return 1;
67 puts ("1st rwlock_wrlock succeeded");
69 if (pthread_rwlock_unlock (&r) != 0)
71 puts ("3rd rwlock_unlock failed");
72 return 1;
74 puts ("3rd rwlock_unlock succeeded");
76 if (pthread_rwlock_wrlock (&r) != 0)
78 puts ("2nd rwlock_wrlock failed");
79 return 1;
81 puts ("2nd rwlock_wrlock succeeded");
83 if (pthread_rwlock_unlock (&r) != 0)
85 puts ("4th rwlock_unlock failed");
86 return 1;
88 puts ("4th rwlock_unlock succeeded");
90 if (pthread_rwlock_rdlock (&r) != 0)
92 puts ("3rd rwlock_rdlock failed");
93 return 1;
95 puts ("3rd rwlock_rdlock succeeded");
97 if (pthread_rwlock_unlock (&r) != 0)
99 puts ("5th rwlock_unlock failed");
100 return 1;
102 puts ("5th rwlock_unlock succeeded");
104 if (pthread_rwlock_destroy (&r) != 0)
106 puts ("rwlock_destroy failed");
107 return 1;
109 puts ("rwlock_destroy succeeded");
111 return 0;
114 #define TEST_FUNCTION do_test ()
115 #include "../test-skeleton.c"