Remove unused localedata/th_TH.in
[glibc.git] / sysdeps / pthread / tst-sem1.c
blob0dda8e8b2d59c24b0eaa5b57fd4f5788fe57e253
1 /* Copyright (C) 2002-2023 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 <errno.h>
19 #include <semaphore.h>
20 #include <stdio.h>
21 #include <unistd.h>
24 static int
25 do_test (void)
27 sem_t s;
29 if (sem_init (&s, 0, 1) == -1)
31 puts ("init failed");
32 return 1;
35 if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
37 puts ("1st wait failed");
38 return 1;
41 if (sem_post (&s) == -1)
43 puts ("1st post failed");
44 return 1;
47 if (TEMP_FAILURE_RETRY (sem_trywait (&s)) == -1)
49 puts ("1st trywait failed");
50 return 1;
53 errno = 0;
54 if (TEMP_FAILURE_RETRY (sem_trywait (&s)) != -1)
56 puts ("2nd trywait succeeded");
57 return 1;
59 else if (errno != EAGAIN)
61 puts ("2nd trywait did not set errno to EAGAIN");
62 return 1;
65 if (sem_post (&s) == -1)
67 puts ("2nd post failed");
68 return 1;
71 if (TEMP_FAILURE_RETRY (sem_wait (&s)) == -1)
73 puts ("2nd wait failed");
74 return 1;
77 if (sem_destroy (&s) == -1)
79 puts ("destroy failed");
80 return 1;
83 return 0;
86 #define TEST_FUNCTION do_test ()
87 #include "../test-skeleton.c"