diff options
author | peter <peter@FreeBSD.org> | 2003-12-03 06:54:40 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-12-03 06:54:40 +0000 |
commit | 976bb368f632aecb3df41d286354c57f38921b00 (patch) | |
tree | dd4cb5a18a26bf30a1c6df35e18a237dba59bd22 /lib/libc_r/uthread/uthread_init.c | |
parent | 53610e3cd2be6e7615ccc52ddb9f997276a0b1da (diff) | |
download | FreeBSD-src-976bb368f632aecb3df41d286354c57f38921b00.zip FreeBSD-src-976bb368f632aecb3df41d286354c57f38921b00.tar.gz |
For the amd64 we need to do some extra stack alignment fixups. Otherwise
we can end up with some threads with a non-16-byte-aligned stack. This
causes some interesting side effects, including general protection
faults leading to a SIGBUS when doing floating point or varargs. This
should be just a verbose NOP for the other platforms.
Approved by: re (scottl)
Diffstat (limited to 'lib/libc_r/uthread/uthread_init.c')
-rw-r--r-- | lib/libc_r/uthread/uthread_init.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libc_r/uthread/uthread_init.c b/lib/libc_r/uthread/uthread_init.c index 5367d0b..d3a2b45 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); |