mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Make improvements
- Improved async signal safety of read() particularly for longjmp() - Started adding cancel cleanup handlers for locks / etc on Windows - Make /dev/tty work better particularly for uses like `foo | less` - Eagerly read console input into a linked list, so poll can signal - Fix some libc definitional bugs, which configure scripts detected
This commit is contained in:
parent
d6c2830850
commit
0c5dd7b342
85 changed files with 1062 additions and 671 deletions
|
@ -92,11 +92,7 @@ static void _pthread_cancel_sig(int sig, siginfo_t *si, void *arg) {
|
|||
|
||||
// punts cancellation to start of next cancellation point
|
||||
// we ensure sigthr is a pending signal in case unblocked
|
||||
if (IsXnuSilicon()) {
|
||||
__syslib->__pthread_kill(_pthread_syshand(pt), sig);
|
||||
} else {
|
||||
sys_tkill(_pthread_tid(pt), sig, __get_tls());
|
||||
}
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
static void _pthread_cancel_listen(void) {
|
||||
|
@ -111,10 +107,7 @@ static void _pthread_cancel_listen(void) {
|
|||
|
||||
static void pthread_cancel_nt(struct PosixThread *pt, intptr_t hThread) {
|
||||
uint32_t old_suspend_count;
|
||||
if (!(pt->pt_flags & PT_NOCANCEL) &&
|
||||
(pt->pt_flags & (PT_ASYNC | PT_MASKED))) {
|
||||
pt->pt_flags |= PT_NOCANCEL;
|
||||
pt->abort_errno = ECANCELED;
|
||||
if (!(pt->pt_flags & PT_NOCANCEL)) {
|
||||
if ((pt->pt_flags & PT_ASYNC) &&
|
||||
(old_suspend_count = SuspendThread(hThread)) != -1u) {
|
||||
if (!old_suspend_count) {
|
||||
|
@ -125,13 +118,13 @@ static void pthread_cancel_nt(struct PosixThread *pt, intptr_t hThread) {
|
|||
cpu.Rdi = (uintptr_t)PTHREAD_CANCELED;
|
||||
cpu.Rsp &= -16;
|
||||
*(uintptr_t *)(cpu.Rsp -= sizeof(uintptr_t)) = cpu.Rip;
|
||||
pt->abort_errno = ECANCELED;
|
||||
unassert(SetThreadContext(hThread, &cpu));
|
||||
}
|
||||
}
|
||||
ResumeThread(hThread);
|
||||
}
|
||||
__sig_cancel(pt);
|
||||
pt->abort_errno = ECANCELED;
|
||||
__sig_cancel(pt, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue