xref: /minix3/lib/libc/compat/arch/sparc64/gen/compat_sigsetjmp.S (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras/*	$NetBSD: compat_sigsetjmp.S,v 1.1 2005/10/16 04:41:34 christos Exp $	*/
2*2fe8fb19SBen Gras/*
3*2fe8fb19SBen Gras * Copyright (c) 1995 Paul Kranenburg
4*2fe8fb19SBen Gras * All rights reserved.
5*2fe8fb19SBen Gras *
6*2fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without
7*2fe8fb19SBen Gras * modification, are permitted provided that the following conditions
8*2fe8fb19SBen Gras * are met:
9*2fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright
10*2fe8fb19SBen Gras *    notice, this list of conditions and the following disclaimer.
11*2fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
12*2fe8fb19SBen Gras *    notice, this list of conditions and the following disclaimer in the
13*2fe8fb19SBen Gras *    documentation and/or other materials provided with the distribution.
14*2fe8fb19SBen Gras * 3. All advertising materials mentioning features or use of this software
15*2fe8fb19SBen Gras *    must display the following acknowledgement:
16*2fe8fb19SBen Gras *      This product includes software developed by Paul Kranenburg.
17*2fe8fb19SBen Gras * 4. The name of the author may not be used to endorse or promote products
18*2fe8fb19SBen Gras *    derived from this software without specific prior written permission
19*2fe8fb19SBen Gras *
20*2fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21*2fe8fb19SBen Gras * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22*2fe8fb19SBen Gras * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23*2fe8fb19SBen Gras * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24*2fe8fb19SBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25*2fe8fb19SBen Gras * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26*2fe8fb19SBen Gras * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27*2fe8fb19SBen Gras * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28*2fe8fb19SBen Gras * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29*2fe8fb19SBen Gras * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*2fe8fb19SBen Gras *
31*2fe8fb19SBen Gras */
32*2fe8fb19SBen Gras
33*2fe8fb19SBen Gras#include "SYS.h"
34*2fe8fb19SBen Gras
35*2fe8fb19SBen Gras#ifdef PIC
36*2fe8fb19SBen Gras#ifdef BIGPIC
37*2fe8fb19SBen Gras
38*2fe8fb19SBen GrasENTRY(sigsetjmp)
39*2fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
40*2fe8fb19SBen Gras	set	_C_LABEL(setjmp), %o2	! if (%o1 != 0) goto _setjmp;
41*2fe8fb19SBen Gras	set	_C_LABEL(_setjmp), %o3	! else goto __setjmp;
42*2fe8fb19SBen Gras	movrnz	%o1, %o2, %o3
43*2fe8fb19SBen Gras	ldx [%g1+%o3], %g1
44*2fe8fb19SBen Gras	jmp %g1
45*2fe8fb19SBen Gras	 st	%o1,[%o0+0x48]		! jmpbuf[JBLEN]
46*2fe8fb19SBen Gras
47*2fe8fb19SBen Gras
48*2fe8fb19SBen GrasENTRY(siglongjmp)
49*2fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
50*2fe8fb19SBen Gras	ld	[%o0 + 0x48],%o2	! jmpbuf[JBLEN]
51*2fe8fb19SBen Gras	set	_C_LABEL(longjmp), %o3	! if (%o2 != 0) goto _longjmp;
52*2fe8fb19SBen Gras	set	_C_LABEL(_longjmp), %o4	! else goto __longjmp;
53*2fe8fb19SBen Gras	movrnz	%o2, %o3, %o4
54*2fe8fb19SBen Gras	ldx	[%g1 + %o4], %g1
55*2fe8fb19SBen Gras	jmp %g1
56*2fe8fb19SBen Gras	 nop
57*2fe8fb19SBen Gras	unimp 0
58*2fe8fb19SBen Gras
59*2fe8fb19SBen Gras#else
60*2fe8fb19SBen Gras
61*2fe8fb19SBen GrasENTRY(sigsetjmp)
62*2fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
63*2fe8fb19SBen Gras	cmp	%o1, 0
64*2fe8fb19SBen Gras	bne,a	1f
65*2fe8fb19SBen Gras	 ldx	[%g1 + _C_LABEL(setjmp)], %g1	! if (%o1 != 0) goto _setjmp;
66*2fe8fb19SBen Gras	ldx	[%g1 + _C_LABEL(_setjmp)], %g1	! else goto __setjmp;
67*2fe8fb19SBen Gras1:
68*2fe8fb19SBen Gras	jmp %g1
69*2fe8fb19SBen Gras	 st	%o1,[%o0+0x48]		! jmpbuf[JBLEN]
70*2fe8fb19SBen Gras
71*2fe8fb19SBen Gras
72*2fe8fb19SBen GrasENTRY(siglongjmp)
73*2fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
74*2fe8fb19SBen Gras	cmp	%o2, 0
75*2fe8fb19SBen Gras	ld	[%o0 + 0x48],%o2	! jmpbuf[JBLEN]
76*2fe8fb19SBen Gras	bne,a	1f
77*2fe8fb19SBen Gras	 ldx	[%g1 + _C_LABEL(longjmp)], %g1	! if (%o2 != 0) goto _longjmp;
78*2fe8fb19SBen Gras	ldx	[%g1 + _C_LABEL(_longjmp)], %g1	! else goto __longjmp;
79*2fe8fb19SBen Gras1:
80*2fe8fb19SBen Gras	jmp %g1
81*2fe8fb19SBen Gras	 nop
82*2fe8fb19SBen Gras	unimp 0
83*2fe8fb19SBen Gras
84*2fe8fb19SBen Gras#endif /* BIGPIC */
85*2fe8fb19SBen Gras#else /* PIC */
86*2fe8fb19SBen Gras
87*2fe8fb19SBen GrasENTRY(sigsetjmp)
88*2fe8fb19SBen Gras	brz,pt	%o1,_C_LABEL(_setjmp)
89*2fe8fb19SBen Gras	 st	%o1,[%o0+0x48]		! jmpbuf[JBLEN]
90*2fe8fb19SBen Gras	ba,a,pt	%icc,_C_LABEL(setjmp)
91*2fe8fb19SBen Gras	 nop				! spitfire bug
92*2fe8fb19SBen Gras	unimp 0
93*2fe8fb19SBen Gras
94*2fe8fb19SBen GrasENTRY(siglongjmp)
95*2fe8fb19SBen Gras	ld	[%o0 + 0x48], %g1
96*2fe8fb19SBen Gras	brz,pt	%g1, _C_LABEL(_longjmp)
97*2fe8fb19SBen Gras	 nop
98*2fe8fb19SBen Gras	ba,a,pt	%icc, _C_LABEL(longjmp)
99*2fe8fb19SBen Gras	unimp 0
100*2fe8fb19SBen Gras
101*2fe8fb19SBen Gras#endif /* PIC */
102