mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-07 03:38:31 +00:00
Overhaul Windows signal handling
The new asynchronous signal delivery technique is now also being used for tkill(), raise(), etc. Many subtle issues have been addresesd. We now signal handling on Windows that's remarkably similar to the POSIX behaviors. However that's just across threads. We're lacking a way to have the signal semantics work well, across multiple WIN32 processes.
This commit is contained in:
parent
8bdaddd81d
commit
99dc1281f5
38 changed files with 635 additions and 279 deletions
18
libc/nt/kernel32/SetThreadContext.S
Normal file
18
libc/nt/kernel32/SetThreadContext.S
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "libc/nt/codegen.h"
|
||||
.imp kernel32,__imp_SetThreadContext,SetThreadContext
|
||||
|
||||
.text.windows
|
||||
.ftrace1
|
||||
SetThreadContext:
|
||||
.ftrace2
|
||||
#ifdef __x86_64__
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
mov __imp_SetThreadContext(%rip),%rax
|
||||
jmp __sysv2nt
|
||||
#elif defined(__aarch64__)
|
||||
mov x0,#0
|
||||
ret
|
||||
#endif
|
||||
.endfn SetThreadContext,globl
|
||||
.previous
|
|
@ -260,6 +260,7 @@ imp 'SetProcessWorkingSetSize' SetProcessWorkingSetSize kernel32 3
|
|||
imp 'SetProcessWorkingSetSizeEx' SetProcessWorkingSetSizeEx kernel32 4
|
||||
imp 'SetStdHandle' SetStdHandle kernel32 2
|
||||
imp 'SetThreadAffinityMask' SetThreadAffinityMask kernel32 2
|
||||
imp 'SetThreadContext' SetThreadContext kernel32 2
|
||||
imp 'SetThreadPriority' SetThreadPriority kernel32 2
|
||||
imp 'SetThreadPriorityBoost' SetThreadPriorityBoost kernel32 2
|
||||
imp 'SetUnhandledExceptionFilter' SetUnhandledExceptionFilter kernel32 1
|
||||
|
|
|
@ -53,7 +53,7 @@ struct NtContext {
|
|||
uint64_t LastBranchFromRip;
|
||||
uint64_t LastExceptionToRip;
|
||||
uint64_t LastExceptionFromRip;
|
||||
};
|
||||
} forcealign(16);
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_NT_STRUCT_CONTEXT_H_ */
|
||||
|
|
|
@ -64,6 +64,7 @@ void *TlsGetValue(uint32_t);
|
|||
uint32_t SuspendThread(int64_t hThread);
|
||||
uint32_t ResumeThread(int64_t hThread);
|
||||
bool32 GetThreadContext(int64_t hThread, struct NtContext *in_out_lpContext);
|
||||
bool32 SetThreadContext(int64_t hThread, const struct NtContext *lpContext);
|
||||
|
||||
#if ShouldUseMsabiAttribute()
|
||||
#include "libc/nt/thunk/thread.inc"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue