Fix pthread isystem reference

Fixes #489
This commit is contained in:
Justine Tunney 2022-07-15 18:46:11 -07:00
parent 13d67fed38
commit b4e38851ff
2 changed files with 16 additions and 4 deletions

View file

@ -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_ */

View file

@ -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);