Remove support in configure for unsupported architectures
[glibc.git] / sysdeps / unix / sysv / linux / ia64 / makecontext.c
blobd7a2a9f15dd963f5d18443b9d7211eaac2a67788
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 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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <libintl.h>
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <ucontext.h>
25 #include <sys/rse.h>
28 struct fdesc
30 unsigned long ip;
31 unsigned long gp;
34 #define PUSH(val) \
35 do { \
36 if (ia64_rse_is_rnat_slot (rbs)) \
37 *rbs++ = 0; \
38 *rbs++ = (val); \
39 } while (0)
42 /* This implementation can handle an ARGC value of at most 8 and
43 values can be passed only in integer registers (r32-r39). */
45 void
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;
51 va_list ap;
52 long *rbs;
53 int i;
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_end & -16;
61 if (argc > 8)
63 fprintf (stderr, _("\
64 makecontext: does not know how to handle more than 8 arguments\n"));
65 exit (-1);
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);
79 va_start (ap, argc);
80 for (i = 0; i < argc; ++i)
81 PUSH(va_arg (ap, long));
82 va_end (ap);
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));
90 sc->sc_ar_rnat = 0;
93 weak_alias (__makecontext, makecontext)