repo.or.cz
/
dragonfly.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
kernel - Refactor struct vmstats and vm_zone
[dragonfly.git]
/
test
/
testcases
/
posixipc
/
trywait_unlocked
/
trywait_unlocked.c
blob
9c71dd64fd0af33feb5a5dde2cff11f01bb23f31
1
#include <common.h>
2
3
int
4
main
(
void
) {
5
sem_t id
;
6
7
if
(
sem_init
(&
id
,
0
,
1
) <
0
) {
8
perror
(
"sem_init"
);
9
return
1
;
10
}
11
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
;
17
}
18
if
(
checkvalue
(&
id
,
0
) <
0
) {
19
sem_destroy
(&
id
);
20
return
1
;
21
}
22
23
if
(
sem_destroy
(&
id
) <
0
) {
24
perror
(
"sem_destroy"
);
25
return
1
;
26
}
27
return
0
;
28
}