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