1*54385Storek/* 2*54385Storek * Copyright (c) 1992 The Regents of the University of California. 3*54385Storek * All rights reserved. 4*54385Storek * 5*54385Storek * This software was developed by the Computer Systems Engineering group 6*54385Storek * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7*54385Storek * contributed to Berkeley. 8*54385Storek * 9*54385Storek * %sccs.include.redist.c% 10*54385Storek * 11*54385Storek * from: $Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp $ 12*54385Storek */ 13*54385Storek 14*54385Storek#if defined(LIBC_SCCS) && !defined(lint) 15*54385Storek .asciz "@(#)_setjmp.s 5.1 (Berkeley) 06/25/92" 16*54385Storek#endif /* LIBC_SCCS and not lint */ 17*54385Storek 18*54385Storek/* 19*54385Storek * C library -- _setjmp, _longjmp 20*54385Storek * 21*54385Storek * _longjmp(a,v) 22*54385Storek * will generate a "return(v?v:1)" from 23*54385Storek * the last call to 24*54385Storek * _setjmp(a) 25*54385Storek * by unwinding the call stack. 26*54385Storek * The previous signal state is NOT restored. 27*54385Storek */ 28*54385Storek 29*54385Storek#include "DEFS.h" 30*54385Storek 31*54385StorekENTRY(_setjmp) 32*54385Storek std %sp, [%o0+0] /* caller's stack pointer and return pc */ 33*54385Storek st %fp, [%o0+8] /* store caller's frame pointer */ 34*54385Storek retl 35*54385Storek clr %o0 ! return 0 36*54385Storek 37*54385StorekENTRY(_longjmp) 38*54385Storek addcc %o1, %g0, %g6 ! compute v ? v : 1 in a global register 39*54385Storek be,a 0f 40*54385Storek mov 1, %g6 41*54385Storek0: 42*54385Storek mov %o0, %g1 ! save a in another global register 43*54385Storek ld [%g1+8], %g7 /* get caller's frame */ 44*54385Storek1: 45*54385Storek cmp %fp, %g7 ! compare against desired frame 46*54385Storek bl,a 1b ! if below, 47*54385Storek restore ! pop frame and loop 48*54385Storek be,a 2f ! if there, 49*54385Storek ldd [%g1+0], %o2 ! fetch return %sp and pc, and get out 50*54385Storek 51*54385StorekLbotch: 52*54385Storek call _longjmperror ! otherwise, went too far; bomb out 53*54385Storek nop 54*54385Storek unimp 0 55*54385Storek 56*54385Storek2: 57*54385Storek cmp %o2, %sp ! %sp must not decrease 58*54385Storek bge,a 3f 59*54385Storek mov %o2, %sp ! it is OK, put it in place 60*54385Storek b,a Lbotch 61*54385Storek3: 62*54385Storek jmp %o3 + 8 ! success, return %g6 63*54385Storek mov %g6, %o0 64