aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-03-16 21:07:22 +0000
committerUlrich Drepper <drepper@redhat.com>2001-03-16 21:07:22 +0000
commitaeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8 (patch)
tree8438c4d6081766a1ede6c89328dfbcd389dbff82
parentb8a8413c6f7970bc4d5659791c3b3670cc037578 (diff)
downloadglibc-aeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8.tar.xz
glibc-aeba9785a6e2e8dca120bb0b62b74ea1eda0a4a8.zip
Update.
2001-03-16 David Mosberger <davidm@hpl.hp.com> * sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h (struct sigcontext): Drop hack that was needed for 2.1.1 kernel headers. * sysdeps/unix/sysv/linux/ia64/ucontext_i.h: New file. * sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Rewrite to make it overlay with kernel's "struct sigcontext". * sysdeps/unix/sysv/linux/ia64/Makefile (sysdep_headers): Add sys/rse.h for "misc" subdir. (sysdep_routines): Add __start_context for "stdlib" subdir. * sysdeps/unix/sysv/linux/ia64/sys/rse.h: New file (based on kernel file of the same name). * stdlib/Makefile (tests): Add tst-setcontext. * stdlib/tst-setcontext.c: New file (based on a sample program by Uli Drepper). * sysdeps/unix/sysv/linux/ia64/setcontext.S: New file. * sysdeps/unix/sysv/linux/ia64/getcontext.S: New file. * sysdeps/unix/sysv/linux/ia64/__start_context.S: New file. * sysdeps/unix/sysv/linux/ia64/makecontext.c: New file. * sysdeps/unix/sysv/linux/ia64/__longjmp.S (__longjmp): Use extr.u instead of shift & and.
-rw-r--r--ChangeLog29
-rw-r--r--linuxthreads/ChangeLog4
-rw-r--r--linuxthreads/attr.c2
-rw-r--r--stdlib/Makefile2
-rw-r--r--stdlib/tst-setcontext.c113
-rw-r--r--sysdeps/unix/sysv/linux/ia64/Makefile8
-rw-r--r--sysdeps/unix/sysv/linux/ia64/__longjmp.S4
-rw-r--r--sysdeps/unix/sysv/linux/ia64/__start_context.S51
-rw-r--r--sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h6
-rw-r--r--sysdeps/unix/sysv/linux/ia64/getcontext.S153
-rw-r--r--sysdeps/unix/sysv/linux/ia64/makecontext.c92
-rw-r--r--sysdeps/unix/sysv/linux/ia64/setcontext.S149
-rw-r--r--sysdeps/unix/sysv/linux/ia64/sys/rse.h78
-rw-r--r--sysdeps/unix/sysv/linux/ia64/sys/ucontext.h74
-rw-r--r--sysdeps/unix/sysv/linux/ia64/ucontext_i.h58
15 files changed, 771 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a06a64a76..b0636e37ba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2001-03-16 David Mosberger <davidm@hpl.hp.com>
+
+ * sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h (struct sigcontext):
+ Drop hack that was needed for 2.1.1 kernel headers.
+
+ * sysdeps/unix/sysv/linux/ia64/ucontext_i.h: New file.
+
+ * sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Rewrite to make it
+ overlay with kernel's "struct sigcontext".
+
+ * sysdeps/unix/sysv/linux/ia64/Makefile (sysdep_headers): Add
+ sys/rse.h for "misc" subdir.
+ (sysdep_routines): Add __start_context for "stdlib" subdir.
+
+ * sysdeps/unix/sysv/linux/ia64/sys/rse.h: New file (based on
+ kernel file of the same name).
+
+ * stdlib/Makefile (tests): Add tst-setcontext.
+ * stdlib/tst-setcontext.c: New file (based on a sample program by
+ Uli Drepper).
+
+ * sysdeps/unix/sysv/linux/ia64/setcontext.S: New file.
+ * sysdeps/unix/sysv/linux/ia64/getcontext.S: New file.
+ * sysdeps/unix/sysv/linux/ia64/__start_context.S: New file.
+ * sysdeps/unix/sysv/linux/ia64/makecontext.c: New file.
+
+ * sysdeps/unix/sysv/linux/ia64/__longjmp.S (__longjmp): Use extr.u
+ instead of shift & and.
+
2001-03-16 Martin Schwidefsky <schwidefsky@de.ibm.com>
* sysdeps/s390/s390-64/bits/huge_val.h: Move to...
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index bbda957a84..3eb7bcbdeb 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,7 @@
+2001-03-16 Ulrich Drepper <drepper@redhat.com>
+
+ * attr.c (pthread_getattr_np): Fix __stacksize computation for IA-64.
+
2001-03-13 Martin Schwidefsky <schwidefsky@de.ibm.com>
* shlib-versions: Add rule for Linux on 64 bit S/390.
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index 8cb0f8f7ef..3553069c2e 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -303,7 +303,7 @@ int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
/* XXX This is awkward. The guard pages are in the middle of the
two stacks. We must count the guard size in the stack size since
otherwise the range of the stack area cannot be computed. */
- attr->__stacksize += attr->guardsize;
+ attr->__stacksize += attr->__guardsize;
#endif
attr->__stackaddr = guardaddr;
diff --git a/stdlib/Makefile b/stdlib/Makefile
index 193c42b284..301e2d22f3 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -59,7 +59,7 @@ test-srcs := tst-fmtmsg
tests := tst-strtol tst-strtod testmb testrand testsort testdiv \
test-canon test-canon2 tst-strtoll tst-environ \
tst-xpg-basename tst-random tst-bsearch tst-limits \
- tst-rand48 bug-strtod
+ tst-rand48 bug-strtod tst-setcontext
# Several mpn functions from GNU MP are used by the strtod function.
diff --git a/stdlib/tst-setcontext.c b/stdlib/tst-setcontext.c
new file mode 100644
index 0000000000..6ee1b514a6
--- /dev/null
+++ b/stdlib/tst-setcontext.c
@@ -0,0 +1,113 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ucontext.h>
+
+static ucontext_t ctx[3];
+
+static int was_in_f1;
+static int was_in_f2;
+
+static void
+f1 (long a0, long a1, long a2, long a3)
+{
+ printf ("start f1(a0=%lx,a1=%lx,a2=%lx,a3=%lx)\n", a0, a1, a2, a3);
+
+ if (a0 != 1 || a1 != 2 || a2 != 3 || a3 != -4)
+ {
+ puts ("arg mismatch");
+ exit (-1);
+ }
+
+ if (swapcontext (&ctx[1], &ctx[2]) != 0)
+ {
+ printf ("%s: swapcontext: %m\n", __FUNCTION__);
+ exit (1);
+ }
+ puts ("finish f1");
+ was_in_f1 = 1;
+}
+
+static void
+f2 (void)
+{
+ puts ("start f2");
+ if (swapcontext (&ctx[2], &ctx[1]) != 0)
+ {
+ printf ("%s: swapcontext: %m\n", __FUNCTION__);
+ exit (1);
+ }
+ puts ("finish f2");
+ was_in_f2 = 1;
+}
+
+int
+main (void)
+{
+ char st1[8192];
+ char st2[8192];
+
+ puts ("making contexts");
+ if (getcontext (&ctx[1]) != 0)
+ {
+ if (errno == ENOSYS)
+ exit (0);
+
+ printf ("%s: getcontext: %m\n", __FUNCTION__);
+ exit (1);
+ }
+ ctx[1].uc_stack.ss_sp = st1;
+ ctx[1].uc_stack.ss_size = sizeof st1;
+ ctx[1].uc_link = &ctx[0];
+ makecontext (&ctx[1], (void (*) (void)) f1, 4, 1, 2, 3, -4);
+
+ if (getcontext (&ctx[2]) != 0)
+ {
+ printf ("%s: second getcontext: %m\n", __FUNCTION__);
+ exit (1);
+ }
+ ctx[2].uc_stack.ss_sp = st2;
+ ctx[2].uc_stack.ss_size = sizeof st2;
+ ctx[2].uc_link = &ctx[1];
+ makecontext (&ctx[2], f2, 0);
+
+ puts ("swapping contexts");
+ if (swapcontext (&ctx[0], &ctx[2]) != 0)
+ {
+ printf ("%s: swapcontext: %m\n", __FUNCTION__);
+ exit (1);
+ }
+ puts ("back at main program");
+
+ if (was_in_f1 == 0)
+ {
+ puts ("didn't reach f1");
+ exit (1);
+ }
+ if (was_in_f2 == 0)
+ {
+ puts ("didn't reach f2");
+ exit (1);
+ }
+
+ puts ("test succeeded");
+ return 0;
+}
diff --git a/sysdeps/unix/sysv/linux/ia64/Makefile b/sysdeps/unix/sysv/linux/ia64/Makefile
index 97861a4e97..7326b9f810 100644
--- a/sysdeps/unix/sysv/linux/ia64/Makefile
+++ b/sysdeps/unix/sysv/linux/ia64/Makefile
@@ -1,3 +1,11 @@
+ifeq ($(subdir),misc)
+sysdep_headers += sys/rse.h
+endif
+
+ifeq ($(subdir),stdlib)
+sysdep_routines += __start_context
+endif
+
ifeq ($(subdir),csu)
CFLAGS-initfini.s += -DWEAK_GMON_START
endif
diff --git a/sysdeps/unix/sysv/linux/ia64/__longjmp.S b/sysdeps/unix/sysv/linux/ia64/__longjmp.S
index 5cc2045097..967cab593d 100644
--- a/sysdeps/unix/sysv/linux/ia64/__longjmp.S
+++ b/sysdeps/unix/sysv/linux/ia64/__longjmp.S
@@ -62,9 +62,7 @@ __longjmp:
sub r8=r8,in0 // r8 <- &orig_jmpbuf - &jmpbuf
;;
ld8 r25=[r2] // r25 <- jmpbuf.ar_unat
- shr r8=r8,3 // r8 <- (&orig_jmpbuf - &jmpbuf)/8
- ;;
- and r8=0x3f,r8
+ extr.u r8=r8,3,6 // r8 <- (&orig_jmpbuf - &jmpbuf)/8 & 0x3f
;;
cmp.lt pNeg,pPos=r8,r0
mov r2=in0
diff --git a/sysdeps/unix/sysv/linux/ia64/__start_context.S b/sysdeps/unix/sysv/linux/ia64/__start_context.S
new file mode 100644
index 0000000000..c21b4cf33a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/__start_context.S
@@ -0,0 +1,51 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <features.h>
+
+/* When a context set up by __makecontext() is activated, control
+ transfers to __start_context. When we get here:
+
+ b1 = entry point of function to call
+ in0 = address of UCP to resume after function returns
+ in1 = global pointer for __start_context
+ out0 .. outN = arguments for function */
+
+ENTRY(__start_context)
+ .prologue
+ alloc r2 = ar.pfs, 2, 0, 8, 0
+
+ .save rp, r4 // terminate call chain with a NULL rp
+ mov r4 = r0
+ ;;
+
+ .body
+ br.call.sptk rp = b1
+1:
+ mov gp = in1 // restore gp
+ cmp.ne p6,p0 = in0, r0 // uc_link != 0 ?
+ ;;
+(p6) mov out0 = in0
+(p6) br.call.sptk rp = __setcontext
+.Lexit:
+ mov out0 = 0
+ br.call.sptk rp = exit
+
+1: br.cond.sptk .Lexit
+END(__start_context)
diff --git a/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h b/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
index 101aad7e5a..8daaa5e485 100644
--- a/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
+++ b/sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h
@@ -21,12 +21,6 @@
# error "Never use <bits/sigcontext.h> directly; include <signal.h> instead."
#endif
-#ifndef sigcontext_struct
-/* Kernel headers before 2.1.1 define a struct sigcontext_struct, but
- we need sigcontext. */
-# define sigcontext_struct sigcontext
-#endif
-
#include <asm/fpu.h>
#include <bits/sigstack.h>
diff --git a/sysdeps/unix/sysv/linux/ia64/getcontext.S b/sysdeps/unix/sysv/linux/ia64/getcontext.S
new file mode 100644
index 0000000000..24b58d435a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/getcontext.S
@@ -0,0 +1,153 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <features.h>
+
+#include "ucontext_i.h"
+
+/* __getcontext (const ucontext_t *ucp)
+
+ Saves the machine context in UCP such that when it is activated,
+ it appears as if __getcontext() returned again. The only difference
+ is that on a first return, r9 contains 1 and on a subsequent
+ return, it contains 0.
+
+ This implementation in intended to be used for *synchronous* context
+ switches only. Therefore, it does not have to save anything
+ other than the PRESERVED state. */
+
+ENTRY(__getcontext)
+ alloc r16 = ar.pfs, 1, 0, 3, 0
+
+ // sigprocmask (SIG_BLOCK, NULL, &sc->sc_mask):
+
+ mov r2 = SC_MASK
+ mov r15 = __NR_rt_sigprocmask
+ ;;
+ mov out0 = SIG_BLOCK
+ mov out1 = 0
+ add out2 = r2, in0
+
+ break __BREAK_SYSCALL
+ flushrs // save dirty partition on rbs
+
+ mov.m rFPSR = ar.fpsr
+ mov.m rRSC = ar.rsc
+ add r2 = SC_GR+1*8, r32
+ ;;
+ mov.m rBSP = ar.bsp
+ mov.m rUNAT = ar.unat
+ add r3 = SC_GR+4*8, r32
+ ;;
+
+.mem.offset 0,0; st8.spill [r2] = r1, (5*8 - 1*8)
+.mem.offset 8,0; st8.spill [r3] = r4, 16
+ mov.i rPFS = ar.pfs
+ ;;
+.mem.offset 0,0; st8.spill [r2] = r5, 16
+.mem.offset 8,0; st8.spill [r3] = r6
+ add r3 = (SC_FR+3*16-(SC_GR+6*8)), r3
+ ;;
+ st8.spill [r2] = r7, (SC_FR+2*16-(SC_GR+7*8))
+ nop 0
+ and rTMP = ~0x3, rRSC
+ ;;
+ mov.m ar.rsc = rTMP // put RSE into enforced lazy mode
+ mov.m rNAT = ar.unat
+ mov.i rLC = ar.lc
+ ;;
+ mov.m rRNAT = ar.rnat
+ mov.m ar.rsc = rRSC // restore RSE mode
+ mov rPR = pr
+
+ /*
+ * Rotate NaT bits by rPOS positions to the right:
+ */
+ stf.spill [r2] = f2, 32
+ stf.spill [r3] = f3, 32
+ add rPOS = SC_GR, r32 // rPOS <- &sc_gr[0]
+ ;;
+ stf.spill [r2] = f4, (16*16-4*16)
+ stf.spill [r3] = f5, (17*16-5*16)
+ extr.u rPOS = rPOS, 3, 6 // get NaT bit number for r0
+ ;;
+ stf.spill [r2] = f16, 32
+ stf.spill [r3] = f17, 32
+ sub rCPOS = 64, rPOS
+ ;;
+ stf.spill [r2] = f18, 32
+ stf.spill [r3] = f19, 32
+ shr.u rTMP = rNAT, rPOS
+ ;;
+ stf.spill [r2] = f20, 32
+ stf.spill [r3] = f21, 32
+ shl rNAT = rNAT, rCPOS
+ ;;
+ stf.spill [r2] = f22, 32
+ stf.spill [r3] = f23, 32
+ or rNAT = rNAT, rTMP
+ ;;
+ stf.spill [r2] = f24, 32
+ stf.spill [r3] = f25, 32
+ mov r8 = 0
+ ;;
+ stf.spill [r2] = f26, 32
+ stf.spill [r3] = f27, 32
+ mov r9 = 1
+ ;;
+ stf.spill [r2] = f28, 32
+ stf.spill [r3] = f29, 32
+ mov rB0 = b0
+ ;;
+ stf.spill [r2] = f30, 32
+ stf.spill [r3] = f31, 32
+ mov rB1 = b1
+ ;;
+ add r2 = SC_NAT, r32
+ nop 0
+ add r3 = SC_BSP, r32
+ ;;
+ st8 [r2] = rNAT, (SC_RNAT-SC_NAT)
+ st8 [r3] = rBSP, (SC_UNAT-SC_BSP)
+ mov rB2 = b2
+ ;;
+ st8 [r2] = rRNAT, (SC_FPSR-SC_RNAT)
+ st8 [r3] = rUNAT, (SC_PFS-SC_UNAT)
+ mov rB3 = b3
+ ;;
+ st8 [r2] = rFPSR, (SC_LC-SC_FPSR)
+ st8 [r3] = rPFS, (SC_PR-SC_PFS)
+ mov rB4 = b4
+ ;;
+ st8 [r2] = rLC, (SC_BR+0*8-SC_LC)
+ st8 [r3] = rPR, (SC_BR+1*8-SC_PR)
+ mov rB5 = b5
+
+ st8 [r2] = rB0, 16
+ st8 [r3] = rB1, 16
+ ;;
+ st8 [r3] = rB2, 16
+ st8 [r3] = rB3, 16
+ ;;
+ st8 [r2] = rB4
+ st8 [r3] = rB5
+ ret
+END(__getcontext)
+
+weak_alias(__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/ia64/makecontext.c b/sysdeps/unix/sysv/linux/ia64/makecontext.c
new file mode 100644
index 0000000000..9f80b114bd
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/makecontext.c
@@ -0,0 +1,92 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ucontext.h>
+
+#include <ia64/rse.h>
+
+struct fdesc
+ {
+ unsigned long ip;
+ unsigned long gp;
+ };
+
+#define PUSH(val) \
+do { \
+ if (ia64_rse_is_rnat_slot (rbs)) \
+ *rbs++ = 0; \
+ *rbs++ = (val); \
+} while (0)
+
+
+/* This implementation can handle an ARGC value of at most 8 and
+ values can be passed only in integer registers (r32-r39). */
+
+void
+__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
+{
+ struct sigcontext *sc = &ucp->uc_mcontext;
+ extern void __start_context (ucontext_t *link, long gp, ...);
+ unsigned long stack_start, stack_end;
+ va_list ap;
+ long *rbs;
+ int i;
+
+ stack_start = (long) sc->sc_stack.ss_sp;
+ stack_end = (long) sc->sc_stack.ss_sp + sc->sc_stack.ss_size;
+
+ stack_start = (stack_start + 7) & -8;
+ stack_end = (stack_start + 15) & -16;
+
+ if (argc > 8)
+ {
+ fprintf (stderr, "__makecontext: does not know how to handle more "
+ "than 8 arguments\n");
+ exit (-1);
+ }
+
+ /* set the entry point and global pointer: */
+ sc->sc_br[0] = ((struct fdesc *) &__start_context)->ip;
+ sc->sc_br[1] = ((struct fdesc *) func)->ip;
+ sc->sc_gr[1] = ((struct fdesc *) func)->gp;
+
+ /* set up the call frame: */
+ sc->sc_ar_pfs = ((sc->sc_ar_pfs & ~0x3fffffffffUL)
+ | (argc + 2) | ((argc + 2) << 7));
+ rbs = (long *) stack_start;
+ PUSH((long) ucp->uc_link);
+ PUSH(((struct fdesc *) &__start_context)->gp);
+ va_start (ap, argc);
+ for (i = 0; i < argc; ++i)
+ PUSH(va_arg (ap, long));
+ va_end (ap);
+
+ /* set the memory and register stack pointers: */
+ sc->sc_ar_bsp = (long) rbs;
+ sc->sc_gr[12] = stack_end - 16;
+
+ /* clear the NaT bits for r1 and r12: */
+ sc->sc_nat &= ~((1 << 1) | (1 << 12));
+ sc->sc_ar_rnat = 0;
+}
+
+weak_alias (__makecontext, makecontext)
diff --git a/sysdeps/unix/sysv/linux/ia64/setcontext.S b/sysdeps/unix/sysv/linux/ia64/setcontext.S
new file mode 100644
index 0000000000..0d6e9a0bce
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/ia64/setcontext.S
@@ -0,0 +1,149 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by David Mosberger-Tang <davidm@hpl.hp.com>.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include <sysdep.h>
+#include <features.h>
+
+#include "ucontext_i.h"
+
+/* __setcontext (const ucontext_t *ucp)
+
+ Restores the machine context in UCP and thereby resumes execution
+ in that context.