選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

473 行
9.3KB

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