mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-02 17:28:30 +00:00
Write some lock contention tests
This commit is contained in:
parent
42c38bc3e3
commit
c06ffd458c
19 changed files with 205 additions and 76 deletions
20
libc/intrin/wait0.internal.h
Normal file
20
libc/intrin/wait0.internal.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_
|
||||
#define COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_
|
||||
#include "libc/bits/atomic.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/linux/futex.h"
|
||||
|
||||
#define _wait0(ptid) \
|
||||
do { \
|
||||
int x; \
|
||||
if (!(x = atomic_load_explicit(ptid, memory_order_relaxed))) { \
|
||||
break; \
|
||||
} else if (IsLinux()) { \
|
||||
LinuxFutexWait(ptid, x, 0); \
|
||||
} else { \
|
||||
sched_yield(); \
|
||||
} \
|
||||
} while (1)
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue