mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Add atomics to chibicc
This change also fixes #434 and makes the chibicc assembler better.
This commit is contained in:
parent
5ddf43332e
commit
a988896048
21 changed files with 650 additions and 445 deletions
|
@ -1,20 +1,10 @@
|
|||
#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"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#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)
|
||||
void _wait0(int *) hidden;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_INTRIN_WAIT0_H_ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue