repo.or.cz
/
musl.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
release 1.1.24
[musl.git]
/
src
/
thread
/
vmlock.c
blob
75f3cb76190fe4e8796997e7c3d29af80fb36792
1
#include
"pthread_impl.h"
2
3
static
volatile
int
vmlock
[
2
];
4
5
void
__vm_wait
()
6
{
7
int
tmp
;
8
while
((
tmp
=
vmlock
[
0
]))
9
__wait
(
vmlock
,
vmlock
+
1
,
tmp
,
1
);
10
}
11
12
void
__vm_lock
()
13
{
14
a_inc
(
vmlock
);
15
}
16
17
void
__vm_unlock
()
18
{
19
if
(
a_fetch_add
(
vmlock
, -
1
)==
1
&&
vmlock
[
1
])
20
__wake
(
vmlock
, -
1
,
1
);
21
}