Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  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 _JBLEN
  273. #ifdef _JBTYPE
  274. typedef _JBTYPE jmp_buf[_JBLEN];
  275. #else
  276. typedef int jmp_buf[_JBLEN];
  277. #endif
  278. #endif
  279.  
  280. _END_STD_C
  281.  
  282. #if defined(__CYGWIN__) || defined(__rtems__)
  283. #include <signal.h>
  284.  
  285. #ifdef __cplusplus
  286. extern "C" {
  287. #endif
  288.  
  289. /* POSIX sigsetjmp/siglongjmp macros */
  290. #ifdef _JBTYPE
  291. typedef _JBTYPE sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (_JBTYPE))];
  292. #else
  293. typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
  294. #endif
  295.  
  296. #define _SAVEMASK       _JBLEN
  297. #define _SIGMASK        (_JBLEN+1)
  298.  
  299. #ifdef __CYGWIN__
  300. # define _CYGWIN_WORKING_SIGSETJMP
  301. #endif
  302.  
  303. #ifdef _POSIX_THREADS
  304. #define __SIGMASK_FUNC pthread_sigmask
  305. #else
  306. #define __SIGMASK_FUNC sigprocmask
  307. #endif
  308.  
  309. #if defined(__GNUC__)
  310.  
  311. #define sigsetjmp(env, savemask) \
  312.             __extension__ \
  313.             ({ \
  314.               sigjmp_buf *_sjbuf = &(env); \
  315.               ((*_sjbuf)[_SAVEMASK] = savemask,\
  316.               __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
  317.               setjmp (*_sjbuf)); \
  318.             })
  319.  
  320. #define siglongjmp(env, val) \
  321.             __extension__ \
  322.             ({ \
  323.               sigjmp_buf *_sjbuf = &(env); \
  324.               ((((*_sjbuf)[_SAVEMASK]) ? \
  325.                __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
  326.                : 0), \
  327.                longjmp (*_sjbuf, val)); \
  328.             })
  329.  
  330. #else /* !__GNUC__ */
  331.  
  332. #define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
  333.                __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
  334.                setjmp (env))
  335.  
  336. #define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
  337.                __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
  338.                longjmp (env, val))
  339.  
  340. #endif
  341.  
  342. /* POSIX _setjmp/_longjmp, maintained for XSI compatibility.  These
  343.    are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
  344.    New applications should use sigsetjmp/siglongjmp instead. */
  345. #ifdef __CYGWIN__
  346. extern void _longjmp(jmp_buf, int);
  347. extern int _setjmp(jmp_buf);
  348. #else
  349. #define _setjmp(env)            sigsetjmp ((env), 0)
  350. #define _longjmp(env, val)      siglongjmp ((env), (val))
  351. #endif
  352.  
  353. #ifdef __cplusplus
  354. }
  355. #endif
  356. #endif /* __CYGWIN__ or __rtems__ */
  357.