mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Fix some issues and do some code cleanup
This commit is contained in:
parent
1f229e4efc
commit
312ed5c67c
72 changed files with 880 additions and 982 deletions
|
@ -28,16 +28,18 @@
|
|||
void flockfile(FILE *f) {
|
||||
int me, owner;
|
||||
unsigned tries;
|
||||
if (!__threaded) return;
|
||||
for (tries = 0, me = gettid();;) {
|
||||
owner = 0;
|
||||
if (_lockcmpxchgp(&f->lock, &owner, me) || owner == me) {
|
||||
return;
|
||||
}
|
||||
if (++tries & 7) {
|
||||
__builtin_ia32_pause();
|
||||
} else {
|
||||
sched_yield();
|
||||
if (__threaded) {
|
||||
for (tries = 0, me = gettid();;) {
|
||||
owner = 0;
|
||||
if (_lockcmpxchgp(&f->lock, &owner, me) || owner == me) {
|
||||
break;
|
||||
}
|
||||
if (++tries & 7) {
|
||||
__builtin_ia32_pause();
|
||||
} else {
|
||||
sched_yield();
|
||||
}
|
||||
}
|
||||
}
|
||||
++f->reent;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue