xref: /minix3/lib/libc/arch/ia64/gen/setjmp.S (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc/*	$NetBSD: setjmp.S,v 1.1 2015/04/17 12:51:05 martin Exp $	*/
2*0a6a1f1dSLionel Sambuc
3*0a6a1f1dSLionel Sambuc/*
4*0a6a1f1dSLionel Sambuc * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5*0a6a1f1dSLionel Sambuc * All rights reserved.
6*0a6a1f1dSLionel Sambuc *
7*0a6a1f1dSLionel Sambuc * Author: Chris G. Demetriou
8*0a6a1f1dSLionel Sambuc *
9*0a6a1f1dSLionel Sambuc * Permission to use, copy, modify and distribute this software and
10*0a6a1f1dSLionel Sambuc * its documentation is hereby granted, provided that both the copyright
11*0a6a1f1dSLionel Sambuc * notice and this permission notice appear in all copies of the
12*0a6a1f1dSLionel Sambuc * software, derivative works or modified versions, and any portions
13*0a6a1f1dSLionel Sambuc * thereof, and that both notices appear in supporting documentation.
14*0a6a1f1dSLionel Sambuc *
15*0a6a1f1dSLionel Sambuc * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16*0a6a1f1dSLionel Sambuc * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17*0a6a1f1dSLionel Sambuc * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18*0a6a1f1dSLionel Sambuc *
19*0a6a1f1dSLionel Sambuc * Carnegie Mellon requests users of this software to return to
20*0a6a1f1dSLionel Sambuc *
21*0a6a1f1dSLionel Sambuc *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
22*0a6a1f1dSLionel Sambuc *  School of Computer Science
23*0a6a1f1dSLionel Sambuc *  Carnegie Mellon University
24*0a6a1f1dSLionel Sambuc *  Pittsburgh PA 15213-3890
25*0a6a1f1dSLionel Sambuc *
26*0a6a1f1dSLionel Sambuc * any improvements or extensions that they make and grant Carnegie the
27*0a6a1f1dSLionel Sambuc * rights to redistribute these changes.
28*0a6a1f1dSLionel Sambuc */
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuc#define _LOCORE
31*0a6a1f1dSLionel Sambuc#include <machine/asm.h>
32*0a6a1f1dSLionel Sambuc
33*0a6a1f1dSLionel SambucRCSID("$NetBSD: setjmp.S,v 1.1 2015/04/17 12:51:05 martin Exp $")
34*0a6a1f1dSLionel Sambuc
35*0a6a1f1dSLionel Sambuc#include    <machine/setjmp.h>
36*0a6a1f1dSLionel Sambuc
37*0a6a1f1dSLionel Sambuc/*
38*0a6a1f1dSLionel Sambuc * C library -- setjmp, longjmp
39*0a6a1f1dSLionel Sambuc *
40*0a6a1f1dSLionel Sambuc *	longjmp(a,v)
41*0a6a1f1dSLionel Sambuc * will generate a "return(v)" from
42*0a6a1f1dSLionel Sambuc * the last call to
43*0a6a1f1dSLionel Sambuc *	setjmp(a)
44*0a6a1f1dSLionel Sambuc * by restoring registers from the stack,
45*0a6a1f1dSLionel Sambuc * and the previous signal state.
46*0a6a1f1dSLionel Sambuc */
47*0a6a1f1dSLionel Sambuc
48*0a6a1f1dSLionel SambucENTRY(__setjmp14, 1)
49*0a6a1f1dSLionel Sambuc	alloc	loc0=ar.pfs,1,2,3,0
50*0a6a1f1dSLionel Sambuc	mov	loc1=rp
51*0a6a1f1dSLionel Sambuc	;;
52*0a6a1f1dSLionel Sambuc	mov	out0=1				// how = SIG_BLOCK
53*0a6a1f1dSLionel Sambuc	mov	out1=0				// set = NULL
54*0a6a1f1dSLionel Sambuc	add	out2=J_SIGSET,in0		// oset = &jb[J_SIGSET]
55*0a6a1f1dSLionel Sambuc	br.call.sptk.few rp=_sys___sigprocmask14
56*0a6a1f1dSLionel Sambuc	;;
57*0a6a1f1dSLionel Sambuc	mov	rp=loc1
58*0a6a1f1dSLionel Sambuc	mov	r14=loc0
59*0a6a1f1dSLionel Sambuc	;;
60*0a6a1f1dSLionel Sambuc	alloc	r15=ar.pfs,1,0,0,0		// drop register frame
61*0a6a1f1dSLionel Sambuc	;;
62*0a6a1f1dSLionel Sambuc	mov	ar.pfs=r14			// restore ar.pfs
63*0a6a1f1dSLionel Sambuc	br.sptk.many _setjmp			// finish saving state
64*0a6a1f1dSLionel SambucEND(__setjmp14)
65*0a6a1f1dSLionel Sambuc
66*0a6a1f1dSLionel SambucENTRY(__longjmp14, 2)
67*0a6a1f1dSLionel Sambuc	alloc	loc0=ar.pfs,2,2,3,0
68*0a6a1f1dSLionel Sambuc	mov	loc1=rp
69*0a6a1f1dSLionel Sambuc	;;
70*0a6a1f1dSLionel Sambuc	mov	out0=3				// how = SIG_SETMASK
71*0a6a1f1dSLionel Sambuc	add	out1=J_SIGSET,in0		// set = &jb[J_SIGSET]
72*0a6a1f1dSLionel Sambuc	mov	out2=0				// oset = NULL
73*0a6a1f1dSLionel Sambuc	br.call.sptk.few rp=_sys___sigprocmask14
74*0a6a1f1dSLionel Sambuc	;;
75*0a6a1f1dSLionel Sambuc	mov	rp=loc1
76*0a6a1f1dSLionel Sambuc	mov	r14=loc0
77*0a6a1f1dSLionel Sambuc	;;
78*0a6a1f1dSLionel Sambuc	alloc	r15=ar.pfs,2,0,0,0		// drop register frame
79*0a6a1f1dSLionel Sambuc	;;
80*0a6a1f1dSLionel Sambuc	mov	ar.pfs=r14			// restore ar.pfs
81*0a6a1f1dSLionel Sambuc	br.sptk.many _longjmp			// finish restoring state
82*0a6a1f1dSLionel SambucEND(__longjmp14)
83