1*84d9c625SLionel Sambuc/* $NetBSD: sigsetjmp.S,v 1.12 2013/09/14 05:38:00 nakayama 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 35e415d488SLionel Sambuc/* 36e415d488SLionel Sambuc * We use the sc_npc field inside the sigcontext to store the save mask 37e415d488SLionel Sambuc */ 38e415d488SLionel Sambuc#define MASK_OFFSET 0x68 39e415d488SLionel Sambuc 40*84d9c625SLionel Sambuc#if __PIC__ - 0 >= 2 412fe8fb19SBen Gras 422fe8fb19SBen GrasENTRY(__sigsetjmp14) 432fe8fb19SBen Gras PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 44e415d488SLionel Sambuc st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf 452fe8fb19SBen Gras sethi %hi(_C_LABEL(__setjmp14)), %o2 462fe8fb19SBen Gras sethi %hi(_C_LABEL(_setjmp)), %o3 472fe8fb19SBen Gras or %o2, %lo(_C_LABEL(__setjmp14)), %o2 482fe8fb19SBen Gras or %o3, %lo(_C_LABEL(_setjmp)), %o3 492fe8fb19SBen Gras brz %o1, 1f 502fe8fb19SBen Gras ldx [%g1+%o3], %o3 ! if (%o1 == 0) goto _setjmp; 512fe8fb19SBen Gras ldx [%g1+%o2], %o3 ! else goto __setjmp; 522fe8fb19SBen Gras1: 532fe8fb19SBen Gras jmp %o3 542fe8fb19SBen Gras nop 552fe8fb19SBen Gras 562fe8fb19SBen GrasENTRY(__siglongjmp14) 572fe8fb19SBen Gras PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 58e415d488SLionel Sambuc ld [%o0+MASK_OFFSET], %o2 ! end of jmpbuf 592fe8fb19SBen Gras sethi %hi(_C_LABEL(__longjmp14)), %o3 602fe8fb19SBen Gras sethi %hi(_C_LABEL(_longjmp)), %o4 612fe8fb19SBen Gras or %o3, %lo(_C_LABEL(__longjmp14)), %o3 622fe8fb19SBen Gras or %o4, %lo(_C_LABEL(_longjmp)), %o4 632fe8fb19SBen Gras brz,a %o2, 1f 642fe8fb19SBen Gras ldx [%g1+%o4], %o4 ! if (%o2 == 0) goto _longjmp; 652fe8fb19SBen Gras ldx [%g1+%o3], %o4 ! else goto __longjmp; 662fe8fb19SBen Gras1: 672fe8fb19SBen Gras jmp %o4 682fe8fb19SBen Gras nop 692fe8fb19SBen Gras unimp 0 70*84d9c625SLionel Sambuc 71*84d9c625SLionel Sambuc#elif __PIC__ - 0 >= 1 722fe8fb19SBen Gras 732fe8fb19SBen GrasENTRY(__sigsetjmp14) 742fe8fb19SBen Gras PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 752fe8fb19SBen Gras cmp %o1,0 76e415d488SLionel Sambuc st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf 772fe8fb19SBen Gras bne,a 1f 782fe8fb19SBen Gras ldx [%g1+_C_LABEL(__setjmp14)], %g1 ! if (%o1 != 0) goto __setjmp; 792fe8fb19SBen Gras ldx [%g1+_C_LABEL(_setjmp)], %g1 ! else goto _setjmp; 802fe8fb19SBen Gras1: 812fe8fb19SBen Gras jmp %g1 822fe8fb19SBen Gras nop 832fe8fb19SBen Gras 842fe8fb19SBen GrasENTRY(__siglongjmp14) 852fe8fb19SBen Gras PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE 86e415d488SLionel Sambuc ld [%o0+MASK_OFFSET],%o2 ! end of jmpbuf 872fe8fb19SBen Gras cmp %o2,0 882fe8fb19SBen Gras bne,a 1f 892fe8fb19SBen Gras ldx [%g1+_C_LABEL(__longjmp14)], %g1 ! if (%o2 != 0) goto __longjmp; 902fe8fb19SBen Gras ldx [%g1+_C_LABEL(_longjmp)], %g1 ! else goto _longjmp; 912fe8fb19SBen Gras1: 922fe8fb19SBen Gras jmp %g1 932fe8fb19SBen Gras nop 942fe8fb19SBen Gras unimp 0 95*84d9c625SLionel Sambuc 96*84d9c625SLionel Sambuc#else /* !__PIC__ */ 972fe8fb19SBen Gras 982fe8fb19SBen GrasENTRY(__sigsetjmp14) 992fe8fb19SBen Gras cmp %o1,0 1002fe8fb19SBen Gras be _C_LABEL(_setjmp) 101e415d488SLionel Sambuc st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf 1022fe8fb19SBen Gras ba,a _C_LABEL(__setjmp14) 1032fe8fb19SBen Gras unimp 0 1042fe8fb19SBen Gras 1052fe8fb19SBen GrasENTRY(__siglongjmp14) 106e415d488SLionel Sambuc ld [%o0+MASK_OFFSET],%g1 1072fe8fb19SBen Gras cmp %g1,0 1082fe8fb19SBen Gras be _C_LABEL(_longjmp) 1092fe8fb19SBen Gras nop 1102fe8fb19SBen Gras ba,a _C_LABEL(__longjmp14) 1112fe8fb19SBen Gras unimp 0 1122fe8fb19SBen Gras 113*84d9c625SLionel Sambuc#endif /* !__PIC__ */ 114