Add epoll and do more release readiness changes

This change also pays off some of the remaining technical debt with
stdio, file descriptors, and memory managemnt polyfills.
This commit is contained in:
Justine Tunney 2020-11-28 12:01:51 -08:00
parent a9ea949df8
commit 3e4fd4b0ad
271 changed files with 5706 additions and 1365 deletions

View file

@ -32,6 +32,21 @@ COSMOPOLITAN_C_START_
cosmopolitan § new technology » synchronization
*/
#define InterlockedAdd(PTR, VAL) \
({ \
typeof(*(PTR)) Res; \
typeof(Res) Val = (VAL); \
asm volatile("xadd\t%0,%1" : "=r"(Res), "+m"(*(PTR)) : "0"(Val)); \
Res + Val; \
})
#define InterlockedExchange(PTR, VAL) \
({ \
typeof(*(PTR)) Res = (VAL); \
asm volatile("xchg\t%0,%1" : "+r"(Res), "+m"(*(PTR))); \
Res; \
})
typedef void (*NtTimerapcroutine)(void *lpArgToCompletionRoutine,
uint32_t dwTimerLowValue,
uint32_t dwTimerHighValue);
@ -78,6 +93,16 @@ int32_t InitializeCriticalSectionAndSpinCount(
uint32_t SetCriticalSectionSpinCount(
struct NtCriticalSection *lpCriticalSection, uint32_t dwSpinCount);
void InitializeSRWLock(intptr_t *);
void AcquireSRWLockExclusive(intptr_t *);
void AcquireSRWLockShared(intptr_t *);
void ReleaseSRWLockExclusive(intptr_t *);
void ReleaseSRWLockShared(intptr_t *);
void TryAcquireSRWLockExclusive(intptr_t *);
void TryAcquireSRWLockShared(intptr_t *);
uint64_t GetTickCount64(void);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_NT_SYNCHRONIZATION_H_ */