1*84d9c625SLionel Sambuc/* $NetBSD: compat_sigsetjmp.S,v 1.3 2013/09/12 15:36:16 joerg Exp $ */ 22fe8fb19SBen Gras/* 32fe8fb19SBen Gras * Copyright (c) 1995 Paul Kranenburg 42fe8fb19SBen Gras * All rights reserved. 52fe8fb19SBen Gras * 62fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without 72fe8fb19SBen Gras * modification, are permitted provided that the following conditions 82fe8fb19SBen Gras * are met: 92fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright 102fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer. 112fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright 122fe8fb19SBen Gras * notice, this list of conditions and the following disclaimer in the 132fe8fb19SBen Gras * documentation and/or other materials provided with the distribution. 142fe8fb19SBen Gras * 3. All advertising materials mentioning features or use of this software 152fe8fb19SBen Gras * must display the following acknowledgement: 162fe8fb19SBen Gras * This product includes software developed by Paul Kranenburg. 172fe8fb19SBen Gras * 4. The name of the author may not be used to endorse or promote products 182fe8fb19SBen Gras * derived from this software without specific prior written permission 192fe8fb19SBen Gras * 202fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 212fe8fb19SBen Gras * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 222fe8fb19SBen Gras * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 232fe8fb19SBen Gras * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 242fe8fb19SBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 252fe8fb19SBen Gras * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 262fe8fb19SBen Gras * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 272fe8fb19SBen Gras * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 282fe8fb19SBen Gras * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 292fe8fb19SBen Gras * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 302fe8fb19SBen Gras * 312fe8fb19SBen Gras */ 322fe8fb19SBen Gras 332fe8fb19SBen Gras#include "SYS.h" 342fe8fb19SBen Gras 35*84d9c625SLionel Sambuc#ifdef __PIC__ 362fe8fb19SBen Gras 372fe8fb19SBen GrasENTRY(sigsetjmp) 382fe8fb19SBen Gras PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE 392fe8fb19SBen Gras tst %o1 402fe8fb19SBen Gras bnz 1f 412fe8fb19SBen Gras st %o1, [%o0 + 56] ! jmpbuf[JBLEN] = savemask 422fe8fb19SBen Gras 432fe8fb19SBen Gras !! if (savemask == 0) goto _setjmp 442fe8fb19SBen Gras set _C_LABEL(_setjmp), %g2 452fe8fb19SBen Gras ld [%g1 + %g2], %g1 462fe8fb19SBen Gras jmp %g1 472fe8fb19SBen Gras nop 482fe8fb19SBen Gras 492fe8fb19SBen Gras !! if (savemask != 0) goto setjmp 502fe8fb19SBen Gras1: set _C_LABEL(setjmp), %g2 512fe8fb19SBen Gras ld [%g1 + %g2], %g1 522fe8fb19SBen Gras jmp %g1 532fe8fb19SBen Gras nop 542fe8fb19SBen Gras 552fe8fb19SBen Gras 562fe8fb19SBen GrasENTRY(siglongjmp) 572fe8fb19SBen Gras PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE 582fe8fb19SBen Gras ld [%o0 + 56], %g2 ! restoremask = jmpbuf[JBLEN] 592fe8fb19SBen Gras tst %g2 602fe8fb19SBen Gras bnz 1f 612fe8fb19SBen Gras nop 622fe8fb19SBen Gras 632fe8fb19SBen Gras !! if (restoremask == 0) goto _longjmp 642fe8fb19SBen Gras set _C_LABEL(_longjmp), %g2 652fe8fb19SBen Gras ld [%g1 + %g2], %g1 662fe8fb19SBen Gras jmp %g1 672fe8fb19SBen Gras nop 682fe8fb19SBen Gras 692fe8fb19SBen Gras !! if (restoremask != 0) goto longjmp 702fe8fb19SBen Gras1: set _C_LABEL(longjmp), %g2 712fe8fb19SBen Gras ld [%g1 + %g2], %g1 722fe8fb19SBen Gras jmp %g1 732fe8fb19SBen Gras nop 742fe8fb19SBen Gras 75*84d9c625SLionel Sambuc#else /* !__PIC__ */ 762fe8fb19SBen Gras 772fe8fb19SBen GrasENTRY(sigsetjmp) 782fe8fb19SBen Gras cmp %o1,0 792fe8fb19SBen Gras be _C_LABEL(_setjmp) 802fe8fb19SBen Gras st %o1,[%o0+40] ! jmpbuf[JBLEN] 812fe8fb19SBen Gras nop 822fe8fb19SBen Gras ba,a _C_LABEL(setjmp) 832fe8fb19SBen Gras unimp 0 842fe8fb19SBen Gras 852fe8fb19SBen GrasENTRY(siglongjmp) 862fe8fb19SBen Gras ld [%o0+40],%g1 872fe8fb19SBen Gras cmp %g1,0 882fe8fb19SBen Gras be _C_LABEL(_longjmp) 892fe8fb19SBen Gras nop 902fe8fb19SBen Gras ba,a _C_LABEL(longjmp) 912fe8fb19SBen Gras unimp 0 922fe8fb19SBen Gras 93*84d9c625SLionel Sambuc#endif /* !__PIC__ */ 94