_setjmp.S revision 1.3 1 1.3 matt /* $NetBSD: _setjmp.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */
2 1.1 thorpej
3 1.1 thorpej #include <machine/asm.h>
4 1.1 thorpej
5 1.1 thorpej #if defined(LIBC_SCCS)
6 1.3 matt __RCSID("$NetBSD: _setjmp.S,v 1.3 2011/01/15 07:31:12 matt Exp $")
7 1.1 thorpej #endif
8 1.1 thorpej
9 1.1 thorpej /*
10 1.1 thorpej * C library -- _setjmp, _longjmp
11 1.1 thorpej *
12 1.1 thorpej * _longjmp(a,v)
13 1.1 thorpej * will generate a "return(v?v:1)" from the last call to
14 1.1 thorpej * _setjmp(a)
15 1.1 thorpej * by restoring registers from the stack.
16 1.1 thorpej * The previous signal state is NOT restored.
17 1.1 thorpej */
18 1.1 thorpej
19 1.1 thorpej ENTRY(_setjmp)
20 1.2 matt mflr %r11 /* save return address */
21 1.2 matt mfcr %r12 /* save condition register */
22 1.2 matt mr %r10,%r1 /* save stack pointer */
23 1.2 matt mr %r9,%r2 /* save GPR2 (not needed) */
24 1.2 matt stmw %r9,8(%r3) /* save r9..r31 */
25 1.2 matt li %r3,0 /* indicate success */
26 1.2 matt blr /* return */
27 1.3 matt END(_setjmp)
28 1.1 thorpej
29 1.1 thorpej ENTRY(_longjmp)
30 1.2 matt lmw %r9,8(%r3) /* save r9..r31 */
31 1.2 matt mtlr %r11 /* restore LR */
32 1.2 matt mtcr %r12 /* restore CR */
33 1.2 matt mr %r2,%r9 /* restore GPR2 (not needed) */
34 1.2 matt mr %r1,%r10 /* restore stack */
35 1.2 matt or. %r3,%r4,%r4 /* get return value */
36 1.2 matt bnelr /* return if not 0 */
37 1.2 matt li %r3,1 /* what's the point? */
38 1.2 matt blr /* return */
39 1.3 matt END(_longjmp)
40