Do more quality assurance work

This commit is contained in:
Justine Tunney 2024-06-24 06:53:49 -07:00
parent 67b19ae733
commit d461c6f47d
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
31 changed files with 194 additions and 108 deletions

View file

@ -32,6 +32,16 @@ struct Dtor {
static _Thread_local struct Dtor *__cxa_thread_atexit_list;
static void _pthread_unwind(struct CosmoTib *tib) {
struct PosixThread *pt;
struct _pthread_cleanup_buffer *cb;
pt = (struct PosixThread *)tib->tib_pthread;
while ((cb = pt->pt_cleanup)) {
pt->pt_cleanup = cb->__prev;
cb->__routine(cb->__arg);
}
}
static void __cxa_thread_unkey(struct CosmoTib *tib) {
void *val;
int i, j, gotsome;
@ -67,16 +77,18 @@ static void _pthread_ungarbage(struct CosmoTib *tib) {
void __cxa_thread_finalize(void) {
struct Dtor *dtor;
struct CosmoTib *tib;
tib = __get_tls();
_pthread_unwind(tib);
if (tib->tib_nsync)
_weaken(nsync_waiter_destroy)(tib->tib_nsync);
__cxa_thread_unkey(tib);
_pthread_ungarbage(tib);
while ((dtor = __cxa_thread_atexit_list)) {
__cxa_thread_atexit_list = dtor->next;
((void (*)(void *))dtor->fun)(dtor->arg);
_weaken(free)(dtor);
}
struct CosmoTib *tib = __get_tls();
__cxa_thread_unkey(tib);
if (tib->tib_nsync)
_weaken(nsync_waiter_destroy)(tib->tib_nsync);
_pthread_ungarbage(tib);
}
int __cxa_thread_atexit_impl(void *fun, void *arg, void *dso_symbol) {

View file

@ -44,7 +44,7 @@
*/
void *NewCosmoStack(void) {
char *p;
size_t n = GetStackSize() + (uintptr_t)ape_stack_align;
size_t n = GetStackSize();
if ((p = mmap(0, n, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1,
0)) != MAP_FAILED) {
if (IsOpenbsd() && __sys_mmap(p, n, PROT_READ | PROT_WRITE,

View file

@ -14,9 +14,6 @@
*/
#define GetGuardSize() 16384
#define STATIC_STACK_ALIGN(BYTES) \
_STACK_SYMBOL("ape_stack_align", _STACK_STRINGIFY(BYTES) _STACK_EXTRA)
/**
* Makes program stack executable if declared, e.g.
*
@ -50,8 +47,6 @@ COSMOPOLITAN_C_START_
extern char ape_stack_prot[] __attribute__((__weak__));
extern char ape_stack_memsz[] __attribute__((__weak__));
extern char ape_stack_align[] __attribute__((__weak__));
extern char ape_stack_round[] __attribute__((__weak__));
uintptr_t GetStackBottom(void) pureconst;

View file

@ -212,6 +212,8 @@ static abi wontreturn void WinInit(const char16_t *cmdline) {
__maps.stack.size = stacksize;
__maps.stack.prot = prot;
__maps.maps = &__maps.stack;
__maps.pages = (stacksize + 4095) / 4096;
__maps.count = 1;
dll_init(&__maps.stack.elem);
dll_make_first(&__maps.used, &__maps.stack.elem);
struct WinArgs *wa =