aboutsummaryrefslogtreecommitdiff
path: root/lib/libc_r
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2003-12-03 06:54:40 +0000
committerPeter Wemm <peter@FreeBSD.org>2003-12-03 06:54:40 +0000
commit29f2f145e45538c397bdfac2bc830bb25196101c (patch)
treedd4cb5a18a26bf30a1c6df35e18a237dba59bd22 /lib/libc_r
parent20109fa0460db86326bf66c24acb154b8de3941b (diff)
Notes
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/uthread_create.c11
-rw-r--r--lib/libc_r/uthread/uthread_init.c10
-rw-r--r--lib/libc_r/uthread/uthread_sig.c12
3 files changed, 27 insertions, 6 deletions
diff --git a/lib/libc_r/uthread/uthread_create.c b/lib/libc_r/uthread/uthread_create.c
index 2ea87b297cdd..356bc07f0264 100644
--- a/lib/libc_r/uthread/uthread_create.c
+++ b/lib/libc_r/uthread/uthread_create.c
@@ -73,6 +73,9 @@ _pthread_create(pthread_t *thread, const pthread_attr_t *attr,
pthread_t new_thread;
pthread_attr_t pattr;
void *stack;
+#if !defined(__ia64__)
+ u_long stackp;
+#endif
if (thread == NULL)
return(EINVAL);
@@ -145,10 +148,12 @@ _pthread_create(pthread_t *thread, const pthread_attr_t *attr,
SET_RETURN_ADDR_JB(new_thread->ctx.jb, _thread_start);
#if !defined(__ia64__)
+ stackp = (long)new_thread->stack + pattr->stacksize_attr - sizeof(double);
+#if defined(__amd64__)
+ stackp &= ~0xFUL;
+#endif
/* The stack starts high and builds down: */
- SET_STACK_JB(new_thread->ctx.jb,
- (long)new_thread->stack + pattr->stacksize_attr
- - sizeof(double));
+ SET_STACK_JB(new_thread->ctx.jb, stackp);
#else
SET_STACK_JB(new_thread->ctx.jb,
(long)new_thread->stack, pattr->stacksize_attr);
diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c
index 5367d0ba087f..d3a2b45617d4 100644
--- a/lib/libc_r/uthread/uthread_init.c
+++ b/lib/libc_r/uthread/uthread_init.c
@@ -208,6 +208,9 @@ _thread_init(void)
size_t len;
int mib[2];
int sched_stack_size; /* Size of scheduler stack. */
+#if !defined(__ia64__)
+ u_long stackp;
+#endif
struct clockinfo clockinfo;
struct sigaction act;
@@ -374,8 +377,11 @@ _thread_init(void)
/* Setup the context for the scheduler: */
_setjmp(_thread_kern_sched_jb);
#if !defined(__ia64__)
- SET_STACK_JB(_thread_kern_sched_jb, _thread_kern_sched_stack +
- sched_stack_size - sizeof(double));
+ stackp = (long)_thread_kern_sched_stack + sched_stack_size - sizeof(double);
+#if defined(__amd64__)
+ stackp &= ~0xFUL;
+#endif
+ SET_STACK_JB(_thread_kern_sched_jb, stackp);
#else
SET_STACK_JB(_thread_kern_sched_jb, _thread_kern_sched_stack,
sched_stack_size);
diff --git a/lib/libc_r/uthread/uthread_sig.c b/lib/libc_r/uthread/uthread_sig.c
index e02ccc369add..3617b36f7335 100644
--- a/lib/libc_r/uthread/uthread_sig.c
+++ b/lib/libc_r/uthread/uthread_sig.c
@@ -1048,13 +1048,20 @@ thread_sigframe_add(struct pthread *thread, int sig, int has_args)
* Leave a little space on the stack and round down to the
* nearest aligned word:
*/
+#if defined(__amd64__)
+ stackp -= 128; /* Skip over 128 byte red-zone */
+#endif
stackp -= sizeof(double);
+#if defined(__amd64__)
+ stackp &= ~0xFUL;
+#else
stackp &= ~0x3UL;
#endif
+#endif
/* Allocate room on top of the stack for a new signal frame: */
stackp -= sizeof(struct pthread_signal_frame);
-#if defined(__ia64__)
+#if defined(__ia64__) || defined(__amd64__)
stackp &= ~0xFUL;
#endif
@@ -1087,6 +1094,9 @@ thread_sigframe_add(struct pthread *thread, int sig, int has_args)
*/
#if !defined(__ia64__)
stackp -= sizeof(double);
+#if defined(__amd64__)
+ stackp &= ~0xFUL;
+#endif
#endif
_setjmp(thread->ctx.jb);
#if !defined(__ia64__)