compat_sigsetjmp.S revision 1.3 1 /* $NetBSD: compat_sigsetjmp.S,v 1.3 2013/09/12 15:36:16 joerg Exp $ */
2 /*
3 * Copyright (c) 1995 Paul Kranenburg
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Paul Kranenburg.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33 #include "SYS.h"
34
35 #ifdef __PIC__
36
37 ENTRY(sigsetjmp)
38 PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE
39 tst %o1
40 bnz 1f
41 st %o1, [%o0 + 56] ! jmpbuf[JBLEN] = savemask
42
43 !! if (savemask == 0) goto _setjmp
44 set _C_LABEL(_setjmp), %g2
45 ld [%g1 + %g2], %g1
46 jmp %g1
47 nop
48
49 !! if (savemask != 0) goto setjmp
50 1: set _C_LABEL(setjmp), %g2
51 ld [%g1 + %g2], %g1
52 jmp %g1
53 nop
54
55
56 ENTRY(siglongjmp)
57 PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE
58 ld [%o0 + 56], %g2 ! restoremask = jmpbuf[JBLEN]
59 tst %g2
60 bnz 1f
61 nop
62
63 !! if (restoremask == 0) goto _longjmp
64 set _C_LABEL(_longjmp), %g2
65 ld [%g1 + %g2], %g1
66 jmp %g1
67 nop
68
69 !! if (restoremask != 0) goto longjmp
70 1: set _C_LABEL(longjmp), %g2
71 ld [%g1 + %g2], %g1
72 jmp %g1
73 nop
74
75 #else /* !__PIC__ */
76
77 ENTRY(sigsetjmp)
78 cmp %o1,0
79 be _C_LABEL(_setjmp)
80 st %o1,[%o0+40] ! jmpbuf[JBLEN]
81 nop
82 ba,a _C_LABEL(setjmp)
83 unimp 0
84
85 ENTRY(siglongjmp)
86 ld [%o0+40],%g1
87 cmp %g1,0
88 be _C_LABEL(_longjmp)
89 nop
90 ba,a _C_LABEL(longjmp)
91 unimp 0
92
93 #endif /* !__PIC__ */
94