|
|
1.1 ! root 1: /*- ! 2: * Copyright (c) 1990 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * the Systems Programming Group of the University of Utah Computer ! 7: * Science Department. ! 8: * ! 9: * Redistribution and use in source and binary forms are permitted ! 10: * provided that: (1) source distributions retain this entire copyright ! 11: * notice and comment, and (2) distributions including binaries display ! 12: * the following acknowledgement: ``This product includes software ! 13: * developed by the University of California, Berkeley and its contributors'' ! 14: * in the documentation or other materials provided with the distribution ! 15: * and in all advertising materials mentioning features or use of this ! 16: * software. Neither the name of the University nor the names of its ! 17: * contributors may be used to endorse or promote products derived ! 18: * from this software without specific prior written permission. ! 19: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 20: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 21: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 22: */ ! 23: ! 24: #if defined(LIBC_SCCS) && !defined(lint) ! 25: .asciz "@(#)setjmp.s 5.1 (Berkeley) 5/12/90" ! 26: #endif /* LIBC_SCCS and not lint */ ! 27: ! 28: /* ! 29: * C library -- setjmp, longjmp ! 30: * ! 31: * longjmp(a,v) ! 32: * will generate a "return(v)" from ! 33: * the last call to ! 34: * setjmp(a) ! 35: * by restoring registers from the stack, ! 36: * and a struct sigcontext, see <signal.h> ! 37: */ ! 38: ! 39: #include "DEFS.h" ! 40: ! 41: ENTRY(setjmp) ! 42: subql #8,sp /* space for sigstack args/rvals */ ! 43: clrl sp@ /* don't change it... */ ! 44: movl sp,sp@(4) /* ...but return the current val */ ! 45: jsr _sigstack /* note: onstack returned in sp@(4) */ ! 46: clrl sp@ /* don't change mask, just return */ ! 47: jsr _sigblock /* old value */ ! 48: movl sp@(4),d1 /* old onstack value */ ! 49: addql #8,sp ! 50: movl sp@(4),a0 /* save area pointer */ ! 51: movl d1,a0@+ /* save old onstack value */ ! 52: movl d0,a0@+ /* save old signal mask */ ! 53: lea sp@(4),a1 /* adjust saved SP since we won't rts */ ! 54: movl a1,a0@+ /* save old SP */ ! 55: movl a6,a0@+ /* save old FP */ ! 56: clrl a0@+ /* no AP */ ! 57: movl sp@,a0@+ /* save old PC */ ! 58: clrl a0@+ /* clean PS */ ! 59: moveml #0x3CFC,a0@ /* save remaining non-scratch regs */ ! 60: clrl d0 /* return 0 */ ! 61: rts ! 62: ! 63: ENTRY(longjmp) ! 64: movl sp@(4),a0 /* save area pointer */ ! 65: tstl a0@(8) /* ensure non-zero SP */ ! 66: jeq botch /* oops! */ ! 67: movl sp@(8),d0 /* grab return value */ ! 68: jne ok /* non-zero ok */ ! 69: moveq #1,d0 /* else make non-zero */ ! 70: ok: ! 71: moveml a0@(28),#0x3CFC /* restore non-scratch regs */ ! 72: movl a0,sp@- /* let sigreturn */ ! 73: jsr _sigreturn /* finish for us */ ! 74: ! 75: botch: ! 76: jsr _longjmperror ! 77: stop #0
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.