From 70ece8be1d4df61fee1848497ed18b744905a684 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Mon, 28 Jan 2008 18:48:42 +0000 Subject: Properly align stack such that code that uses SSE2 instructions doesn't crash. ok espie@, beck@ --- lib/libpthread/arch/i386/uthread_machdep.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libpthread/arch/i386/uthread_machdep.c b/lib/libpthread/arch/i386/uthread_machdep.c index 42c8f52774a..8d9d5da9da5 100644 --- a/lib/libpthread/arch/i386/uthread_machdep.c +++ b/lib/libpthread/arch/i386/uthread_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_machdep.c,v 1.5 2006/04/06 15:27:08 kurt Exp $ */ +/* $OpenBSD: uthread_machdep.c,v 1.6 2008/01/28 18:48:41 kettenis Exp $ */ /* David Leonard, . Public domain. */ /* @@ -65,8 +65,12 @@ _thread_machdep_init(struct _machdep_state* statep, void *base, int len, { struct frame *f; - /* Locate the initial frame, aligned at the top of the stack */ - f = (struct frame *)(((int)base + len - sizeof *f) & ~15); + /* + * Locate the initial frame at the top of the stack. For the + * stack to end up properly (16-byte) aligned, we need to + * align the frame at an odd 8-byte boundary. + */ + f = (struct frame *)((((int)base + len - sizeof *f) & ~15) - 8); /* Set up initial frame */ f->fr_esp = (int)&f->fr_edi; -- cgit v1.2.3