1*cf88c389Smatt/* $NetBSD: _setjmp.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */ 25ef4bdf6Sthorpej 35ef4bdf6Sthorpej#include <machine/asm.h> 45ef4bdf6Sthorpej 55ef4bdf6Sthorpej#if defined(LIBC_SCCS) 6*cf88c389Smatt__RCSID("$NetBSD: _setjmp.S,v 1.3 2011/01/15 07:31:12 matt Exp $") 75ef4bdf6Sthorpej#endif 85ef4bdf6Sthorpej 95ef4bdf6Sthorpej/* 105ef4bdf6Sthorpej * C library -- _setjmp, _longjmp 115ef4bdf6Sthorpej * 125ef4bdf6Sthorpej * _longjmp(a,v) 135ef4bdf6Sthorpej * will generate a "return(v?v:1)" from the last call to 145ef4bdf6Sthorpej * _setjmp(a) 155ef4bdf6Sthorpej * by restoring registers from the stack. 165ef4bdf6Sthorpej * The previous signal state is NOT restored. 175ef4bdf6Sthorpej */ 185ef4bdf6Sthorpej 195ef4bdf6SthorpejENTRY(_setjmp) 201cddd41eSmatt mflr %r11 /* save return address */ 211cddd41eSmatt mfcr %r12 /* save condition register */ 221cddd41eSmatt mr %r10,%r1 /* save stack pointer */ 231cddd41eSmatt mr %r9,%r2 /* save GPR2 (not needed) */ 241cddd41eSmatt stmw %r9,8(%r3) /* save r9..r31 */ 251cddd41eSmatt li %r3,0 /* indicate success */ 261cddd41eSmatt blr /* return */ 27*cf88c389SmattEND(_setjmp) 285ef4bdf6Sthorpej 295ef4bdf6SthorpejENTRY(_longjmp) 301cddd41eSmatt lmw %r9,8(%r3) /* save r9..r31 */ 311cddd41eSmatt mtlr %r11 /* restore LR */ 321cddd41eSmatt mtcr %r12 /* restore CR */ 331cddd41eSmatt mr %r2,%r9 /* restore GPR2 (not needed) */ 341cddd41eSmatt mr %r1,%r10 /* restore stack */ 351cddd41eSmatt or. %r3,%r4,%r4 /* get return value */ 361cddd41eSmatt bnelr /* return if not 0 */ 371cddd41eSmatt li %r3,1 /* what's the point? */ 381cddd41eSmatt blr /* return */ 39*cf88c389SmattEND(_longjmp) 40