/*
 * sMachDep.s for stubbed PCR.
 * Contains an alternate implementation of setjmp/longjmp.  The standard one
 * uses a bigger buffer, and thus breaks with Cedar code that thinks it knows
 * the size of the buffer.  Stole from real PCR.
 */
#include <sys/trap.h>


!
!
! Replacement for ←setjmp / ←longjmp
!
! Doesn't do Sun's check-for-longjmp-0 hack.
!
! This uses three cells of the jmp←buf:
!
!   buf[0] (offset=0): saved pc (exactly as stored by the call instruction)
!   buf[1] (offset=4): not used
!   buf[2] (offset=8): saved sp (stored here for compatibility with ←setjmp)
!
	.seg	"text"
	.proc	16
	.globl	←XR←setjmp
←XR←setjmp:
	st	%sp,[%o0+8]
	st	%o7,[%o0]
	retl
	clr	%o0		! delay slot
!
!
	.seg	"text"
	.proc	16
	.globl	←XR←longjmp
←XR←longjmp:
	t	ST←FLUSH←WINDOWS
	sub	%sp,64,%sp	! leave space for another copy of regs in case
				! preempted while fp and sp inconsistent below.
				! (this is why C library versions of ←setjmp/
				! ←longjmp can't be used)
	ld	[%o0+8],%fp
	sub	%fp,64,%sp
	ld	[%o0],%i7	! return ptr
	ret
	restore	%o1,0,%o0	! delay slot