xref: /openbsd/lib/libc/arch/sparc64/gen/_setjmp.S (revision a5f181b9)
1*a5f181b9Smiod/*	$OpenBSD: _setjmp.S,v 1.3 2004/05/04 15:57:06 miod Exp $	*/
27e2260f1Sart/*	$NetBSD: _setjmp.S,v 1.4 1998/10/08 02:27:59 eeh Exp $	*/
37e2260f1Sart
47e2260f1Sart/*
57e2260f1Sart * Copyright (c) 1992, 1993
67e2260f1Sart *	The Regents of the University of California.  All rights reserved.
77e2260f1Sart *
87e2260f1Sart * This software was developed by the Computer Systems Engineering group
97e2260f1Sart * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
107e2260f1Sart * contributed to Berkeley.
117e2260f1Sart *
127e2260f1Sart * Redistribution and use in source and binary forms, with or without
137e2260f1Sart * modification, are permitted provided that the following conditions
147e2260f1Sart * are met:
157e2260f1Sart * 1. Redistributions of source code must retain the above copyright
167e2260f1Sart *    notice, this list of conditions and the following disclaimer.
177e2260f1Sart * 2. Redistributions in binary form must reproduce the above copyright
187e2260f1Sart *    notice, this list of conditions and the following disclaimer in the
197e2260f1Sart *    documentation and/or other materials provided with the distribution.
206580fee3Smillert * 3. Neither the name of the University nor the names of its contributors
217e2260f1Sart *    may be used to endorse or promote products derived from this software
227e2260f1Sart *    without specific prior written permission.
237e2260f1Sart *
247e2260f1Sart * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
257e2260f1Sart * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
267e2260f1Sart * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
277e2260f1Sart * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
287e2260f1Sart * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
297e2260f1Sart * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
307e2260f1Sart * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
317e2260f1Sart * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
327e2260f1Sart * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
337e2260f1Sart * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
347e2260f1Sart * SUCH DAMAGE.
357e2260f1Sart */
367e2260f1Sart
377e2260f1Sart#include <machine/asm.h>
387e2260f1Sart
39*a5f181b9Smiod	.register	%g2,#ignore
40*a5f181b9Smiod	.register	%g3,#ignore
41*a5f181b9Smiod
427e2260f1Sart/*
437e2260f1Sart * C library -- _setjmp, _longjmp
447e2260f1Sart *
457e2260f1Sart *	_longjmp(a,v)
467e2260f1Sart * will generate a "return(v?v:1)" from
477e2260f1Sart * the last call to
487e2260f1Sart *	_setjmp(a)
49*a5f181b9Smiod * by restoring the previous context.
507e2260f1Sart * The previous signal state is NOT restored.
517e2260f1Sart */
527e2260f1Sart
537e2260f1SartENTRY(_setjmp)
547e2260f1Sart	stx	%sp, [%o0 + 0x00]	/* store caller's stack pointer */
55*a5f181b9Smiod	stx	%o7, [%o0 + 0x08]	/* ... and return pc */
567e2260f1Sart	retl
577e2260f1Sart	 clr	%o0			! return 0
587e2260f1Sart
597e2260f1SartENTRY(_longjmp)
60*a5f181b9Smiod	save	%sp, -CC64FSZ, %sp
61*a5f181b9Smiod	flushw
62*a5f181b9Smiod	ldx	[%i0 + 0x00], %fp
63*a5f181b9Smiod	ldx	[%i0 + 0x08], %i7
64*a5f181b9Smiod	mov	1, %i0
65*a5f181b9Smiod	movrnz	%i1, %i1, %i0		! compute v ? v : 1
66*a5f181b9Smiod	ret
67*a5f181b9Smiod	 restore
68