~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to system/include/libc/machine/setjmp.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
_BEGIN_STD_C
 
3
 
 
4
#if defined(__arm__) || defined(__thumb__)
 
5
/*
 
6
 * All callee preserved registers:
 
7
 * v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7
 
8
 */
 
9
#define _JBLEN 23
 
10
#endif
 
11
 
 
12
#if defined(__AVR__)
 
13
#define _JBLEN 24
 
14
#endif
 
15
 
 
16
#ifdef __sparc__
 
17
/*
 
18
 * onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext).
 
19
 * All else recovered by under/over(flow) handling.
 
20
 */
 
21
#define _JBLEN  13
 
22
#endif
 
23
 
 
24
#ifdef __BFIN__
 
25
#define _JBLEN  40
 
26
#endif
 
27
 
 
28
/* necv70 was 9 as well. */
 
29
 
 
30
#if defined(__m68k__) || defined(__mc68000__)
 
31
/*
 
32
 * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6,
 
33
 * fp2-fp7      for 68881.
 
34
 * All else recovered by under/over(flow) handling.
 
35
 */
 
36
#define _JBLEN  34
 
37
#endif
 
38
 
 
39
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
 
40
/*
 
41
 * D, X, Y are not saved.
 
42
 * Only take into account the pseudo soft registers (max 32).
 
43
 */
 
44
#define _JBLEN  32
 
45
#endif
 
46
 
 
47
#if defined(__Z8001__) || defined(__Z8002__)
 
48
/* 16 regs + pc */
 
49
#define _JBLEN 20
 
50
#endif
 
51
 
 
52
#ifdef _AM29K
 
53
/*
 
54
 * onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext).
 
55
 * All else recovered by under/over(flow) handling.
 
56
 */
 
57
#define _JBLEN  9
 
58
#endif
 
59
 
 
60
#if defined(__CYGWIN__) && !defined (_JBLEN)
 
61
#define _JBLEN (13 * 4)
 
62
#elif defined (__i386__)
 
63
#if defined(__unix__) || defined(__rtems__)
 
64
# define _JBLEN 9
 
65
#else
 
66
#include "setjmp-dj.h"
 
67
#endif
 
68
#endif
 
69
 
 
70
#ifdef __x86_64__
 
71
#define _JBTYPE long long
 
72
#define _JBLEN  8
 
73
#endif
 
74
 
 
75
#ifdef __i960__
 
76
#define _JBLEN 35
 
77
#endif
 
78
 
 
79
#ifdef __M32R__
 
80
/* Only 8 words are currently needed.  10 gives us some slop if we need
 
81
   to expand.  */
 
82
#define _JBLEN 10
 
83
#endif
 
84
 
 
85
#ifdef __mips__
 
86
#ifdef __mips64
 
87
#define _JBTYPE long long
 
88
#endif
 
89
#ifdef __mips_soft_float
 
90
#define _JBLEN 11
 
91
#else
 
92
#define _JBLEN 23
 
93
#endif
 
94
#endif
 
95
 
 
96
#ifdef __m88000__
 
97
#define _JBLEN 21
 
98
#endif
 
99
 
 
100
#ifdef __H8300__
 
101
#define _JBLEN 5
 
102
#define _JBTYPE int
 
103
#endif
 
104
 
 
105
#ifdef __H8300H__
 
106
/* same as H8/300 but registers are twice as big */
 
107
#define _JBLEN 5
 
108
#define _JBTYPE long
 
109
#endif
 
110
 
 
111
#if defined (__H8300S__) || defined (__H8300SX__)
 
112
/* same as H8/300 but registers are twice as big */
 
113
#define _JBLEN 5
 
114
#define _JBTYPE long
 
115
#endif
 
116
 
 
117
#ifdef __H8500__
 
118
#define _JBLEN 4
 
119
#endif
 
120
 
 
121
#ifdef  __sh__
 
122
#if __SH5__
 
123
#define _JBLEN 50
 
124
#define _JBTYPE long long
 
125
#else
 
126
#define _JBLEN 20
 
127
#endif /* __SH5__ */
 
128
#endif
 
129
 
 
130
#ifdef  __v800
 
131
#define _JBLEN 28
 
132
#endif
 
133
 
 
134
#ifdef __PPC__
 
135
#ifdef __ALTIVEC__
 
136
#define _JBLEN 64
 
137
#else
 
138
#define _JBLEN 32
 
139
#endif
 
140
#define _JBTYPE double
 
141
#endif
 
142
 
 
143
#ifdef __MICROBLAZE__
 
144
#define _JBLEN  20
 
145
#define _JBTYPE unsigned int
 
146
#endif
 
147
 
 
148
#ifdef __hppa__
 
149
/* %r30, %r2-%r18, %r27, pad, %fr12-%fr15.
 
150
   Note space exists for the FP registers, but they are not
 
151
   saved.  */
 
152
#define _JBLEN 28
 
153
#endif
 
154
 
 
155
#if defined(__mn10300__) || defined(__mn10200__)
 
156
#ifdef __AM33_2__
 
157
#define _JBLEN 26
 
158
#else
 
159
/* A guess */
 
160
#define _JBLEN 10
 
161
#endif
 
162
#endif
 
163
 
 
164
#ifdef __v850
 
165
/* I think our setjmp is saving 15 regs at the moment.  Gives us one word
 
166
   slop if we need to expand.  */
 
167
#define _JBLEN 16
 
168
#endif
 
169
 
 
170
#if defined(_C4x)
 
171
#define _JBLEN 10
 
172
#endif
 
173
#if defined(_C3x)
 
174
#define _JBLEN 9
 
175
#endif
 
176
 
 
177
#ifdef __TMS320C6X__
 
178
#define _JBLEN 13
 
179
#endif
 
180
 
 
181
#ifdef __TIC80__
 
182
#define _JBLEN 13
 
183
#endif
 
184
 
 
185
#ifdef __D10V__
 
186
#define _JBLEN 8
 
187
#endif
 
188
 
 
189
#ifdef __D30V__
 
190
#define _JBLEN ((64 /* GPR */ + (2*2) /* ACs */ + 18 /* CRs */) / 2)
 
191
#define _JBTYPE double
 
192
#endif
 
193
 
 
194
#ifdef __frv__
 
195
#define _JBLEN (68/2)  /* room for 68 32-bit regs */
 
196
#define _JBTYPE double
 
197
#endif
 
198
 
 
199
#ifdef __moxie__
 
200
#define _JBLEN 16
 
201
#endif
 
202
 
 
203
#ifdef __CRX__
 
204
#define _JBLEN 9
 
205
#endif
 
206
 
 
207
#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
 
208
/* r6, r7, r8, r9, r10, r11, r12 (r12L, r12H), 
 
209
 * r13 (r13L, r13H), ra(raL, raH), sp(spL, spH) */
 
210
#define _JBLEN 14
 
211
#define _JBTYPE unsigned short
 
212
#endif
 
213
 
 
214
#ifdef __fr30__
 
215
#define _JBLEN 10
 
216
#endif
 
217
 
 
218
#ifdef __iq2000__
 
219
#define _JBLEN 32
 
220
#endif
 
221
 
 
222
#ifdef __mcore__
 
223
#define _JBLEN 16
 
224
#endif
 
225
 
 
226
#ifdef __MMIX__
 
227
/* Using a layout compatible with GCC's built-in.  */
 
228
#define _JBLEN 5
 
229
#define _JBTYPE unsigned long
 
230
#endif
 
231
 
 
232
#ifdef __mt__
 
233
#define _JBLEN 16
 
234
#endif
 
235
 
 
236
#ifdef __SPU__
 
237
#define _JBLEN 50 
 
238
#define _JBTYPE __vector signed int
 
239
#endif
 
240
 
 
241
#ifdef __xstormy16__
 
242
/* 4 GPRs plus SP plus PC. */
 
243
#define _JBLEN 8
 
244
#endif
 
245
 
 
246
#ifdef __mep__
 
247
/* 16 GPRs, pc, hi, lo */
 
