Path: blob/main/lib/libc/powerpcspe/gen/sigsetjmp.S
39536 views
/*-1* Copyright (c) 2016 Justin Hibbits2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*/25/* $NetBSD: sigsetjmp.S,v 1.4 1998/10/03 12:30:38 tsubai Exp $ */2627#include <machine/asm.h>28/*29* C library -- sigsetjmp, siglongjmp30*31* siglongjmp(a,v)32* will generate a "return(v?v:1)" from the last call to33* sigsetjmp(a, savemask)34* by restoring registers from the stack.35* The previous signal state is restored if savemask is non-zero36*37* jmpbuf layout:38* +------------+39* | savemask |40* +------------+41* | sig state |42* | |43* | (4 words) |44* | |45* +------------+46* | saved regs |47* | ... |48*/495051#include <sys/syscall.h>5253ENTRY(sigsetjmp)54mr %r6,%r355stw %r4,0(%r3)56or. %r7,%r4,%r457beq 1f58li %r3,1 /* SIG_BLOCK, but doesn't matter */59/* since set == NULL */60li %r4,0 /* set = NULL */61mr %r5,%r6 /* &oset */62addi %r5,%r5,463li %r0, SYS_sigprocmask /* sigprocmask(SIG_BLOCK, NULL, &oset)*/64sc /* assume no error XXX */651:66mflr %r1167mfcr %r1268mr %r10,%r169mr %r9,%r27071/* FPRs */72evstdd %r9,24+0*8(%r6)73evstdd %r10,24+1*8(%r6)74evstdd %r11,24+2*8(%r6)75evstdd %r12,24+3*8(%r6)76evstdd %r13,24+4*8(%r6)77evstdd %r14,24+5*8(%r6)78evstdd %r15,24+6*8(%r6)79evstdd %r16,24+7*8(%r6)80evstdd %r17,24+8*8(%r6)81evstdd %r18,24+9*8(%r6)82evstdd %r19,24+10*8(%r6)83evstdd %r20,24+11*8(%r6)84evstdd %r21,24+12*8(%r6)85evstdd %r22,24+13*8(%r6)86evstdd %r23,24+14*8(%r6)87evstdd %r24,24+15*8(%r6)88evstdd %r25,24+16*8(%r6)89evstdd %r26,24+17*8(%r6)90evstdd %r27,24+18*8(%r6)91evstdd %r28,24+19*8(%r6)92evstdd %r29,24+20*8(%r6)93evstdd %r30,24+21*8(%r6)94evstdd %r31,24+22*8(%r6)9596li %r3,097blr98END(sigsetjmp)99100ENTRY(siglongjmp)101102/* FPRs */103evldd %r9,24+0*8(%r3)104evldd %r10,24+1*8(%r3)105evldd %r11,24+2*8(%r3)106evldd %r12,24+3*8(%r3)107evldd %r13,24+4*8(%r3)108evldd %r14,24+5*8(%r3)109evldd %r15,24+6*8(%r3)110evldd %r16,24+7*8(%r3)111evldd %r17,24+8*8(%r3)112evldd %r18,24+9*8(%r3)113evldd %r19,24+10*8(%r3)114evldd %r20,24+11*8(%r3)115evldd %r21,24+12*8(%r3)116evldd %r22,24+13*8(%r3)117evldd %r23,24+14*8(%r3)118evldd %r24,24+15*8(%r3)119evldd %r25,24+16*8(%r3)120evldd %r26,24+17*8(%r3)121evldd %r27,24+18*8(%r3)122evldd %r28,24+19*8(%r3)123evldd %r29,24+20*8(%r3)124evldd %r30,24+21*8(%r3)125evldd %r31,24+22*8(%r3)126127lwz %r7,0(%r3)128mr %r6,%r4129mtlr %r11130mtcr %r12131mr %r1,%r10132or. %r7,%r7,%r7133beq 1f134mr %r4,%r3135li %r3,3 /* SIG_SETMASK */136addi %r4,%r4,4 /* &set */137li %r5,0 /* oset = NULL */138li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */139sc /* assume no error XXX */1401:141or. %r3,%r6,%r6142bnelr143li %r3,1144blr145END(siglongjmp)146147.section .note.GNU-stack,"",%progbits148149150