xref: /minix3/lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc/*	$NetBSD: compat_sigsetjmp.S,v 1.3 2013/11/30 20:54:14 joerg Exp $	*/
22fe8fb19SBen Gras
32fe8fb19SBen Gras/*
42fe8fb19SBen Gras * Copyright (c) 1997 Mark Brinicombe
52fe8fb19SBen Gras * All rights reserved.
62fe8fb19SBen Gras *
72fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without
82fe8fb19SBen Gras * modification, are permitted provided that the following conditions
92fe8fb19SBen Gras * are met:
102fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright
112fe8fb19SBen Gras *    notice, this list of conditions and the following disclaimer.
122fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
132fe8fb19SBen Gras *    notice, this list of conditions and the following disclaimer in the
142fe8fb19SBen Gras *    documentation and/or other materials provided with the distribution.
152fe8fb19SBen Gras * 3. All advertising materials mentioning features or use of this software
162fe8fb19SBen Gras *    must display the following acknowledgement:
172fe8fb19SBen Gras *	This product includes software developed by Mark Brinicombe
182fe8fb19SBen Gras * 4. Neither the name of the University nor the names of its contributors
192fe8fb19SBen Gras *    may be used to endorse or promote products derived from this software
202fe8fb19SBen Gras *    without specific prior written permission.
212fe8fb19SBen Gras *
222fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
232fe8fb19SBen Gras * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
242fe8fb19SBen Gras * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
252fe8fb19SBen Gras * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
262fe8fb19SBen Gras * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
272fe8fb19SBen Gras * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
282fe8fb19SBen Gras * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
292fe8fb19SBen Gras * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
302fe8fb19SBen Gras * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
312fe8fb19SBen Gras * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
322fe8fb19SBen Gras * SUCH DAMAGE.
332fe8fb19SBen Gras */
342fe8fb19SBen Gras
352fe8fb19SBen Gras#include <machine/asm.h>
362fe8fb19SBen Gras#include <machine/setjmp.h>
372fe8fb19SBen Gras
382fe8fb19SBen Gras/*
392fe8fb19SBen Gras * C library -- sigsetjmp, siglongjmp
402fe8fb19SBen Gras *
412fe8fb19SBen Gras *	longjmp(a,v)
422fe8fb19SBen Gras * will generate a "return(v)" from the last call to
432fe8fb19SBen Gras *	setjmp(a, m)
442fe8fb19SBen Gras * by restoring registers from the stack.
452fe8fb19SBen Gras * The previous signal state is restored.
462fe8fb19SBen Gras */
472fe8fb19SBen Gras
482fe8fb19SBen GrasENTRY(sigsetjmp)
49*84d9c625SLionel Sambuc#if defined(__thumb__) && defined(_ARM_ARCH_T2)
50*84d9c625SLionel Sambuc	cbnz	r1, 1f
51*84d9c625SLionel Sambuc	b	PLT_SYM(_C_LABEL(_setjmp))
52*84d9c625SLionel Sambuc1:	b	PLT_SYM(_C_LABEL(setjmp))
53*84d9c625SLionel Sambuc#elif !defined(__thumb__)
54*84d9c625SLionel Sambuc	cmp	r1, #0
55*84d9c625SLionel Sambuc	beq	PLT_SYM(_C_LABEL(_setjmp))
56*84d9c625SLionel Sambuc	b	PLT_SYM(_C_LABEL(setjmp))
57*84d9c625SLionel Sambuc#else
58*84d9c625SLionel Sambuc	push	{r3, lr}
59*84d9c625SLionel Sambuc	beq	1f
60*84d9c625SLionel Sambuc	bl	PLT_SYM(_C_LABEL(setjmp))
61*84d9c625SLionel Sambuc	pop	{r3, pc}
62*84d9c625SLionel Sambuc1:	bl	PLT_SYM(_C_LABEL(_setjmp))
63*84d9c625SLionel Sambuc	pop	{r3, pc}
64*84d9c625SLionel Sambuc#endif
65*84d9c625SLionel SambucEND(sigsetjmp)
662fe8fb19SBen Gras
672fe8fb19SBen GrasENTRY(siglongjmp)
682fe8fb19SBen Gras	ldr	r2, .L_setjmp_magic
692fe8fb19SBen Gras	ldr	r3, [r0]
70*84d9c625SLionel Sambuc	cmp	r2, r3
71*84d9c625SLionel Sambuc#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
72*84d9c625SLionel Sambuc#if defined(__thumb__)
73*84d9c625SLionel Sambuc	it	eq
74*84d9c625SLionel Sambuc#endif
75*84d9c625SLionel Sambuc	beq	PLT_SYM(_C_LABEL(_longjmp))
76*84d9c625SLionel Sambuc	b	PLT_SYM(_C_LABEL(longjmp))
77*84d9c625SLionel Sambuc#else
78*84d9c625SLionel Sambuc	push	{lr}
79*84d9c625SLionel Sambuc	sub	sp, sp, #4
80*84d9c625SLionel Sambuc	beq	1f
81*84d9c625SLionel Sambuc	bl	PIC_SYM(_C_LABEL(longjmp), PLT)
82*84d9c625SLionel Sambuc	b	2f
83*84d9c625SLionel Sambuc1:	bl	PIC_SYM(_C_LABEL(_longjmp), PLT)
84*84d9c625SLionel Sambuc2:	add	sp, sp, #4
85*84d9c625SLionel Sambuc	pop	{pc}
86*84d9c625SLionel Sambuc#endif
87*84d9c625SLionel Sambuc
88*84d9c625SLionel Sambuc	.align	0
89*84d9c625SLionel Sambuc.L_setjmp_magic:
90*84d9c625SLionel Sambuc	.word	_JB_MAGIC__SETJMP
91*84d9c625SLionel SambucEND(siglongjmp)
92