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