add support for TLS variant I, presently needed for arm and mips
[musl] / src / thread / pthread_create.c
index 6327a94..e67616e 100644 (file)
@@ -130,7 +130,7 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attr,
                }
                tsd = map + size - __pthread_tsd_size;
        }
-       new = __copy_tls(tsd - libc.tls_size);
+       new = __copy_tls(stack = tsd - libc.tls_size);
        new->map_base = map;
        new->map_size = size;
        new->pid = self->pid;
@@ -145,10 +145,9 @@ int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attr,
        }
        new->unblock_cancel = self->cancel;
        new->canary = self->canary;
-       stack = (void *)new;
 
        a_inc(&libc.threads_minus_1);
-       ret = __clone(start, stack, flags, new, &new->tid, new, &new->tid);
+       ret = __clone(start, stack, flags, new, &new->tid, TP_ADJ(new), &new->tid);
 
        __release_ptc();