summaryrefslogtreecommitdiffstats
path: root/lib/libkse
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1999-11-28 19:47:43 +0000
committerdfr <dfr@FreeBSD.org>1999-11-28 19:47:43 +0000
commit40f75646e17ad33162d267d29c837b01ad389a47 (patch)
treeda2392504b5f7efd06c32ded79d45f4199ad1384 /lib/libkse
parentd7156780d39bcfe9261d9a092c4b4fcbf122a73e (diff)
downloadFreeBSD-src-40f75646e17ad33162d267d29c837b01ad389a47.zip
FreeBSD-src-40f75646e17ad33162d267d29c837b01ad389a47.tar.gz
* Fix the stack allocation code so that it works for alpha. Change it
to use mmap(..., MAP_STACK, ...) on alpha too since that should work now. * Add hooks to allow GDB to access the internals of pthreads without having to know the exact layout of struct pthread. Reviewed by: deischen
Diffstat (limited to 'lib/libkse')
-rw-r--r--lib/libkse/thread/thr_create.c28
-rw-r--r--lib/libkse/thread/thr_private.h4
2 files changed, 26 insertions, 6 deletions
diff --git a/lib/libkse/thread/thr_create.c b/lib/libkse/thread/thr_create.c
index f7c95d0..8621c05 100644
--- a/lib/libkse/thread/thr_create.c
+++ b/lib/libkse/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.
*/
diff --git a/lib/libkse/thread/thr_private.h b/lib/libkse/thread/thr_private.h
index 0f27063..8bf8113 100644
--- a/lib/libkse/thread/thr_private.h
+++ b/lib/libkse/thread/thr_private.h
@@ -336,7 +336,8 @@ struct pthread_attr {
*/
#define PTHREAD_STACK_DEFAULT 65536
/* Size of red zone at the end of each stack. */
-#define PTHREAD_STACK_GUARD 4096
+#define PTHREAD_STACK_GUARD PAGE_SIZE
+
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since many applications are likely to run
@@ -466,6 +467,7 @@ struct pthread {
#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
u_int32_t magic;
char *name;
+ u_int64_t uniqueid; /* for gdb */
/*
* Lock for accesses to this thread structure.
OpenPOWER on IntegriCloud