1*2fe8fb19SBen Gras/* $NetBSD: compat_sigsetjmp.S,v 1.2 2007/10/08 13:06:00 uwe Exp $ */ 2*2fe8fb19SBen Gras/* 3*2fe8fb19SBen Gras * Copyright (c) 1995 Paul Kranenburg 4*2fe8fb19SBen Gras * All rights reserved. 5*2fe8fb19SBen Gras * 6*2fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without 7*2fe8fb19SBen Gras * modification, are permitted provided that the following conditions 8*2fe8fb19SBen Gras * are met: 9*2fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright 10*2fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer. 11*2fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 12*2fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the 13*2fe8fb19SBen Gras * documentation and/or other materials provided with the distribution. 14*2fe8fb19SBen Gras * 3. All advertising materials mentioning features or use of this software 15*2fe8fb19SBen Gras * must display the following acknowledgement: 16*2fe8fb19SBen Gras * This product includes software developed by Paul Kranenburg. 17*2fe8fb19SBen Gras * 4. The name of the author may not be used to endorse or promote products 18*2fe8fb19SBen Gras * derived from this software without specific prior written permission 19*2fe8fb19SBen Gras * 20*2fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 21*2fe8fb19SBen Gras * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22*2fe8fb19SBen Gras * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23*2fe8fb19SBen Gras * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 24*2fe8fb19SBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25*2fe8fb19SBen Gras * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26*2fe8fb19SBen Gras * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27*2fe8fb19SBen Gras * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28*2fe8fb19SBen Gras * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29*2fe8fb19SBen Gras * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30*2fe8fb19SBen Gras * 31*2fe8fb19SBen Gras */ 32*2fe8fb19SBen Gras 33*2fe8fb19SBen Gras#include "SYS.h" 34*2fe8fb19SBen Gras 35*2fe8fb19SBen Gras#ifdef PIC 36*2fe8fb19SBen Gras 37*2fe8fb19SBen GrasENTRY(sigsetjmp) 38*2fe8fb19SBen Gras PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE 39*2fe8fb19SBen Gras tst %o1 40*2fe8fb19SBen Gras bnz 1f 41*2fe8fb19SBen Gras st %o1, [%o0 + 56] ! jmpbuf[JBLEN] = savemask 42*2fe8fb19SBen Gras 43*2fe8fb19SBen Gras !! if (savemask == 0) goto _setjmp 44*2fe8fb19SBen Gras set _C_LABEL(_setjmp), %g2 45*2fe8fb19SBen Gras ld [%g1 + %g2], %g1 46*2fe8fb19SBen Gras jmp %g1 47*2fe8fb19SBen Gras nop 48*2fe8fb19SBen Gras 49*2fe8fb19SBen Gras !! if (savemask != 0) goto setjmp 50*2fe8fb19SBen Gras1: set _C_LABEL(setjmp), %g2 51*2fe8fb19SBen Gras ld [%g1 + %g2], %g1 52*2fe8fb19SBen Gras jmp %g1 53*2fe8fb19SBen Gras nop 54*2fe8fb19SBen Gras 55*2fe8fb19SBen Gras 56*2fe8fb19SBen GrasENTRY(siglongjmp) 57*2fe8fb19SBen Gras PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE 58*2fe8fb19SBen Gras ld [%o0 + 56], %g2 ! restoremask = jmpbuf[JBLEN] 59*2fe8fb19SBen Gras tst %g2 60*2fe8fb19SBen Gras bnz 1f 61*2fe8fb19SBen Gras nop 62*2fe8fb19SBen Gras 63*2fe8fb19SBen Gras !! if (restoremask == 0) goto _longjmp 64*2fe8fb19SBen Gras set _C_LABEL(_longjmp), %g2 65*2fe8fb19SBen Gras ld [%g1 + %g2], %g1 66*2fe8fb19SBen Gras jmp %g1 67*2fe8fb19SBen Gras nop 68*2fe8fb19SBen Gras 69*2fe8fb19SBen Gras !! if (restoremask != 0) goto longjmp 70*2fe8fb19SBen Gras1: set _C_LABEL(longjmp), %g2 71*2fe8fb19SBen Gras ld [%g1 + %g2], %g1 72*2fe8fb19SBen Gras jmp %g1 73*2fe8fb19SBen Gras nop 74*2fe8fb19SBen Gras 75*2fe8fb19SBen Gras#else /* !PIC */ 76*2fe8fb19SBen Gras 77*2fe8fb19SBen GrasENTRY(sigsetjmp) 78*2fe8fb19SBen Gras cmp %o1,0 79*2fe8fb19SBen Gras be _C_LABEL(_setjmp) 80*2fe8fb19SBen Gras st %o1,[%o0+40] ! jmpbuf[JBLEN] 81*2fe8fb19SBen Gras nop 82*2fe8fb19SBen Gras ba,a _C_LABEL(setjmp) 83*2fe8fb19SBen Gras unimp 0 84*2fe8fb19SBen Gras 85*2fe8fb19SBen GrasENTRY(siglongjmp) 86*2fe8fb19SBen Gras ld [%o0+40],%g1 87*2fe8fb19SBen Gras cmp %g1,0 88*2fe8fb19SBen Gras be _C_LABEL(_longjmp) 89*2fe8fb19SBen Gras nop 90*2fe8fb19SBen Gras ba,a _C_LABEL(longjmp) 91*2fe8fb19SBen Gras unimp 0 92*2fe8fb19SBen Gras 93*2fe8fb19SBen Gras#endif /* !PIC */ 94