1 /**
2  * D header file for POSIX.
3  *
4  * Copyright: Public Domain
5  * License:   Public Domain
6  * Authors:   Sean Kelly
7  * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8  */
9 module tango.stdc.posix.setjmp;
10 
11 private import tango.stdc.posix.config;
12 private import tango.stdc.posix.signal; // for sigset_t
13 
14 extern (C):
15 
16 //
17 // Required
18 //
19 /*
20 jmp_buf
21 
22 int  setjmp(jmp_buf);
23 void longjmp(jmp_buf, int);
24 */
25 
26 version( linux )
27 {
28     version( X86_64 )
29     {
30         //const JB_BX     = 0;
31         //const JB_BP     = 1;
32         //const JB_12     = 2;
33         //const JB_13     = 3;
34         //const JB_14     = 4;
35         //const JB_15     = 5;
36         //const JB_SP     = 6;
37         //const JB_PC     = 7;
38         //const JB_SIZE   = 64;
39 
40         alias long[8] __jmp_buf;
41     }
42     else version( X86 )
43     {
44         //const JB_BX     = 0;
45         //const JB_SI     = 1;
46         //const JB_DI     = 2;
47         //const JB_BP     = 3;
48         //const JB_SP     = 4;
49         //const JB_PC     = 5;
50         //const JB_SIZE   = 24;
51 
52         alias int[6] __jmp_buf;
53     }
54     else version ( PPC64 )
55     {
56         /*align(16)*/ alias long[64] __jmp_buf;
57     }
58     else version ( PPC )
59     {
60         /*align(16)*/ alias int[64 + (12 * 4)] __jmp_buf;
61     }
62     else version ( SPARC )
63     {
64         alias int[3] __jmp_buf;
65     }
66 
67     struct __jmp_buf_tag
68     {
69         __jmp_buf   __jmpbuf;
70         int         __mask_was_saved;
71         sigset_t    __saved_mask;
72     }
73 
74     alias __jmp_buf_tag[1] jmp_buf;
75 
76     alias _setjmp setjmp; // see XOpen block
77     void longjmp(jmp_buf, int);
78 }
79 else version( solaris )
80 {
81 	version( X86_64 )		alias long[8] jmp_buf;
82     else version( X86 )		alias int[10] jmp_buf;
83     else version ( SPARC )	alias int[12] jmp_buf;
84 	
85 	int setjmp(jmp_buf);
86 	void longjmp(jmp_buf, int);
87 }
88 
89 //
90 // C Extension (CX)
91 //
92 /*
93 sigjmp_buf
94 
95 int  sigsetjmp(sigjmp_buf, int);
96 void siglongjmp(sigjmp_buf, int);
97 */
98 
99 version( linux )
100 {
101     alias jmp_buf sigjmp_buf;
102 
103     int __sigsetjmp(sigjmp_buf, int);
104     alias __sigsetjmp sigsetjmp;
105     void siglongjmp(sigjmp_buf, int);
106 }
107 else version( solaris )
108 {
109 	version( X86_64 )		alias long[128] sigjmp_buf;
110     else version( X86 )		alias int[128] sigjmp_buf;
111     else version ( SPARC )	alias int[19] sigjmp_buf;
112 	
113 	int  sigsetjmp(sigjmp_buf, int);
114 	void siglongjmp(sigjmp_buf, int);
115 }
116 
117 //
118 // XOpen (XSI)
119 //
120 /*
121 int  _setjmp(jmp_buf);
122 void _longjmp(jmp_buf, int);
123 */
124 
125 version( linux )
126 {
127     int  _setjmp(jmp_buf);
128     void _longjmp(jmp_buf, int);
129 }
130 else version( solaris )
131 {
132     int  _setjmp(jmp_buf);
133     void _longjmp(jmp_buf, int);
134 }