248
#define _JBLEN 19
 
249
#endif
 
250
 
 
251
#ifdef __CRIS__
 
252
#define _JBLEN 18
 
253
#endif
 
254
 
 
255
#ifdef __lm32__
 
256
#define _JBLEN 19
 
257
#endif
 
258
 
 
259
#ifdef __m32c__
 
260
#if defined(__r8c_cpu__) || defined(__m16c_cpu__)
 
261
#define _JBLEN (22/2)
 
262
#else
 
263
#define _JBLEN (34/2)
 
264
#endif
 
265
#define _JBTYPE unsigned short
 
266
#endif /* __m32c__ */
 
267
 
 
268
#ifdef __RX__
 
269
#define _JBLEN 0x44
 
270
#endif
 
271
 
 
272
#ifdef EMSCRIPTEN /* Not that this can actually work... */
 
273
#define _JBLEN 20
 
274
#define _JBTYPE unsigned short
 
275
#endif
 
276
 
 
277
#ifdef _JBLEN
 
278
#ifdef _JBTYPE
 
279
typedef _JBTYPE jmp_buf[_JBLEN];
 
280
#else
 
281
typedef int jmp_buf[_JBLEN];
 
282
#endif
 
283
#endif
 
284
 
 
285
_END_STD_C
 
286
 
 
287
#if defined(__CYGWIN__) || defined(__rtems__)
 
288
#include <signal.h>
 
289
 
 
290
#ifdef __cplusplus
 
291
extern "C" {
 
292
#endif
 
293
 
 
294
/* POSIX sigsetjmp/siglongjmp macros */
 
295
#ifdef _JBTYPE
 
296
typedef _JBTYPE sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (_JBTYPE))];
 
297
#else
 
298
typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
 
299
#endif
 
300
 
 
301
#define _SAVEMASK       _JBLEN
 
302
#define _SIGMASK        (_JBLEN+1)
 
303
 
 
304
#ifdef __CYGWIN__
 
305
# define _CYGWIN_WORKING_SIGSETJMP
 
306
#endif
 
307
 
 
308
#ifdef _POSIX_THREADS
 
309
#define __SIGMASK_FUNC pthread_sigmask
 
310
#else
 
311
#define __SIGMASK_FUNC sigprocmask
 
312
#endif
 
313
 
 
314
#if defined(__GNUC__)
 
315
 
 
316
#define sigsetjmp(env, savemask) \
 
317
            __extension__ \
 
318
            ({ \
 
319
              sigjmp_buf *_sjbuf = &(env); \
 
320
              ((*_sjbuf)[_SAVEMASK] = savemask,\
 
321
              __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
 
322
              setjmp (*_sjbuf)); \
 
323
            })
 
324
 
 
325
#define siglongjmp(env, val) \
 
326
            __extension__ \
 
327
            ({ \
 
328
              sigjmp_buf *_sjbuf = &(env); \
 
329
              ((((*_sjbuf)[_SAVEMASK]) ? \
 
330
               __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
 
331
               : 0), \
 
332
               longjmp (*_sjbuf, val)); \
 
333
            })
 
334
 
 
335
#else /* !__GNUC__ */
 
336
 
 
337
#define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
 
338
               __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
 
339
               setjmp (env))
 
340
 
 
341
#define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
 
342
               __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
 
343
               longjmp (env, val))
 
344
 
 
345
#endif
 
346
 
 
347
/* POSIX _setjmp/_longjmp, maintained for XSI compatibility.  These
 
348
   are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
 
349
   New applications should use sigsetjmp/siglongjmp instead. */
 
350
#ifdef __CYGWIN__
 
351
extern void _longjmp(jmp_buf, int);
 
352
extern int _setjmp(jmp_buf);
 
353
#else
 
354
#define _setjmp(env)            sigsetjmp ((env), 0)
 
355
#define _longjmp(env, val)      siglongjmp ((env), (val))
 
356
#endif
 
357
 
 
358
#ifdef __cplusplus
 
359
}
 
360
#endif
 
361
#endif /* __CYGWIN__ or __rtems__ */