Subversion Repositories Kolibri OS

Rev

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. #ifdef __fr30__
  208. #define _JBLEN 10
  209. #endif
  210.  
  211. #ifdef __iq2000__
  212. #define _JBLEN 32
  213. #endif
  214.  
  215. #ifdef __mcore__
  216. #define _JBLEN 16
  217. #endif
  218.  
  219. #ifdef __MMIX__
  220. /* Using a layout compatible with GCC's built-in.  */
  221. #define _JBLEN 5
  222. #define _JBTYPE unsigned long
  223. #endif
  224.  
  225. #ifdef __mt__
  226. #define _JBLEN 16
  227. #endif
  228.  
  229. #ifdef __SPU__
  230. #define _JBLEN 50
  231. #define _JBTYPE __vector signed int
  232. #endif
  233.  
  234. #ifdef __xstormy16__
  235. /* 4 GPRs plus SP plus PC. */
  236. #define _JBLEN 8
  237. #endif
  238.  
  239. #ifdef __mep__
  240. /* 16 GPRs, pc, hi, lo */
  241. #define _JBLEN 19
  242. #endif
  243.  
  244. #ifdef __CRIS__
  245. #define _JBLEN 18
  246. #endif
  247.  
  248. #ifdef __lm32__
  249. #define _JBLEN 19
  250. #endif
  251.  
  252. #ifdef __m32c__
  253. #if defined(__r8c_cpu__) || defined(__m16c_cpu__)
  254. #define _JBLEN (22/2)
  255. #else
  256. #define _JBLEN (34/2)
  257. #endif
  258. #define _JBTYPE unsigned short
  259. #endif /* __m32c__ */
  260.  
  261. #ifdef __RX__
  262. #define _JBLEN 0x44
  263. #endif
  264.  
  265. #ifdef _JBLEN
  266. #ifdef _JBTYPE
  267. typedef _JBTYPE jmp_buf[_JBLEN];
  268. #else
  269. typedef int jmp_buf[_JBLEN];
  270. #endif
  271. #endif
  272.  
  273. _END_STD_C
  274.  
  275. #if defined(__CYGWIN__) || defined(__rtems__)
  276. #include <signal.h>
  277.  
  278. #ifdef __cplusplus
  279. extern "C" {
  280. #endif
  281.  
  282. /* POSIX sigsetjmp/siglongjmp macros */
  283. #ifdef _JBTYPE
  284. typedef _JBTYPE sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (_JBTYPE))];
  285. #else
  286. typedef int sigjmp_buf[_JBLEN+1+(sizeof (sigset_t)/sizeof (int))];
  287. #endif
  288.  
  289. #define _SAVEMASK       _JBLEN
  290. #define _SIGMASK        (_JBLEN+1)
  291.  
  292. #ifdef __CYGWIN__
  293. # define _CYGWIN_WORKING_SIGSETJMP
  294. #endif
  295.  
  296. #ifdef _POSIX_THREADS
  297. #define __SIGMASK_FUNC pthread_sigmask
  298. #else
  299. #define __SIGMASK_FUNC sigprocmask
  300. #endif
  301.  
  302. #if defined(__GNUC__)
  303.  
  304. #define sigsetjmp(env, savemask) \
  305.             __extension__ \
  306.             ({ \
  307.               sigjmp_buf *_sjbuf = &(env); \
  308.               ((*_sjbuf)[_SAVEMASK] = savemask,\
  309.               __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *)((*_sjbuf) + _SIGMASK)),\
  310.               setjmp (*_sjbuf)); \
  311.             })
  312.  
  313. #define siglongjmp(env, val) \
  314.             __extension__ \
  315.             ({ \
  316.               sigjmp_buf *_sjbuf = &(env); \
  317.               ((((*_sjbuf)[_SAVEMASK]) ? \
  318.                __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *)((*_sjbuf) + _SIGMASK), 0)\
  319.                : 0), \
  320.                longjmp (*_sjbuf, val)); \
  321.             })
  322.  
  323. #else /* !__GNUC__ */
  324.  
  325. #define sigsetjmp(env, savemask) ((env)[_SAVEMASK] = savemask,\
  326.                __SIGMASK_FUNC (SIG_SETMASK, 0, (sigset_t *) ((env) + _SIGMASK)),\
  327.                setjmp (env))
  328.  
  329. #define siglongjmp(env, val) ((((env)[_SAVEMASK])?\
  330.                __SIGMASK_FUNC (SIG_SETMASK, (sigset_t *) ((env) + _SIGMASK), 0):0),\
  331.                longjmp (env, val))
  332.  
  333. #endif
  334.  
  335. /* POSIX _setjmp/_longjmp, maintained for XSI compatibility.  These
  336.    are equivalent to sigsetjmp/siglongjmp when not saving the signal mask.
  337.    New applications should use sigsetjmp/siglongjmp instead. */
  338. #ifdef __CYGWIN__
  339. extern void _longjmp(jmp_buf, int);
  340. extern int _setjmp(jmp_buf);
  341. #else
  342. #define _setjmp(env)            sigsetjmp ((env), 0)
  343. #define _longjmp(env, val)      siglongjmp ((env), (val))
  344. #endif
  345.  
  346. #ifdef __cplusplus
  347. }
  348. #endif
  349. #endif /* __CYGWIN__ or __rtems__ */
  350.