mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-23 11:00:31 +00:00
Add back missing TlsAlloc() call
Cosmopolitan Libc once called this important function although somewhere along the way, possibly in a refactoring, it got removed and __tls_alloc has always been zero ever since.
This commit is contained in:
parent
e08a4cd99e
commit
5d2d9e9640
5 changed files with 12 additions and 9 deletions
|
@ -45,7 +45,7 @@ cosmo: push %rbp
|
|||
#endif /* SYSDEBUG */
|
||||
|
||||
#ifndef NOX87
|
||||
// Windows always initializes FPU to douuble precision.
|
||||
// Windows always initializes FPU to double precision.
|
||||
// WSL breaks Linux ABI by initializing FPU to double precision.
|
||||
// This code makes long double long again.
|
||||
//
|
||||
|
|
|
@ -251,6 +251,8 @@ textstartup void __enable_tls(void) {
|
|||
atomic_store_explicit(&_pthread_static.ptid, tid, memory_order_release);
|
||||
|
||||
// ask the operating system to change the x86 segment register
|
||||
if (IsWindows())
|
||||
__tls_index = TlsAlloc();
|
||||
__set_tls(tib);
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
|
|
@ -38,7 +38,7 @@ dontinstrument textstartup void __set_tls(struct CosmoTib *tib) {
|
|||
#ifdef __x86_64__
|
||||
// ask the operating system to change the x86 segment register
|
||||
if (IsWindows()) {
|
||||
asm("mov\t%1,%%gs:%0" : "=m"(*((long *)0x1480 + __tls_index)) : "r"(tib));
|
||||
__set_tls_win32(tib);
|
||||
} else if (IsLinux()) {
|
||||
sys_set_tls(ARCH_SET_GS, tib);
|
||||
} else if (IsFreebsd()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue