xref: /netbsd-src/lib/libc/arch/sparc64/gen/sigsetjmp.S (revision c7b602785c767d37c2d67a1f287ddd25f5848ec1)
1*c7b60278Snakayama/*	$NetBSD: sigsetjmp.S,v 1.12 2013/09/14 05:38:00 nakayama Exp $	*/
24c7dd803Schristos/*
34c7dd803Schristos * Copyright (c) 1995 Paul Kranenburg
44c7dd803Schristos * All rights reserved.
54c7dd803Schristos *
64c7dd803Schristos * Redistribution and use in source and binary forms, with or without
74c7dd803Schristos * modification, are permitted provided that the following conditions
84c7dd803Schristos * are met:
94c7dd803Schristos * 1. Redistributions of source code must retain the above copyright
104c7dd803Schristos *    notice, this list of conditions and the following disclaimer.
114c7dd803Schristos * 2. Redistributions in binary form must reproduce the above copyright
124c7dd803Schristos *    notice, this list of conditions and the following disclaimer in the
134c7dd803Schristos *    documentation and/or other materials provided with the distribution.
144c7dd803Schristos * 3. All advertising materials mentioning features or use of this software
154c7dd803Schristos *    must display the following acknowledgement:
164c7dd803Schristos *      This product includes software developed by Paul Kranenburg.
174c7dd803Schristos * 4. The name of the author may not be used to endorse or promote products
184c7dd803Schristos *    derived from this software without specific prior written permission
194c7dd803Schristos *
204c7dd803Schristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
214c7dd803Schristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
224c7dd803Schristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
234c7dd803Schristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
244c7dd803Schristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
254c7dd803Schristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
264c7dd803Schristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
274c7dd803Schristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
284c7dd803Schristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
294c7dd803Schristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
304c7dd803Schristos *
314c7dd803Schristos */
324c7dd803Schristos
334c7dd803Schristos#include "SYS.h"
344c7dd803Schristos
35d21307a5Smartin/*
36d21307a5Smartin * We use the sc_npc field inside the sigcontext to store the save mask
37d21307a5Smartin */
3844283e6eSmartin#define	MASK_OFFSET	0x68
39d21307a5Smartin
404d12bfcdSjoerg#if __PIC__ - 0 >= 2
414c7dd803Schristos
424c7dd803SchristosENTRY(__sigsetjmp14)
434c7dd803Schristos	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
4444283e6eSmartin	st	%o1,[%o0+MASK_OFFSET]	! end of jmpbuf
454c7dd803Schristos	sethi	%hi(_C_LABEL(__setjmp14)), %o2
464c7dd803Schristos	sethi	%hi(_C_LABEL(_setjmp)), %o3
474c7dd803Schristos	or	%o2, %lo(_C_LABEL(__setjmp14)), %o2
484c7dd803Schristos	or	%o3, %lo(_C_LABEL(_setjmp)), %o3
494c7dd803Schristos	brz	%o1, 1f
504c7dd803Schristos	 ldx	[%g1+%o3], %o3		! if (%o1 == 0) goto _setjmp;
514c7dd803Schristos	ldx	[%g1+%o2], %o3		! else goto __setjmp;
524c7dd803Schristos1:
534c7dd803Schristos	jmp	%o3
544c7dd803Schristos	 nop
554c7dd803Schristos
564c7dd803SchristosENTRY(__siglongjmp14)
574c7dd803Schristos	PIC_PROLOGUE(%g1,%o2)		! %g1 = _GLOBAL_OFFSET_TABLE
5844283e6eSmartin	ld	[%o0+MASK_OFFSET], %o2	! end of jmpbuf
594c7dd803Schristos	sethi	%hi(_C_LABEL(__longjmp14)), %o3
604c7dd803Schristos	sethi	%hi(_C_LABEL(_longjmp)), %o4
614c7dd803Schristos	or	%o3, %lo(_C_LABEL(__longjmp14)), %o3
624c7dd803Schristos	or	%o4, %lo(_C_LABEL(_longjmp)), %o4
634c7dd803Schristos	brz,a	%o2, 1f
644c7dd803Schristos	 ldx	[%g1+%o4], %o4		! if (%o2 == 0) goto _longjmp;
654c7dd803Schristos	ldx	[%g1+%o3], %o4		! else goto __longjmp;
664c7dd803Schristos1:
674c7dd803Schristos	jmp	%o4
684c7dd803Schristos	 nop
694c7dd803Schristos	unimp 0
704d12bfcdSjoerg
71*c7b60278Snakayama#elif __PIC__ - 0 >= 1
724c7dd803Schristos
734c7dd803SchristosENTRY(__sigsetjmp14)
744c7dd803Schristos	PIC_PROLOGUE(%g1,%o2)			! %g1 = _GLOBAL_OFFSET_TABLE
754c7dd803Schristos	cmp	%o1,0
7644283e6eSmartin	st	%o1,[%o0+MASK_OFFSET]		! end of jmpbuf
774c7dd803Schristos	bne,a	1f
784c7dd803Schristos	 ldx	[%g1+_C_LABEL(__setjmp14)], %g1	! if (%o1 != 0) goto __setjmp;
794c7dd803Schristos	ldx	[%g1+_C_LABEL(_setjmp)], %g1	! else goto _setjmp;
804c7dd803Schristos1:
814c7dd803Schristos	jmp %g1
824c7dd803Schristos	 nop
834c7dd803Schristos
844c7dd803SchristosENTRY(__siglongjmp14)
854c7dd803Schristos	PIC_PROLOGUE(%g1,%o2)			! %g1 = _GLOBAL_OFFSET_TABLE
8644283e6eSmartin	ld	[%o0+MASK_OFFSET],%o2		! end of jmpbuf
874c7dd803Schristos	cmp	%o2,0
884c7dd803Schristos	bne,a	1f
894c7dd803Schristos	 ldx	[%g1+_C_LABEL(__longjmp14)], %g1 ! if (%o2 != 0) goto __longjmp;
904c7dd803Schristos	ldx	[%g1+_C_LABEL(_longjmp)], %g1	! else goto _longjmp;
914c7dd803Schristos1:
924c7dd803Schristos	jmp %g1
934c7dd803Schristos	 nop
944c7dd803Schristos	unimp 0
954d12bfcdSjoerg
964d12bfcdSjoerg#else /* !__PIC__ */
974c7dd803Schristos
984c7dd803SchristosENTRY(__sigsetjmp14)
994c7dd803Schristos	cmp	%o1,0
1004c7dd803Schristos	be	_C_LABEL(_setjmp)
10144283e6eSmartin	 st	%o1,[%o0+MASK_OFFSET]	! end of jmpbuf
1024c7dd803Schristos	ba,a	_C_LABEL(__setjmp14)
1034c7dd803Schristos	unimp 0
1044c7dd803Schristos
1054c7dd803SchristosENTRY(__siglongjmp14)
106d21307a5Smartin	ld	[%o0+MASK_OFFSET],%g1
1074c7dd803Schristos	cmp	%g1,0
1084c7dd803Schristos	be	_C_LABEL(_longjmp)
1094c7dd803Schristos	 nop
1104c7dd803Schristos	ba,a	_C_LABEL(__longjmp14)
1114c7dd803Schristos	unimp 0
1124c7dd803Schristos
1134d12bfcdSjoerg#endif /* !__PIC__ */
114