]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/ia64/makecontext.c
1 /* Copyright (C) 2001-2015 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 Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
31 if (ia64_rse_is_rnat_slot (rbs)) \
37 /* This implementation can handle an ARGC value of at most 8 and
38 values can be passed only in integer registers (r32-r39). */
41 __makecontext (ucontext_t
*ucp
, void (*func
) (void), int argc
, ...)
43 struct sigcontext
*sc
= &ucp
->uc_mcontext
;
44 extern void __start_context (ucontext_t
*link
, long gp
, ...);
45 unsigned long stack_start
, stack_end
;
50 stack_start
= (long) sc
->sc_stack
.ss_sp
;
51 stack_end
= (long) sc
->sc_stack
.ss_sp
+ sc
->sc_stack
.ss_size
;
53 stack_start
= (stack_start
+ 7) & -8;
54 stack_end
= stack_end
& -16;
59 makecontext: does not know how to handle more than 8 arguments\n"));
63 /* set the entry point and global pointer: */
64 sc
->sc_br
[0] = ELF_PTR_TO_FDESC (&__start_context
)->ip
;
65 sc
->sc_br
[1] = ELF_PTR_TO_FDESC (func
)->ip
;
66 sc
->sc_gr
[1] = ELF_PTR_TO_FDESC (func
)->gp
;
68 /* set up the call frame: */
69 sc
->sc_ar_pfs
= ((sc
->sc_ar_pfs
& ~0x3fffffffffUL
)
70 | (argc
+ 2) | ((argc
+ 2) << 7));
71 rbs
= (unsigned long *) stack_start
;
72 PUSH((long) ucp
->uc_link
);
73 PUSH(ELF_PTR_TO_FDESC (&__start_context
)->gp
);
75 for (i
= 0; i
< argc
; ++i
)
76 PUSH(va_arg (ap
, long));
79 /* set the memory and register stack pointers: */
80 sc
->sc_ar_bsp
= (long) rbs
;
81 sc
->sc_gr
[12] = stack_end
- 16;
83 /* clear the NaT bits for r1 and r12: */
84 sc
->sc_nat
&= ~((1 << 1) | (1 << 12));
88 weak_alias (__makecontext
, makecontext
)