1*4d12bfcdSjoerg/* $NetBSD: compat_sigsetjmp.S,v 1.2 2013/09/12 15:36:16 joerg Exp $ */ 2180e99b5Schristos/* 3180e99b5Schristos * Copyright (c) 1995 Paul Kranenburg 4180e99b5Schristos * All rights reserved. 5180e99b5Schristos * 6180e99b5Schristos * Redistribution and use in source and binary forms, with or without 7180e99b5Schristos * modification, are permitted provided that the following conditions 8180e99b5Schristos * are met: 9180e99b5Schristos * 1. Redistributions of source code must retain the above copyright 10180e99b5Schristos * notice, this list of conditions and the following disclaimer. 11180e99b5Schristos * 2. Redistributions in binary form must reproduce the above copyright 12180e99b5Schristos * notice, this list of conditions and the following disclaimer in the 13180e99b5Schristos * documentation and/or other materials provided with the distribution. 14180e99b5Schristos * 3. All advertising materials mentioning features or use of this software 15180e99b5Schristos * must display the following acknowledgement: 16180e99b5Schristos * This product includes software developed by Paul Kranenburg. 17180e99b5Schristos * 4. The name of the author may not be used to endorse or promote products 18180e99b5Schristos * derived from this software without specific prior written permission 19180e99b5Schristos * 20180e99b5Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21180e99b5Schristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22180e99b5Schristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23180e99b5Schristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24180e99b5Schristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25180e99b5Schristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26180e99b5Schristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27180e99b5Schristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28180e99b5Schristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29180e99b5Schristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30180e99b5Schristos * 31180e99b5Schristos */ 32180e99b5Schristos 33180e99b5Schristos#include "SYS.h" 34180e99b5Schristos 35*4d12bfcdSjoerg#if __PIC__ - 0 >= 2 36180e99b5Schristos 37180e99b5SchristosENTRY(sigsetjmp) 38180e99b5Schristos PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 39180e99b5Schristos set _C_LABEL(setjmp), %o2 ! if (%o1 != 0) goto _setjmp; 40180e99b5Schristos set _C_LABEL(_setjmp), %o3 ! else goto __setjmp; 41180e99b5Schristos movrnz %o1, %o2, %o3 42180e99b5Schristos ldx [%g1+%o3], %g1 43180e99b5Schristos jmp %g1 44180e99b5Schristos st %o1,[%o0+0x48] ! jmpbuf[JBLEN] 45180e99b5Schristos 46180e99b5Schristos 47180e99b5SchristosENTRY(siglongjmp) 48180e99b5Schristos PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 49180e99b5Schristos ld [%o0 + 0x48],%o2 ! jmpbuf[JBLEN] 50180e99b5Schristos set _C_LABEL(longjmp), %o3 ! if (%o2 != 0) goto _longjmp; 51180e99b5Schristos set _C_LABEL(_longjmp), %o4 ! else goto __longjmp; 52180e99b5Schristos movrnz %o2, %o3, %o4 53180e99b5Schristos ldx [%g1 + %o4], %g1 54180e99b5Schristos jmp %g1 55180e99b5Schristos nop 56180e99b5Schristos unimp 0 57180e99b5Schristos 58*4d12bfcdSjoerg#elif __PIC__ - 0 >= 1 59180e99b5Schristos 60180e99b5SchristosENTRY(sigsetjmp) 61180e99b5Schristos PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 62180e99b5Schristos cmp %o1, 0 63180e99b5Schristos bne,a 1f 64180e99b5Schristos ldx [%g1 + _C_LABEL(setjmp)], %g1 ! if (%o1 != 0) goto _setjmp; 65180e99b5Schristos ldx [%g1 + _C_LABEL(_setjmp)], %g1 ! else goto __setjmp; 66180e99b5Schristos1: 67180e99b5Schristos jmp %g1 68180e99b5Schristos st %o1,[%o0+0x48] ! jmpbuf[JBLEN] 69180e99b5Schristos 70180e99b5Schristos 71180e99b5SchristosENTRY(siglongjmp) 72180e99b5Schristos PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 73180e99b5Schristos cmp %o2, 0 74180e99b5Schristos ld [%o0 + 0x48],%o2 ! jmpbuf[JBLEN] 75180e99b5Schristos bne,a 1f 76180e99b5Schristos ldx [%g1 + _C_LABEL(longjmp)], %g1 ! if (%o2 != 0) goto _longjmp; 77180e99b5Schristos ldx [%g1 + _C_LABEL(_longjmp)], %g1 ! else goto __longjmp; 78180e99b5Schristos1: 79180e99b5Schristos jmp %g1 80180e99b5Schristos nop 81180e99b5Schristos unimp 0 82180e99b5Schristos 83*4d12bfcdSjoerg#else /* !__PIC__ */ 84180e99b5Schristos 85180e99b5SchristosENTRY(sigsetjmp) 86180e99b5Schristos brz,pt %o1,_C_LABEL(_setjmp) 87180e99b5Schristos st %o1,[%o0+0x48] ! jmpbuf[JBLEN] 88180e99b5Schristos ba,a,pt %icc,_C_LABEL(setjmp) 89180e99b5Schristos nop ! spitfire bug 90180e99b5Schristos unimp 0 91180e99b5Schristos 92180e99b5SchristosENTRY(siglongjmp) 93180e99b5Schristos ld [%o0 + 0x48], %g1 94180e99b5Schristos brz,pt %g1, _C_LABEL(_longjmp) 95180e99b5Schristos nop 96180e99b5Schristos ba,a,pt %icc, _C_LABEL(longjmp) 97180e99b5Schristos unimp 0 98180e99b5Schristos 99*4d12bfcdSjoerg#endif /* !__PIC__ */ 100