mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 11:18:30 +00:00
Use dynamic memory for *NSYNC waiters
This commit is contained in:
parent
15af5c2d7e
commit
241f949540
12 changed files with 171 additions and 72 deletions
10
libc/errno.h
10
libc/errno.h
|
@ -28,11 +28,11 @@ COSMOPOLITAN_C_START_
|
|||
/* this header is included by 700+ files; therefore we */
|
||||
/* hand-roll &__get_tls()->tib_errno to avoid #include */
|
||||
/* cosmopolitan uses x28 as the tls register b/c apple */
|
||||
#define errno \
|
||||
(*({ \
|
||||
errno_t *__ep; \
|
||||
asm("sub\t%0,x28,#68" : "=r"(__ep)); \
|
||||
__ep; \
|
||||
#define errno \
|
||||
(*({ \
|
||||
errno_t *__ep; \
|
||||
asm("sub\t%0,x28,#192-0x3c" : "=r"(__ep)); \
|
||||
__ep; \
|
||||
}))
|
||||
#else
|
||||
#define errno (*__errno_location())
|
||||
|
|
|
@ -67,7 +67,7 @@ __gc: .ftrace2
|
|||
|
||||
// if this code fails
|
||||
// check if CosmoTib's size changed
|
||||
sub x8,x28,#128 // __get_tls()
|
||||
sub x8,x28,#192 // __get_tls()
|
||||
ldr x9,[x8,0x18] // tib::garbages
|
||||
ldr x10,[x9] // g->i
|
||||
ldr x8,[x9,8] // g->p
|
||||
|
|
|
@ -112,7 +112,7 @@ vfork:
|
|||
// } else {
|
||||
// __get_tls()->tib_flags &= ~TIB_FLAG_VFORKED;
|
||||
// }
|
||||
sub x1,x28,#0x80 // RELIES ON TLS TIB ABI!
|
||||
sub x1,x28,#192 // sizeof(CosmoTib)
|
||||
ldr x2,[x1,64]
|
||||
cbnz x0,2f
|
||||
orr x2,x2,#TIB_FLAG_VFORKED
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "libc/thread/thread.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "third_party/nsync/futex.internal.h"
|
||||
#include "third_party/nsync/wait_s.internal.h"
|
||||
|
||||
void _pthread_unwind(struct PosixThread *pt) {
|
||||
struct _pthread_cleanup_buffer *cb;
|
||||
|
@ -115,6 +116,9 @@ wontreturn void pthread_exit(void *rc) {
|
|||
_weaken(__cxa_thread_finalize)();
|
||||
}
|
||||
_pthread_unkey(tib);
|
||||
if (tib->tib_nsync) {
|
||||
nsync_waiter_destroy(tib->tib_nsync);
|
||||
}
|
||||
_pthread_ungarbage();
|
||||
_pthread_decimate();
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ struct CosmoTib {
|
|||
uint32_t tib_sigstack_size;
|
||||
uint32_t tib_sigstack_flags;
|
||||
void **tib_keys;
|
||||
void *tib_nsync;
|
||||
void *tib_todo[63];
|
||||
};
|
||||
|
||||
extern int __threaded;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue