xref: /minix3/lib/libc/compat/arch/sparc64/gen/compat_sigsetjmp.S (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc/*	$NetBSD: compat_sigsetjmp.S,v 1.2 2013/09/12 15:36:16 joerg Exp $	*/
22fe8fb19SBen Gras/*
32fe8fb19SBen Gras * Copyright (c) 1995 Paul Kranenburg
42fe8fb19SBen Gras * All rights reserved.
52fe8fb19SBen Gras *
62fe8fb19SBen Gras * Redistribution and use in source and binary forms, with or without
72fe8fb19SBen Gras * modification, are permitted provided that the following conditions
82fe8fb19SBen Gras * are met:
92fe8fb19SBen Gras * 1. Redistributions of source code must retain the above copyright
102fe8fb19SBen Gras *    notice, this list of conditions and the following disclaimer.
112fe8fb19SBen Gras * 2. Redistributions in binary form must reproduce the above copyright
122fe8fb19SBen Gras *    notice, this list of conditions and the following disclaimer in the
132fe8fb19SBen Gras *    documentation and/or other materials provided with the distribution.
142fe8fb19SBen Gras * 3. All advertising materials mentioning features or use of this software
152fe8fb19SBen Gras *    must display the following acknowledgement:
162fe8fb19SBen Gras *      This product includes software developed by Paul Kranenburg.
172fe8fb19SBen Gras * 4. The name of the author may not be used to endorse or promote products
182fe8fb19SBen Gras *    derived from this software without specific prior written permission
192fe8fb19SBen Gras *
202fe8fb19SBen Gras * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
212fe8fb19SBen Gras * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
222fe8fb19SBen Gras * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
232fe8fb19SBen Gras * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
242fe8fb19SBen Gras * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
252fe8fb19SBen Gras * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
262fe8fb19SBen Gras * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
272fe8fb19SBen Gras * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
282fe8fb19SBen Gras * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
292fe8fb19SBen Gras * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
302fe8fb19SBen Gras *
312fe8fb19SBen Gras */
322fe8fb19SBen Gras
332fe8fb19SBen Gras#include "SYS.h"
342fe8fb19SBen Gras
35*84d9c625SLionel Sambuc#if __PIC__ - 0 >= 2
362fe8fb19SBen Gras
372fe8fb19SBen GrasENTRY(sigsetjmp)
382fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
392fe8fb19SBen Gras	set	_C_LABEL(setjmp), %o2	! if (%o1 != 0) goto _setjmp;
402fe8fb19SBen Gras	set	_C_LABEL(_setjmp), %o3	! else goto __setjmp;
412fe8fb19SBen Gras	movrnz	%o1, %o2, %o3
422fe8fb19SBen Gras	ldx [%g1+%o3], %g1
432fe8fb19SBen Gras	jmp %g1
442fe8fb19SBen Gras	 st	%o1,[%o0+0x48]		! jmpbuf[JBLEN]
452fe8fb19SBen Gras
462fe8fb19SBen Gras
472fe8fb19SBen GrasENTRY(siglongjmp)
482fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
492fe8fb19SBen Gras	ld	[%o0 + 0x48],%o2	! jmpbuf[JBLEN]
502fe8fb19SBen Gras	set	_C_LABEL(longjmp), %o3	! if (%o2 != 0) goto _longjmp;
512fe8fb19SBen Gras	set	_C_LABEL(_longjmp), %o4	! else goto __longjmp;
522fe8fb19SBen Gras	movrnz	%o2, %o3, %o4
532fe8fb19SBen Gras	ldx	[%g1 + %o4], %g1
542fe8fb19SBen Gras	jmp %g1
552fe8fb19SBen Gras	 nop
562fe8fb19SBen Gras	unimp 0
572fe8fb19SBen Gras
58*84d9c625SLionel Sambuc#elif __PIC__ - 0 >= 1
592fe8fb19SBen Gras
602fe8fb19SBen GrasENTRY(sigsetjmp)
612fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
622fe8fb19SBen Gras	cmp	%o1, 0
632fe8fb19SBen Gras	bne,a	1f
642fe8fb19SBen Gras	 ldx	[%g1 + _C_LABEL(setjmp)], %g1	! if (%o1 != 0) goto _setjmp;
652fe8fb19SBen Gras	ldx	[%g1 + _C_LABEL(_setjmp)], %g1	! else goto __setjmp;
662fe8fb19SBen Gras1:
672fe8fb19SBen Gras	jmp %g1
682fe8fb19SBen Gras	 st	%o1,[%o0+0x48]		! jmpbuf[JBLEN]
692fe8fb19SBen Gras
702fe8fb19SBen Gras
712fe8fb19SBen GrasENTRY(siglongjmp)
722fe8fb19SBen Gras	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
732fe8fb19SBen Gras	cmp	%o2, 0
742fe8fb19SBen Gras	ld	[%o0 + 0x48],%o2	! jmpbuf[JBLEN]
752fe8fb19SBen Gras	bne,a	1f
762fe8fb19SBen Gras	 ldx	[%g1 + _C_LABEL(longjmp)], %g1	! if (%o2 != 0) goto _longjmp;
772fe8fb19SBen Gras	ldx	[%g1 + _C_LABEL(_longjmp)], %g1	! else goto __longjmp;
782fe8fb19SBen Gras1:
792fe8fb19SBen Gras	jmp %g1
802fe8fb19SBen Gras	 nop
812fe8fb19SBen Gras	unimp 0
822fe8fb19SBen Gras
83*84d9c625SLionel Sambuc#else /* !__PIC__ */
842fe8fb19SBen Gras
852fe8fb19SBen GrasENTRY(sigsetjmp)
862fe8fb19SBen Gras	brz,pt	%o1,_C_LABEL(_setjmp)
872fe8fb19SBen Gras	 st	%o1,[%o0+0x48]		! jmpbuf[JBLEN]
882fe8fb19SBen Gras	ba,a,pt	%icc,_C_LABEL(setjmp)
892fe8fb19SBen Gras	 nop				! spitfire bug
902fe8fb19SBen Gras	unimp 0
912fe8fb19SBen Gras
922fe8fb19SBen GrasENTRY(siglongjmp)
932fe8fb19SBen Gras	ld	[%o0 + 0x48], %g1
942fe8fb19SBen Gras	brz,pt	%g1, _C_LABEL(_longjmp)
952fe8fb19SBen Gras	 nop
962fe8fb19SBen Gras	ba,a,pt	%icc, _C_LABEL(longjmp)
972fe8fb19SBen Gras	unimp 0
982fe8fb19SBen Gras
99*84d9c625SLionel Sambuc#endif /* !__PIC__ */
100