mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Always initialize thread local storage
We had previously not enabled TLS in MODE=tiny in order to keep the smallest example programs (e.g. life.com) just 16kb in size. But it was error prone doing that, so now we just always enable it because this change uses hacks to ensure it won't increase life.com's size. This change also fixes a bug on NetBSD, where signal handlers would break thread local storage if SA_SIGINFO was being used. This looks like it might be a bug in NetBSD, but it's got a simple workaround.
This commit is contained in:
parent
057e8f5b54
commit
69f4152f38
33 changed files with 174 additions and 123 deletions
5
third_party/dlmalloc/locks.inc
vendored
5
third_party/dlmalloc/locks.inc
vendored
|
@ -1,4 +1,5 @@
|
|||
// clang-format off
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/nexgen32e/threaded.h"
|
||||
|
||||
/* --------------------------- Lock preliminaries ------------------------ */
|
||||
|
@ -94,7 +95,7 @@ FORCEINLINE void x86_clear_lock(int* sl) {
|
|||
/* Plain spin locks use single word (embedded in malloc_states) */
|
||||
static dontinline int spin_acquire_lock(int *sl) {
|
||||
while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) {
|
||||
__builtin_ia32_pause();
|
||||
sched_yield();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) {
|
|||
++lk->c;
|
||||
return 0;
|
||||
}
|
||||
__builtin_ia32_pause();
|
||||
sched_yield();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue