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