diff options
Diffstat (limited to 'libc/bionic/pthread_create.cpp')
-rw-r--r-- | libc/bionic/pthread_create.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp index c4cb262ac..2ded22b0f 100644 --- a/libc/bionic/pthread_create.cpp +++ b/libc/bionic/pthread_create.cpp @@ -30,9 +30,11 @@ #include <errno.h> #include <sys/mman.h> +#include <unistd.h> #include "pthread_internal.h" +#include "private/bionic_macros.h" #include "private/bionic_ssp.h" #include "private/bionic_tls.h" #include "private/libc_logging.h" @@ -183,8 +185,8 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr, } // Make sure the stack size and guard size are multiples of PAGE_SIZE. - thread->attr.stack_size = (thread->attr.stack_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); - thread->attr.guard_size = (thread->attr.guard_size + (PAGE_SIZE-1)) & ~(PAGE_SIZE-1); + thread->attr.stack_size = BIONIC_ALIGN(thread->attr.stack_size, PAGE_SIZE); + thread->attr.guard_size = BIONIC_ALIGN(thread->attr.guard_size, PAGE_SIZE); if (thread->attr.stack_base == NULL) { // The caller didn't provide a stack, so allocate one. @@ -219,6 +221,8 @@ int pthread_create(pthread_t* thread_out, pthread_attr_t const* attr, thread->start_routine = start_routine; thread->start_routine_arg = arg; + thread->set_cached_pid(getpid()); + int flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID; void* tls = thread->tls; |