1*0d34bfa2Suebayasi/* $NetBSD: compat_setjmp.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ 25b84b398Schristos 35b84b398Schristos/*- 45b84b398Schristos * Copyright (c) 1990 The Regents of the University of California. 55b84b398Schristos * All rights reserved. 65b84b398Schristos * 75b84b398Schristos * This code is derived from software contributed to Berkeley by 85b84b398Schristos * William Jolitz. 95b84b398Schristos * 105b84b398Schristos * Redistribution and use in source and binary forms, with or without 115b84b398Schristos * modification, are permitted provided that the following conditions 125b84b398Schristos * are met: 135b84b398Schristos * 1. Redistributions of source code must retain the above copyright 145b84b398Schristos * notice, this list of conditions and the following disclaimer. 155b84b398Schristos * 2. Redistributions in binary form must reproduce the above copyright 165b84b398Schristos * notice, this list of conditions and the following disclaimer in the 175b84b398Schristos * documentation and/or other materials provided with the distribution. 185b84b398Schristos * 3. Neither the name of the University nor the names of its contributors 195b84b398Schristos * may be used to endorse or promote products derived from this software 205b84b398Schristos * without specific prior written permission. 215b84b398Schristos * 225b84b398Schristos * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 235b84b398Schristos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 245b84b398Schristos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 255b84b398Schristos * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 265b84b398Schristos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 275b84b398Schristos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 285b84b398Schristos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 295b84b398Schristos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 305b84b398Schristos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 315b84b398Schristos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 325b84b398Schristos * SUCH DAMAGE. 335b84b398Schristos * 345b84b398Schristos * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 355b84b398Schristos */ 365b84b398Schristos 375b84b398Schristos#include <machine/asm.h> 385b84b398Schristos#if defined(LIBC_SCCS) 39*0d34bfa2Suebayasi RCSID("$NetBSD: compat_setjmp.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $") 405b84b398Schristos#endif 415b84b398Schristos 425b84b398Schristos/* 435b84b398Schristos * C library -- _setjmp, _longjmp 445b84b398Schristos * 455b84b398Schristos * longjmp(a,v) 465b84b398Schristos * will generate a "return(v)" from the last call to 475b84b398Schristos * setjmp(a) 485b84b398Schristos * by restoring registers from the stack. 495b84b398Schristos * The previous signal state is restored. 505b84b398Schristos */ 515b84b398Schristos 525b84b398SchristosENTRY(setjmp) 535b84b398Schristos 545b84b398Schristos PIC_PROLOGUE 555b84b398Schristos pushl $0 564d12bfcdSjoerg#ifdef __PIC__ 575b84b398Schristos call PIC_PLT(_C_LABEL(sigblock)) 585b84b398Schristos#else 595b84b398Schristos call _C_LABEL(sigblock) 605b84b398Schristos#endif 615b84b398Schristos addl $4,%esp 625b84b398Schristos PIC_EPILOGUE 635b84b398Schristos 645b84b398Schristos movl 4(%esp),%ecx 655b84b398Schristos movl 0(%esp),%edx 665b84b398Schristos movl %edx, 0(%ecx) 675b84b398Schristos movl %ebx, 4(%ecx) 685b84b398Schristos movl %esp, 8(%ecx) 695b84b398Schristos movl %ebp,12(%ecx) 705b84b398Schristos movl %esi,16(%ecx) 715b84b398Schristos movl %edi,20(%ecx) 725b84b398Schristos movl %eax,24(%ecx) 735b84b398Schristos xorl %eax,%eax 745b84b398Schristos ret 75*0d34bfa2SuebayasiEND(setjmp) 765b84b398Schristos 775b84b398SchristosENTRY(longjmp) 785b84b398Schristos movl 4(%esp),%edx 795b84b398Schristos 805b84b398Schristos PIC_PROLOGUE 815b84b398Schristos pushl 24(%edx) 824d12bfcdSjoerg#ifdef __PIC__ 835b84b398Schristos call PIC_PLT(_C_LABEL(sigsetmask)) 845b84b398Schristos#else 855b84b398Schristos call _C_LABEL(sigsetmask) 865b84b398Schristos#endif 875b84b398Schristos addl $4,%esp 885b84b398Schristos PIC_EPILOGUE 895b84b398Schristos 905b84b398Schristos movl 4(%esp),%edx 915b84b398Schristos movl 8(%esp),%eax 925b84b398Schristos movl 0(%edx),%ecx 935b84b398Schristos movl 4(%edx),%ebx 945b84b398Schristos movl 8(%edx),%esp 955b84b398Schristos movl 12(%edx),%ebp 965b84b398Schristos movl 16(%edx),%esi 975b84b398Schristos movl 20(%edx),%edi 985b84b398Schristos testl %eax,%eax 995b84b398Schristos jnz 1f 1005b84b398Schristos incl %eax 1015b84b398Schristos1: movl %ecx,0(%esp) 1025b84b398Schristos ret 103*0d34bfa2SuebayasiEND(longjmp) 104