1 /* Copyright (C) 2001 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
35 if (ia64_rse_is_rnat_slot (rbs)) \
41 /* This implementation can handle an ARGC value of at most 8 and
42 values can be passed only in integer registers (r32-r39). */
45 __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
47 struct sigcontext *sc = &ucp->uc_mcontext;
48 extern void __start_context (ucontext_t *link, long gp, ...);
49 unsigned long stack_start, stack_end;
54 stack_start = (long) sc->sc_stack.ss_sp;
55 stack_end = (long) sc->sc_stack.ss_sp + sc->sc_stack.ss_size;
57 stack_start = (stack_start + 7) & -8;
58 stack_end = (stack_start + 15) & -16;
63 makecontext: does not know how to handle more than 8 arguments\n"));
67 /* set the entry point and global pointer: */
68 sc->sc_br[0] = ((struct fdesc *) &__start_context)->ip;
69 sc->sc_br[1] = ((struct fdesc *) func)->ip;
70 sc->sc_gr[1] = ((struct fdesc *) func)->gp;
72 /* set up the call frame: */
73 sc->sc_ar_pfs = ((sc->sc_ar_pfs & ~0x3fffffffffUL)
74 | (argc + 2) | ((argc + 2) << 7));
75 rbs = (long *) stack_start;
76 PUSH((long) ucp->uc_link);
77 PUSH(((struct fdesc *) &__start_context)->gp);
79 for (i = 0; i < argc; ++i)
80 PUSH(va_arg (ap, long));
83 /* set the memory and register stack pointers: */
84 sc->sc_ar_bsp = (long) rbs;
85 sc->sc_gr[12] = stack_end - 16;
87 /* clear the NaT bits for r1 and r12: */
88 sc->sc_nat &= ~((1 << 1) | (1 << 12));
92 weak_alias (__makecontext, makecontext)