kernel - Refactor struct vmstats and vm_zone
[dragonfly.git] / test / testcases / posixipc / trywait_unlocked / trywait_unlocked.c
blob9c71dd64fd0af33feb5a5dde2cff11f01bb23f31
1 #include <common.h>
3 int
4 main(void) {
5 sem_t id;
7 if (sem_init(&id, 0, 1) < 0) {
8 perror("sem_init");
9 return 1;
12 /* This should succeed and decrement the value to 0. */
13 if (sem_trywait(&id) < 0) {
14 perror("sem_trywait()");
15 sem_destroy(&id);
16 return 1;
18 if (checkvalue(&id, 0) < 0) {
19 sem_destroy(&id);
20 return 1;
23 if (sem_destroy(&id) < 0) {
24 perror("sem_destroy");
25 return 1;
27 return 0;