]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/ia64/makecontext.c
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. */
36 if (ia64_rse_is_rnat_slot (rbs)) \
42 /* This implementation can handle an ARGC value of at most 8 and
43 values can be passed only in integer registers (r32-r39). */
46 __makecontext (ucontext_t
*ucp
, void (*func
) (void), int argc
, ...)
48 struct sigcontext
*sc
= &ucp
->uc_mcontext
;
49 extern void __start_context (ucontext_t
*link
, long gp
, ...);
50 unsigned long stack_start
, stack_end
;
55 stack_start
= (long) sc
->sc_stack
.ss_sp
;
56 stack_end
= (long) sc
->sc_stack
.ss_sp
+ sc
->sc_stack
.ss_size
;
58 stack_start
= (stack_start
+ 7) & -8;
59 stack_end
= (stack_start
+ 15) & -16;
64 makecontext: does not know how to handle more than 8 arguments\n"));
68 /* set the entry point and global pointer: */
69 sc
->sc_br
[0] = ((struct fdesc
*) &__start_context
)->ip
;
70 sc
->sc_br
[1] = ((struct fdesc
*) func
)->ip
;
71 sc
->sc_gr
[1] = ((struct fdesc
*) func
)->gp
;
73 /* set up the call frame: */
74 sc
->sc_ar_pfs
= ((sc
->sc_ar_pfs
& ~0x3fffffffffUL
)
75 | (argc
+ 2) | ((argc
+ 2) << 7));
76 rbs
= (long *) stack_start
;
77 PUSH((long) ucp
->uc_link
);
78 PUSH(((struct fdesc
*) &__start_context
)->gp
);
80 for (i
= 0; i
< argc
; ++i
)
81 PUSH(va_arg (ap
, long));
84 /* set the memory and register stack pointers: */
85 sc
->sc_ar_bsp
= (long) rbs
;
86 sc
->sc_gr
[12] = stack_end
- 16;
88 /* clear the NaT bits for r1 and r12: */
89 sc
->sc_nat
&= ~((1 << 1) | (1 << 12));
93 weak_alias (__makecontext
, makecontext
)