xref: /freebsd-src/lib/libc/arm/gen/sigsetjmp.S (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
14e75169fSAndrew Turner/*	$NetBSD: sigsetjmp.S,v 1.6 2013/04/19 16:50:22 matt Exp $	*/
22357939bSOlivier Houchard
32357939bSOlivier Houchard/*
42357939bSOlivier Houchard * Copyright (c) 1997 Mark Brinicombe
52357939bSOlivier Houchard * All rights reserved.
62357939bSOlivier Houchard *
72357939bSOlivier Houchard * Redistribution and use in source and binary forms, with or without
82357939bSOlivier Houchard * modification, are permitted provided that the following conditions
92357939bSOlivier Houchard * are met:
102357939bSOlivier Houchard * 1. Redistributions of source code must retain the above copyright
112357939bSOlivier Houchard *    notice, this list of conditions and the following disclaimer.
122357939bSOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright
132357939bSOlivier Houchard *    notice, this list of conditions and the following disclaimer in the
142357939bSOlivier Houchard *    documentation and/or other materials provided with the distribution.
152357939bSOlivier Houchard * 3. All advertising materials mentioning features or use of this software
162357939bSOlivier Houchard *    must display the following acknowledgement:
172357939bSOlivier Houchard *	This product includes software developed by Mark Brinicombe
182357939bSOlivier Houchard * 4. Neither the name of the University nor the names of its contributors
192357939bSOlivier Houchard *    may be used to endorse or promote products derived from this software
202357939bSOlivier Houchard *    without specific prior written permission.
212357939bSOlivier Houchard *
222357939bSOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
232357939bSOlivier Houchard * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
242357939bSOlivier Houchard * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
252357939bSOlivier Houchard * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
262357939bSOlivier Houchard * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
272357939bSOlivier Houchard * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
282357939bSOlivier Houchard * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
292357939bSOlivier Houchard * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
302357939bSOlivier Houchard * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
312357939bSOlivier Houchard * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
322357939bSOlivier Houchard * SUCH DAMAGE.
332357939bSOlivier Houchard */
342357939bSOlivier Houchard
352357939bSOlivier Houchard#include <machine/asm.h>
364e75169fSAndrew Turner#include <machine/setjmp.h>
374e75169fSAndrew Turner
382357939bSOlivier Houchard/*
392357939bSOlivier Houchard * C library -- sigsetjmp, siglongjmp
402357939bSOlivier Houchard *
412357939bSOlivier Houchard *	longjmp(a,v)
422357939bSOlivier Houchard * will generate a "return(v)" from the last call to
432357939bSOlivier Houchard *	setjmp(a, m)
442357939bSOlivier Houchard * by restoring registers from the stack.
452357939bSOlivier Houchard * The previous signal state is restored.
462357939bSOlivier Houchard */
472357939bSOlivier Houchard
482357939bSOlivier HouchardENTRY(sigsetjmp)
492357939bSOlivier Houchard	teq	r1, #0
502357939bSOlivier Houchard	beq	PIC_SYM(_C_LABEL(_setjmp), PLT)
512357939bSOlivier Houchard	b	PIC_SYM(_C_LABEL(setjmp), PLT)
52f2e71517SIan LeporeEND(sigsetjmp)
532357939bSOlivier Houchard
542357939bSOlivier Houchard.L_setjmp_magic:
552357939bSOlivier Houchard	.word	_JB_MAGIC__SETJMP
56904e5aceSOlivier HouchardWEAK_ALIAS(__siglongjmp, siglongjmp)
572357939bSOlivier Houchard
582357939bSOlivier HouchardENTRY(siglongjmp)
59f44fbb4cSAndrew Turner	ldr	r2, .L_setjmp_magic		/* load magic */
60f44fbb4cSAndrew Turner	ldr	r3, [r0]			/* get magic from jmp_buf */
61f44fbb4cSAndrew Turner	bic	r3, r3, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP)
62f44fbb4cSAndrew Turner						/* ignore VFP-ness of magic */
63f44fbb4cSAndrew Turner	teq	r2, r3				/* magic correct? */
642357939bSOlivier Houchard	beq	PIC_SYM(_C_LABEL(_longjmp), PLT)
652357939bSOlivier Houchard	b	PIC_SYM(_C_LABEL(longjmp), PLT)
66f2e71517SIan LeporeEND(siglongjmp)
67*96cdb0abSKonstantin Belousov
68*96cdb0abSKonstantin Belousov	.section .note.GNU-stack,"",%progbits
69