From b4e38851fff03be67ba0f53b07d88dc768c220df Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Fri, 15 Jul 2022 18:46:11 -0700 Subject: [PATCH] Fix pthread isystem reference Fixes #489 --- libc/isystem/pthread.h | 2 +- libc/thread/spawn.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libc/isystem/pthread.h b/libc/isystem/pthread.h index 0285ea61d..15164ec4d 100644 --- a/libc/isystem/pthread.h +++ b/libc/isystem/pthread.h @@ -1,4 +1,4 @@ #ifndef LIBC_ISYSTEM_PTHREAD_H_ #define LIBC_ISYSTEM_PTHREAD_H_ -#include "libc/runtime/pthread.h" +#include "libc/intrin/pthread.h" #endif /* LIBC_ISYSTEM_PTHREAD_H_ */ diff --git a/libc/thread/spawn.c b/libc/thread/spawn.c index e7a27882a..57a87fd97 100644 --- a/libc/thread/spawn.c +++ b/libc/thread/spawn.c @@ -56,7 +56,19 @@ STATIC_YOINK("_main_thread_ctor"); #define _MEMZ ROUNDUP(_TLSZ + _TIBZ, alignof(struct cthread_descriptor_t)) /** - * Spawns thread. + * Spawns thread, e.g. + * + * int worker(void *arg, int tid) { + * const char *s = arg; + * printf("%s\n", s); + * return 0; + * } + * + * int main() { + * struct spawn th; + * _spawn(worker, "hi", &th); + * _join(&th); + * } * * @param fun is thread worker callback, which receives `arg` and `ctid` * @param arg shall be passed to `fun` @@ -77,14 +89,14 @@ int _spawn(int fun(void *, int), void *arg, struct spawn *opt_out_thread) { th = &ths; } - // Allocate enough TLS memory for all the GNU Linuker (_tls_size) + // allocate enough TLS memory for all the GNU Linuker (_tls_size) // organized _Thread_local data, as well as Cosmpolitan Libc (64) if (!(th->tls = _mktls(&th->tib))) { return -1; } th->ctid = (int *)(th->tib + 0x38); - // We must use _mapstack() to allocate the stack because OpenBSD has + // we must use _mapstack() to allocate the stack because OpenBSD has // very strict requirements for what's allowed to be used for stacks if (!(th->stk = _mapstack())) { free(th->tls);