mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-01 16:58:30 +00:00
Make improvements
- Document redbean's argon2 module - Fix regressions in cthreads library - Make testlib work better with threads - Give the cthreads library lots of love - Remove some of the stdio assembly code - Implement getloadavg() across platforms - Code size optimizations for errnos, etc. - Only check for signals in main thread on Windows - Make errnos for dup2 / dup3 consistent with posix This change also fixes a bug in the argon2 module, where the NUL terminator was being included in the hash encoded ascii string. This shouldn't require any database migrations to folks who found this module and productionized it, since the argon2 library treats it as a c string.
This commit is contained in:
parent
cb67223051
commit
de5de19004
234 changed files with 1728 additions and 1993 deletions
|
@ -29,35 +29,13 @@
|
|||
#include "libc/intrin/lockcmpxchgp.h"
|
||||
#include "libc/nexgen32e/threaded.h"
|
||||
|
||||
_Alignas(64) static int rlock;
|
||||
|
||||
// return 0 on success, or tid of other owner
|
||||
static privileged inline int AcquireInterruptPollLock(void) {
|
||||
// any thread can poll for interrupts
|
||||
// but it's wasteful to have every single thread doing it
|
||||
int me, owner = 0;
|
||||
if (__threaded) {
|
||||
me = gettid();
|
||||
if (!_lockcmpxchgp(&rlock, &owner, me) && owner == me) {
|
||||
owner = 0;
|
||||
}
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
|
||||
static textwindows inline void ReleaseInterruptPollLock(void) {
|
||||
int zero = 0;
|
||||
__atomic_store(&rlock, &zero, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
textwindows bool _check_interrupts(bool restartable, struct Fd *fd) {
|
||||
bool res;
|
||||
if (__time_critical) return false;
|
||||
if (AcquireInterruptPollLock()) return false;
|
||||
if (__threaded && __threaded != gettid()) return false;
|
||||
if (weaken(_check_sigalrm)) weaken(_check_sigalrm)();
|
||||
if (weaken(_check_sigchld)) weaken(_check_sigchld)();
|
||||
if (fd && weaken(_check_sigwinch)) weaken(_check_sigwinch)(fd);
|
||||
res = weaken(__sig_check) && weaken(__sig_check)(restartable);
|
||||
ReleaseInterruptPollLock();
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue