mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 15:28:30 +00:00
Implement signal handler tail recursion
GNU Make on Windows now appears to be working reliably. This change also fixes a bug where, after fork the Windows thread handle wasn't reset and that caused undefined behavior using SetThreadContext() with our signals
This commit is contained in:
parent
a657f3e878
commit
cdf556e7d2
15 changed files with 627 additions and 77 deletions
|
@ -27,6 +27,7 @@
|
|||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/files.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/nt/synchronization.h"
|
||||
#include "libc/nt/thread.h"
|
||||
|
@ -191,10 +192,11 @@ textstartup void __enable_tls(void) {
|
|||
tib->tib_locale = (intptr_t)&__c_dot_utf8_locale;
|
||||
tib->tib_pthread = (pthread_t)&_pthread_static;
|
||||
if (IsWindows()) {
|
||||
intptr_t threadhand, pseudo = GetCurrentThread();
|
||||
DuplicateHandle(GetCurrentProcess(), pseudo, GetCurrentProcess(),
|
||||
&threadhand, 0, true, kNtDuplicateSameAccess);
|
||||
atomic_store_explicit(&tib->tib_syshand, threadhand, memory_order_relaxed);
|
||||
intptr_t hThread;
|
||||
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
|
||||
GetCurrentProcess(), &hThread, 0, false,
|
||||
kNtDuplicateSameAccess);
|
||||
atomic_store_explicit(&tib->tib_syshand, hThread, memory_order_relaxed);
|
||||
} else if (IsXnuSilicon()) {
|
||||
tib->tib_syshand = __syslib->__pthread_self();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue