mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Write more tests for signal handling
There's now a much stronger level of assurance that signaling on Windows will be atomic, low-latency, low tail latency, and shall never deadlock.
This commit is contained in:
parent
0e59afb403
commit
dd8c4dbd7d
19 changed files with 407 additions and 75 deletions
|
@ -18,7 +18,8 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/internal.h"
|
||||
|
||||
__msabi textwindows char16_t *__itoa16(char16_t p[21], uint64_t x) {
|
||||
__msabi textwindows dontinstrument char16_t *__itoa16(char16_t p[21],
|
||||
uint64_t x) {
|
||||
char t;
|
||||
size_t a, b, i = 0;
|
||||
do {
|
||||
|
|
|
@ -44,9 +44,8 @@ void __sig_unblock(sigset_t m) {
|
|||
if (IsWindows() || IsMetal()) {
|
||||
if (__tls_enabled) {
|
||||
atomic_store_explicit(&__get_tls()->tib_sigmask, m, memory_order_release);
|
||||
if (_weaken(__sig_check)) {
|
||||
if (_weaken(__sig_check))
|
||||
_weaken(__sig_check)();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sys_sigprocmask(SIG_SETMASK, &m, 0);
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "libc/nt/enum/pageflags.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/memory.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/thunk/msabi.h"
|
||||
#ifdef __x86_64__
|
||||
|
@ -42,11 +43,16 @@ __msabi extern typeof(CreateFileMapping) *const __imp_CreateFileMappingW;
|
|||
__msabi extern typeof(MapViewOfFileEx) *const __imp_MapViewOfFileEx;
|
||||
__msabi extern typeof(SetEndOfFile) *const __imp_SetEndOfFile;
|
||||
__msabi extern typeof(SetFilePointer) *const __imp_SetFilePointer;
|
||||
__msabi extern typeof(GetEnvironmentVariable)
|
||||
*const __imp_GetEnvironmentVariableW;
|
||||
|
||||
__msabi textwindows char16_t *__sig_process_path(char16_t *path, uint32_t pid,
|
||||
int create_directories) {
|
||||
// Generates C:\ProgramData\cosmo\sig\x\y.pid like path
|
||||
__msabi textwindows dontinstrument char16_t *__sig_process_path(
|
||||
char16_t *path, uint32_t pid, int create_directories) {
|
||||
char16_t buf[3];
|
||||
char16_t *p = path;
|
||||
*p++ = 'C'; // C:\ProgramData\cosmo\sig\x\y.pid
|
||||
uint32_t vlen = __imp_GetEnvironmentVariableW(u"SYSTEMDRIVE", buf, 3);
|
||||
*p++ = vlen == 2 ? buf[0] : 'C';
|
||||
*p++ = ':';
|
||||
*p++ = '\\';
|
||||
*p++ = 'P';
|
||||
|
|
|
@ -47,6 +47,9 @@ textwindows int __sig_mask(int how, const sigset_t *neu, sigset_t *old) {
|
|||
} else { // SIG_SETMASK
|
||||
oldmask = atomic_exchange_explicit(mask, *neu, memory_order_acq_rel);
|
||||
}
|
||||
if (_weaken(__sig_check)) {
|
||||
_weaken(__sig_check)();
|
||||
}
|
||||
} else {
|
||||
oldmask = atomic_load_explicit(mask, memory_order_acquire);
|
||||
}
|
||||
|
@ -56,10 +59,6 @@ textwindows int __sig_mask(int how, const sigset_t *neu, sigset_t *old) {
|
|||
*old = oldmask;
|
||||
}
|
||||
|
||||
if (_weaken(__sig_check)) {
|
||||
_weaken(__sig_check)();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue