summaryrefslogtreecommitdiff
path: root/lib/libc/arch/ns32k/gen/sigsetjmp.S
blob: 04929573f818acbcd14c3eb0aff1090fa0d10805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*	$NetBSD: sigsetjmp.S,v 1.2 1994/12/07 04:47:59 phil Exp $	*/

/* 
 * Copyright (c) 1992 Helsinki University of Technology
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * HELSINKI UNIVERSITY OF TECHNOLOGY ALLOWS FREE USE OF THIS SOFTWARE IN
 * ITS "AS IS" CONDITION. HELSINKI UNIVERSITY OF TECHNOLOGY DISCLAIMS ANY
 * LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE
 * USE OF THIS SOFTWARE.
 */
/*
 * HISTORY
 * 29-Apr-92  Johannes Helander (jvh) at Helsinki University of Technology
 *	Created.
 *
 * 05-Aug-94  Matthias Pfaller (leo@marco.de)
 *	Converted to sigsetjmp.S from setjmp.S
 *
 *	$Id: sigsetjmp.S,v 1.1 1995/10/18 08:41:37 deraadt Exp $
 */

#include <machine/asm.h>
#include <machine/jmpbuf.h>

ENTRY(sigsetjmp)
	movd	4(sp), r2		/* jmp_buf */
	movd	0(sp), JMP_BUF_PC(r2)	/* pc of caller */
	movd	8(sp), r1		/* savemask */
	movd	r1, JMP_BUF_SIGMASK+4(r2)
	cmpqd	0, r1
	beq	1f
	movqd	0, tos
	bsr	_sigblock
	adjspb	-4
	movd	4(sp), r2		/* jmp_buf */

	movd	r0, JMP_BUF_SIGMASK(r2)	/* save mask */

1:	sprd	sp, JMP_BUF_SP(r2)
	sprd	fp, JMP_BUF_FP(r2)
	sprd	sb, JMP_BUF_SB(r2)
	movd	r3, JMP_BUF_R3(r2)	/* save registers r3-r7 */
	movd	r4, JMP_BUF_R4(r2)
	movd	r5, JMP_BUF_R5(r2)
	movd	r6, JMP_BUF_R6(r2)
	movd	r7, JMP_BUF_R7(r2)

	movqd	0, r0
	ret	0

ENTRY(siglongjmp)
	movd	4(sp),r2		/* jmp_buf */
	cmpqd	0, JMP_BUF_SIGMASK+4(r2)
	beq	1f

	movd	JMP_BUF_SIGMASK(r2), tos /* restore mask */
	bsr	_sigsetmask
	adjspb	-4
	movd	4(sp), r2		/* jmp_buf */

1:	movd	8(sp), r0		/* value */

	lprd	sp, JMP_BUF_SP(r2)
	lprd	fp, JMP_BUF_FP(r2)
	lprd	sb, JMP_BUF_SB(r2)
	movd	JMP_BUF_R3(r2), r3	/* load registers r3-r7 */
	movd	JMP_BUF_R4(r2), r4
	movd	JMP_BUF_R5(r2), r5
	movd	JMP_BUF_R6(r2), r6
	movd	JMP_BUF_R7(r2), r7
	movd	JMP_BUF_PC(r2),	0(sp)	/* patch return pc */

	cmpqd	0, r0
	bne	nonzero
	movqd	1, r0
nonzero:
	ret	0