Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/arch/i386/gen Align the stack to a 16-byte boundary...



details:   https://anonhg.NetBSD.org/src/rev/52f281ef12ef
branches:  trunk
changeset: 781308:52f281ef12ef
user:      drochner <drochner%NetBSD.org@localhost>
date:      Fri Aug 31 20:57:24 2012 +0000

description:
Align the stack to a 16-byte boundary on LWP creation.
This is more than required by the ABI, but it makes programs using SSE
in a thread work without extra compiler flags or performance hit.

diffstat:

 lib/libc/arch/i386/gen/_lwp.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r 9aa8fdaee236 -r 52f281ef12ef lib/libc/arch/i386/gen/_lwp.c
--- a/lib/libc/arch/i386/gen/_lwp.c     Fri Aug 31 20:23:33 2012 +0000
+++ b/lib/libc/arch/i386/gen/_lwp.c     Fri Aug 31 20:57:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:42 joerg Exp $   */
+/*     $NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $        */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:42 joerg Exp $");
+__RCSID("$NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -56,9 +56,9 @@
        /* LINTED uintptr_t is safe */
        u->uc_mcontext.__gregs[_REG_EIP] = (uintptr_t)start;
        
-       /* Align to a word */
+       /* Align to a 16-byte boundary for SSE */
        /* LINTED uintptr_t is safe */
-       sp = (void **) ((uintptr_t)(stack_base + stack_size) & ~0x3);
+       sp = (void **) (((uintptr_t)(stack_base + stack_size - 4) & ~0xf) + 4);
        
        *--sp = arg;
        *--sp = (void *) _lwp_exit;



Home | Main Index | Thread Index | Old Index