diff options
Diffstat (limited to 'lib/libpthread/thread/thr_create.c')
-rw-r--r-- | lib/libpthread/thread/thr_create.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c index f7c95d0..8621c05 100644 --- a/lib/libpthread/thread/thr_create.c +++ b/lib/libpthread/thread/thr_create.c @@ -36,8 +36,9 @@ #include <string.h> #include <fcntl.h> #include <unistd.h> +#include <stddef.h> #include <sys/time.h> -#include <sys/types.h> +#include <sys/param.h> #include <sys/mman.h> #ifdef _THREAD_SAFE #include <machine/reg.h> @@ -45,6 +46,21 @@ #include "pthread_private.h" #include "libc_private.h" +static u_int64_t next_uniqueid = 1; + +#define OFF(f) offsetof(struct pthread, f) +int _thread_next_offset = OFF(tle.tqe_next); +int _thread_uniqueid_offset = OFF(uniqueid); +int _thread_state_offset = OFF(state); +int _thread_name_offset = OFF(name); +int _thread_sig_saved_offset = OFF(sig_saved); +int _thread_saved_sigcontext_offset = OFF(saved_sigcontext); +int _thread_saved_jmp_buf_offset = OFF(saved_jmp_buf); +#undef OFF + +int _thread_PS_RUNNING_value = PS_RUNNING; +int _thread_PS_DEAD_value = PS_DEAD; + int pthread_create(pthread_t * thread, const pthread_attr_t * attr, void *(*start_routine) (void *), void *arg) @@ -129,11 +145,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, else if (mmap(stack, PTHREAD_STACK_DEFAULT, PROT_READ | PROT_WRITE, -#ifdef __i386__ MAP_STACK, -#else - MAP_ANON, -#endif -1, 0) == MAP_FAILED) { ret = EAGAIN; munmap(_next_stack, @@ -268,6 +280,12 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr, _thread_kern_sig_defer(); /* + * Initialise the unique id which GDB uses to + * track threads. + */ + new_thread->uniqueid = next_uniqueid++; + + /* * Check if the garbage collector thread * needs to be started. */ |