1 /* Copyright (C) 2001-2024 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
30 if (ia64_rse_is_rnat_slot (rbs)) \
36 /* This implementation can handle an ARGC value of at most 8 and
37 values can be passed only in integer registers (r32-r39). */
40 __makecontext (ucontext_t
*ucp
, void (*func
) (void), int argc
, ...)
42 mcontext_t
*sc
= &ucp
->uc_mcontext
;
43 extern void __start_context (ucontext_t
*link
, long gp
, ...);
44 unsigned long stack_start
, stack_end
;
49 stack_start
= (long) sc
->sc_stack
.ss_sp
;
50 stack_end
= (long) sc
->sc_stack
.ss_sp
+ sc
->sc_stack
.ss_size
;
52 stack_start
= (stack_start
+ 7) & -8;
53 stack_end
= stack_end
& -16;
58 makecontext: does not know how to handle more than 8 arguments\n"));
62 /* set the entry point and global pointer: */
63 sc
->sc_br
[0] = ELF_PTR_TO_FDESC (&__start_context
)->ip
;
64 sc
->sc_br
[1] = ELF_PTR_TO_FDESC (func
)->ip
;
65 sc
->sc_gr
[1] = ELF_PTR_TO_FDESC (func
)->gp
;
67 /* set up the call frame: */
68 sc
->sc_ar_pfs
= ((sc
->sc_ar_pfs
& ~0x3fffffffffUL
)
69 | (argc
+ 2) | ((argc
+ 2) << 7));
70 rbs
= (unsigned long *) stack_start
;
71 PUSH((long) ucp
->uc_link
);
72 PUSH(ELF_PTR_TO_FDESC (&__start_context
)->gp
);
74 for (i
= 0; i
< argc
; ++i
)
75 PUSH(va_arg (ap
, long));
78 /* set the memory and register stack pointers: */
79 sc
->sc_ar_bsp
= (long) rbs
;
80 sc
->sc_gr
[12] = stack_end
- 16;
82 /* clear the NaT bits for r1 and r12: */
83 sc
->sc_nat
&= ~((1 << 1) | (1 << 12));
87 weak_alias (__makecontext
, makecontext
)