xref: /freebsd/sys/arm/include/setjmp.h (revision 9336e0699bda8a301cd2bfa37106b6ec5e32012e)
1 /*	$NetBSD: setjmp.h,v 1.2 2001/08/25 14:45:59 bjh21 Exp $	*/
2 /* $FreeBSD$ */
3 
4 /*
5  * machine/setjmp.h: machine dependent setjmp-related information.
6  */
7 
8 #ifndef _MACHINE_SETJMP_H_
9 #define _MACHINE_SETJMP_H_
10 #ifdef __ELF__
11 #define	_JBLEN	64		/* size, in longs, of a jmp_buf */
12 #else
13 #define	_JBLEN	29		/* size, in longs, of a jmp_buf */
14 #endif
15 
16 /*
17  * NOTE: The internal structure of a jmp_buf is *PRIVATE*
18  *       This information is provided as there is software
19  *       that fiddles with this with obtain the stack pointer
20  *	 (yes really ! and its commercial !).
21  *
22  * Description of the setjmp buffer
23  *
24  * word  0	magic number	(dependant on creator)
25  *       1 -  3	f4		fp register 4
26  *	 4 -  6	f5		fp register 5
27  *	 7 -  9 f6		fp register 6
28  *	10 - 12	f7		fp register 7
29  *	13	fpsr		fp status register
30  *	14	r4		register 4
31  *	15	r5		register 5
32  *	16	r6		register 6
33  *	17	r7		register 7
34  *	18	r8		register 8
35  *	19	r9		register 9
36  *	20	r10		register 10 (sl)
37  *	21	r11		register 11 (fp)
38  *	22	r12		register 12 (ip)
39  *	23	r13		register 13 (sp)
40  *	24	r14		register 14 (lr)
41  *	25	signal mask	(dependant on magic)
42  *	26	(con't)
43  *	27	(con't)
44  *	28	(con't)
45  *
46  * The magic number number identifies the jmp_buf and
47  * how the buffer was created as well as providing
48  * a sanity check
49  *
50  * A side note I should mention - Please do not tamper
51  * with the floating point fields. While they are
52  * always saved and restored at the moment this cannot
53  * be garenteed especially if the compiler happens
54  * to be generating soft-float code so no fp
55  * registers will be used.
56  *
57  * Whilst this can be seen an encouraging people to
58  * use the setjmp buffer in this way I think that it
59  * is for the best then if changes occur compiles will
60  * break rather than just having new builds falling over
61  * mysteriously.
62  */
63 
64 #define _JB_MAGIC__SETJMP	0x4278f500
65 #define _JB_MAGIC_SETJMP	0x4278f501
66 
67 /* Valid for all jmp_buf's */
68 
69 #define _JB_MAGIC		 0
70 #define _JB_REG_F4		 1
71 #define _JB_REG_F5		 4
72 #define _JB_REG_F6		 7
73 #define _JB_REG_F7		10
74 #define _JB_REG_FPSR		13
75 #define _JB_REG_R4		14
76 #define _JB_REG_R5		15
77 #define _JB_REG_R6		16
78 #define _JB_REG_R7		17
79 #define _JB_REG_R8		18
80 #define _JB_REG_R9		19
81 #define _JB_REG_R10		20
82 #define _JB_REG_R11		21
83 #define _JB_REG_R12		22
84 #define _JB_REG_R13		23
85 #define _JB_REG_R14		24
86 
87 /* Only valid with the _JB_MAGIC_SETJMP magic */
88 
89 #define _JB_SIGMASK		25
90 #if __BSD_VISIBLE || __POSIX_VISIBLE || __XSI_VISIBLE
91 typedef struct _sigjmp_buf { int _sjb[_JBLEN + 1]; } sigjmp_buf[1];
92 #endif
93 
94 typedef struct _jmp_buf { int _jb[_JBLEN + 1]; } jmp_buf[1];
95 
96 #endif /* !_MACHINE_SETJMP_H_ */
97