mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-04-27 01:04:43 +00:00
- Fix bugs in kDos2Errno definition - malloc() should now be thread safe - Fix bug in rollup.com header generator - Fix open(O_APPEND) on the New Technology - Fix select() on the New Technology and test it - Work towards refactoring i/o for thread safety - Socket reads and writes on NT now poll for signals - Work towards i/o completion ports on the New Technology - Make read() and write() intermittently check for signals - Blinkenlights keyboard i/o so much better on NT w/ poll() - You can now poll() files and sockets at the same time on NT - Fix bug in appendr() that manifests with dlmalloc footers off
24 lines
1.2 KiB
C
24 lines
1.2 KiB
C
#ifndef COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_
|
|
#define COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 401 && \
|
|
!defined(__STRICT_ANSI__)
|
|
|
|
#define _spinlock(lock) \
|
|
do { \
|
|
for (;;) { \
|
|
typeof(*(lock)) x; \
|
|
__atomic_load(lock, &x, __ATOMIC_RELAXED); \
|
|
if (!x && !__sync_lock_test_and_set(lock, __ATOMIC_CONSUME)) { \
|
|
break; \
|
|
} else { \
|
|
__builtin_ia32_pause(); \
|
|
} \
|
|
} \
|
|
} while (0)
|
|
|
|
#define _spunlock(lock) __sync_lock_release(lock)
|
|
|
|
#endif /* GNU 4.1+ */
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_INTRIN_SPINLOCK_H_ */
|