Print this page
6507 i386 makecontext(3c) needs to 16-byte align the stack


  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include "thr_uberdata.h"
  27 #include <procfs.h>
  28 #include <ucontext.h>
  29 #include <setjmp.h>
  30 
  31 /*
  32  * The i386 ABI says that the stack pointer need be only 4-byte aligned
  33  * before a function call (STACK_ALIGN == 4).  We use a 16-byte stack
  34  * alignment for the benefit of floating point code compiled using sse2.
  35  * Even though the i386 ABI doesn't require it, both cc and gcc
  36  * assume this alignment on entry to a function and maintain it
  37  * for calls made from that function.  If the stack is initially
  38  * aligned on a 16-byte boundary, it will continue to be so aligned.
  39  * If it is not initially so aligned, it will never become so aligned.

  40  */
  41 #undef  STACK_ALIGN
  42 #define STACK_ALIGN     16
  43 
  44 extern int getlwpstatus(thread_t, lwpstatus_t *);
  45 extern int putlwpregs(thread_t, prgregset_t);
  46 
  47 void *
  48 setup_top_frame(void *stk, size_t stksize, ulwp_t *ulwp)
  49 {
  50         uint32_t *stack;
  51         struct {
  52                 uint32_t        rpc;
  53                 uint32_t        arg;
  54                 uint32_t        pad;
  55                 uint32_t        fp;
  56                 uint32_t        pc;
  57         } frame;
  58 
  59         /*




  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 #include "thr_uberdata.h"
  27 #include <procfs.h>
  28 #include <ucontext.h>
  29 #include <setjmp.h>
  30 
  31 /*
  32  * The stack needs to be 16-byte aligned with a 4-byte bias.  See comment in
  33  * lib/libc/i386/gen/makectxt.c.
  34  *
  35  * Note: If you change it, you need to change it in the following files as
  36  * well:
  37  *
  38  *  - lib/libc/i386/gen/makectxt.c
  39  *  - lib/common/i386/crti.s
  40  *  - lib/common/i386/crt1.s
  41  */
  42 #undef  STACK_ALIGN
  43 #define STACK_ALIGN     16
  44 
  45 extern int getlwpstatus(thread_t, lwpstatus_t *);
  46 extern int putlwpregs(thread_t, prgregset_t);
  47 
  48 void *
  49 setup_top_frame(void *stk, size_t stksize, ulwp_t *ulwp)
  50 {
  51         uint32_t *stack;
  52         struct {
  53                 uint32_t        rpc;
  54                 uint32_t        arg;
  55                 uint32_t        pad;
  56                 uint32_t        fp;
  57                 uint32_t        pc;
  58         } frame;
  59 
  60         /*