home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / unix / unixlib_1 / !UnixLib37_src_clib_h_setjmp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-09  |  2.1 KB  |  89 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/h/RCS/setjmp,v $
  4.  * $Date: 1996/10/30 21:58:58 $
  5.  * $Revision: 1.2 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: setjmp,v $
  10.  * Revision 1.2  1996/10/30 21:58:58  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.1  1996/04/19 21:02:57  simon
  14.  * Initial revision
  15.  *
  16.  ***************************************************************************/
  17.  
  18. /* ANSI Standard 4.6: Non-Local Jumps <setjmp.h>.  */
  19.  
  20. #ifndef __SETJMP_H
  21. #define __SETJMP_H
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27. #ifdef __JMP_BUF_SIZE
  28. #if __JMP_BUF_SIZE < 23
  29. #undef __JMP_BUF_SIZE
  30. #endif
  31. #endif
  32.  
  33. #ifndef __JMP_BUF_SIZE
  34. #define __JMP_BUF_SIZE 23
  35. #endif
  36.  
  37. typedef int jmp_buf[__JMP_BUF_SIZE];
  38.  
  39. /* See Norcroft setjmp.h for reason */
  40. #ifdef __STDC__
  41. /* -pcc mode doesn't allow circular definitions... */
  42. #define setjmp(jmp_buf) (setjmp(jmp_buf))
  43. #endif
  44.  
  45. extern int setjmp (jmp_buf);
  46. extern void longjmp (jmp_buf,int);
  47.  
  48. #if 0
  49.  
  50. /* POSIX details.  */
  51. #ifndef __SIGNAL_H
  52. #include <signal.h>
  53. #endif
  54.  
  55. /* Calling environment, plus possibly a saved signal mask.  */
  56. typedef struct
  57. {
  58.   /* Calling environment.  */
  59.   jmp_buf __jmpbuf;
  60.   /* Saved the signal mask ? */
  61.   int __mask_was_saved;
  62.   sigset_t saved_mask;
  63. } sigjmp_buf[1];
  64.  
  65. /* Store the calling environment in env, also saving the
  66.    signal mask if savemask is nonzero.  */
  67. extern void __sigjmp_save (sigjmp_buf env, int savemask);
  68.  
  69. /* Similar to setjmp. If save sigs is nonzero, the set of
  70.    blocked signals is saved in state and will be restored
  71.    if a siglongjmp is later performed with this state.  */
  72. extern int sigsetjmp (sigjmp_buf state, int savesigs);
  73.  
  74. #define sigsetjmp(env, savemask) \
  75.   (__sigjmp_save ((env), (savemask)), setjmp ((env)[0].__jmpbuf))
  76.  
  77. /* Jump to the environment saved in env, making the sigsetjmp
  78.    call there return val, or 1 if val is 0.  Restore the signal
  79.    mask if that sigsetjmp call saved it.  */
  80. extern void siglongjmp (const sigjmp_buf env, int val);
  81.  
  82. #endif
  83.  
  84. #ifdef __cplusplus
  85.     }
  86. #endif
  87.  
  88. #endif
  89.