xref: /netbsd-src/lib/libc/compat/arch/sh3/gen/compat_sigsetjmp.S (revision a92c06216007da7facc666c78f6e4ba9857970f5)
1*a92c0621Suwe/*	$NetBSD: compat_sigsetjmp.S,v 1.5 2006/01/05 19:21:37 uwe Exp $	*/
24890707aSuwe
34890707aSuwe/*-
44890707aSuwe * Copyright (c) 1990 The Regents of the University of California.
54890707aSuwe * All rights reserved.
64890707aSuwe *
74890707aSuwe * This code is derived from software contributed to Berkeley by
84890707aSuwe * William Jolitz.
94890707aSuwe *
104890707aSuwe * Redistribution and use in source and binary forms, with or without
114890707aSuwe * modification, are permitted provided that the following conditions
124890707aSuwe * are met:
134890707aSuwe * 1. Redistributions of source code must retain the above copyright
144890707aSuwe *    notice, this list of conditions and the following disclaimer.
154890707aSuwe * 2. Redistributions in binary form must reproduce the above copyright
164890707aSuwe *    notice, this list of conditions and the following disclaimer in the
174890707aSuwe *    documentation and/or other materials provided with the distribution.
184890707aSuwe * 3. Neither the name of the University nor the names of its contributors
194890707aSuwe *    may be used to endorse or promote products derived from this software
204890707aSuwe *    without specific prior written permission.
214890707aSuwe *
224890707aSuwe * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
234890707aSuwe * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
244890707aSuwe * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
254890707aSuwe * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
264890707aSuwe * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
274890707aSuwe * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
284890707aSuwe * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
294890707aSuwe * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
304890707aSuwe * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
314890707aSuwe * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
324890707aSuwe * SUCH DAMAGE.
334890707aSuwe *
344890707aSuwe *	from: @(#)setjmp.s	5.1 (Berkeley) 4/23/90"
354890707aSuwe */
364890707aSuwe
374890707aSuwe#include <machine/asm.h>
3855be1ea1Suwe#include <machine/setjmp.h>
3955be1ea1Suwe
404890707aSuwe#if defined(LIBC_SCCS)
41*a92c0621Suwe	RCSID("$NetBSD: compat_sigsetjmp.S,v 1.5 2006/01/05 19:21:37 uwe Exp $")
424890707aSuwe#endif
434890707aSuwe
444890707aSuweENTRY(sigsetjmp)
454890707aSuwe	tst	r5, r5
4655be1ea1Suwe	mov.l	r5, @(_JB_HAS_MASK * 4, r4)
4755be1ea1Suwe	bt	2f			/* if (savemask == 0) */
484890707aSuwe
4955be1ea1Suwe	PIC_PROLOGUE(.L_got_1)
5055be1ea1Suwe	sts.l	pr, @-sp
5155be1ea1Suwe	mov.l	r4, @-sp
5255be1ea1Suwe
5355be1ea1Suwe	mov.l	.L_sigblock, r0
5455be1ea1Suwe1:	CALL	r0			/* int mask = sigblock(0); */
554890707aSuwe	 mov	#0, r4
564890707aSuwe
5755be1ea1Suwe	mov.l	@sp+, r4
5855be1ea1Suwe	lds.l	@sp+, pr
5955be1ea1Suwe	PIC_EPILOGUE
604890707aSuwe
6155be1ea1Suwe	mov.l	r0, @(_JB_SIGMASK * 4, r4)
62c8cec240Suwe
6355be1ea1Suwe2:	/* identical to _setjmp sans mask */
64c8cec240Suwe	add	#((_JB_REG_R15 + 1) * 4), r4
654890707aSuwe	mov.l	r15, @-r4
664890707aSuwe	mov.l	r14, @-r4
674890707aSuwe	mov.l	r13, @-r4
684890707aSuwe	mov.l	r12, @-r4
694890707aSuwe	mov.l	r11, @-r4
704890707aSuwe	mov.l	r10, @-r4
714890707aSuwe	mov.l	r9, @-r4
724890707aSuwe	mov.l	r8, @-r4
734890707aSuwe	sts.l	pr, @-r4
744890707aSuwe	rts
754890707aSuwe	 xor	r0, r0
764890707aSuwe
774890707aSuwe	.align	2
7855be1ea1Suwe.L_got_1:	PIC_GOT_DATUM
7955be1ea1Suwe.L_sigblock:	CALL_DATUM(_C_LABEL(sigblock), 1b)
8055be1ea1Suwe	SET_ENTRY_SIZE(sigsetjmp)
8155be1ea1Suwe
824890707aSuwe
834890707aSuweENTRY(siglongjmp)
8455be1ea1Suwe	mov.l	@(_JB_HAS_MASK * 4, r4), r0
854890707aSuwe	tst	r0, r0
86c8cec240Suwe	bt	2f			/* if no mask */
874890707aSuwe
88*a92c0621Suwe	/* we won't return here, so we don't need to save pr and r12 */
89*a92c0621Suwe	PIC_PROLOGUE_NOSAVE(.L_got_2)
9055be1ea1Suwe	mov.l	r5, @-sp
91*a92c0621Suwe	mov.l	r4, @-sp
924890707aSuwe
9355be1ea1Suwe	mov.l	.L_sigsetmask, r0
9455be1ea1Suwe1:	CALL	r0			/* sigsetmask(saved mask) */
9555be1ea1Suwe	 mov.l	@(_JB_SIGMASK * 4, r4), r4
9655be1ea1Suwe
9755be1ea1Suwe	mov.l	@sp+, r4
98*a92c0621Suwe	mov.l	@sp+, r5
9955be1ea1Suwe
10055be1ea1Suwe2:	/* identical to _longjmp */
1014890707aSuwe	lds.l	@r4+, pr
1024890707aSuwe	mov.l	@r4+, r8
1034890707aSuwe	mov.l	@r4+, r9
1044890707aSuwe	mov.l	@r4+, r10
1054890707aSuwe	mov.l	@r4+, r11
1064890707aSuwe	mov.l	@r4+, r12
1074890707aSuwe	mov.l	@r4+, r13
1084890707aSuwe	mov.l	@r4+, r14
1094890707aSuwe	mov.l	@r4+, r15
11055be1ea1Suwe
11155be1ea1Suwe	mov	r5, r0
11255be1ea1Suwe	tst	r0, r0	/* make sure return value is non-zero */
1134890707aSuwe	bf	.L0
1144890707aSuwe	add	#1, r0
1154890707aSuwe.L0:
1164890707aSuwe	rts
1174890707aSuwe	 nop
1184890707aSuwe
1194890707aSuwe	.align	2
12055be1ea1Suwe.L_got_2:	PIC_GOT_DATUM
12155be1ea1Suwe.L_sigsetmask:	CALL_DATUM(_C_LABEL(sigsetmask), 1b)
12255be1ea1Suwe	SET_ENTRY_SIZE(siglongjmp)
123