1*526051f6Sjoerg/* $NetBSD: compat_sigsetjmp.S,v 1.3 2013/11/30 20:54:14 joerg Exp $ */ 2b638db2cSchristos 3b638db2cSchristos/* 4b638db2cSchristos * Copyright (c) 1997 Mark Brinicombe 5b638db2cSchristos * All rights reserved. 6b638db2cSchristos * 7b638db2cSchristos * Redistribution and use in source and binary forms, with or without 8b638db2cSchristos * modification, are permitted provided that the following conditions 9b638db2cSchristos * are met: 10b638db2cSchristos * 1. Redistributions of source code must retain the above copyright 11b638db2cSchristos * notice, this list of conditions and the following disclaimer. 12b638db2cSchristos * 2. Redistributions in binary form must reproduce the above copyright 13b638db2cSchristos * notice, this list of conditions and the following disclaimer in the 14b638db2cSchristos * documentation and/or other materials provided with the distribution. 15b638db2cSchristos * 3. All advertising materials mentioning features or use of this software 16b638db2cSchristos * must display the following acknowledgement: 17b638db2cSchristos * This product includes software developed by Mark Brinicombe 18b638db2cSchristos * 4. Neither the name of the University nor the names of its contributors 19b638db2cSchristos * may be used to endorse or promote products derived from this software 20b638db2cSchristos * without specific prior written permission. 21b638db2cSchristos * 22b638db2cSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23b638db2cSchristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24b638db2cSchristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25b638db2cSchristos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26b638db2cSchristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27b638db2cSchristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28b638db2cSchristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29b638db2cSchristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30b638db2cSchristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31b638db2cSchristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32b638db2cSchristos * SUCH DAMAGE. 33b638db2cSchristos */ 34b638db2cSchristos 35b638db2cSchristos#include <machine/asm.h> 36b638db2cSchristos#include <machine/setjmp.h> 37b638db2cSchristos 38b638db2cSchristos/* 39b638db2cSchristos * C library -- sigsetjmp, siglongjmp 40b638db2cSchristos * 41b638db2cSchristos * longjmp(a,v) 42b638db2cSchristos * will generate a "return(v)" from the last call to 43b638db2cSchristos * setjmp(a, m) 44b638db2cSchristos * by restoring registers from the stack. 45b638db2cSchristos * The previous signal state is restored. 46b638db2cSchristos */ 47b638db2cSchristos 48b638db2cSchristosENTRY(sigsetjmp) 492cf5e996Smatt#if defined(__thumb__) && defined(_ARM_ARCH_T2) 502cf5e996Smatt cbnz r1, 1f 512cf5e996Smatt b PLT_SYM(_C_LABEL(_setjmp)) 522cf5e996Smatt1: b PLT_SYM(_C_LABEL(setjmp)) 532cf5e996Smatt#elif !defined(__thumb__) 542cf5e996Smatt cmp r1, #0 552cf5e996Smatt beq PLT_SYM(_C_LABEL(_setjmp)) 562cf5e996Smatt b PLT_SYM(_C_LABEL(setjmp)) 572cf5e996Smatt#else 582cf5e996Smatt push {r3, lr} 592cf5e996Smatt beq 1f 602cf5e996Smatt bl PLT_SYM(_C_LABEL(setjmp)) 612cf5e996Smatt pop {r3, pc} 622cf5e996Smatt1: bl PLT_SYM(_C_LABEL(_setjmp)) 632cf5e996Smatt pop {r3, pc} 642cf5e996Smatt#endif 652cf5e996SmattEND(sigsetjmp) 66b638db2cSchristos 67b638db2cSchristosENTRY(siglongjmp) 68b638db2cSchristos ldr r2, .L_setjmp_magic 69b638db2cSchristos ldr r3, [r0] 702cf5e996Smatt cmp r2, r3 712cf5e996Smatt#if !defined(__thumb__) || defined(_ARM_ARCH_T2) 722cf5e996Smatt#if defined(__thumb__) 732cf5e996Smatt it eq 742cf5e996Smatt#endif 75*526051f6Sjoerg beq PLT_SYM(_C_LABEL(_longjmp)) 76*526051f6Sjoerg b PLT_SYM(_C_LABEL(longjmp)) 772cf5e996Smatt#else 782cf5e996Smatt push {lr} 792cf5e996Smatt sub sp, sp, #4 802cf5e996Smatt beq 1f 812cf5e996Smatt bl PIC_SYM(_C_LABEL(longjmp), PLT) 822cf5e996Smatt b 2f 832cf5e996Smatt1: bl PIC_SYM(_C_LABEL(_longjmp), PLT) 842cf5e996Smatt2: add sp, sp, #4 852cf5e996Smatt pop {pc} 862cf5e996Smatt#endif 872cf5e996Smatt 882cf5e996Smatt .align 0 892cf5e996Smatt.L_setjmp_magic: 902cf5e996Smatt .word _JB_MAGIC__SETJMP 912cf5e996SmattEND(siglongjmp) 92