home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / h / setjmp < prev    next >
Encoding:
Text File  |  2004-09-07  |  2.4 KB  |  87 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/setjmp.h,v $
  4.  * $Date: 2004/09/07 14:05:10 $
  5.  * $Revision: 1.11 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* ANSI Standard 4.6: Non-Local Jumps <setjmp.h>.  */
  12.  
  13. #ifndef __SETJMP_H
  14. #define __SETJMP_H
  15.  
  16. #ifndef __UNIXLIB_FEATURES_H
  17. #include <unixlib/features.h>
  18. #endif
  19.  
  20. #ifndef __UNIXLIB_TYPES_H
  21. #include <unixlib/types.h>
  22. #endif
  23.  
  24. __BEGIN_DECLS
  25.  
  26. /* Warning: if __JMP_BUF_SIZE is updated then lib1aof.s and riscos-{aof/elf}.h in
  27.    gcc/config/arm/ also need changing */
  28. #ifdef __JMP_BUF_SIZE
  29. #if __JMP_BUF_SIZE < 26
  30. #undef __JMP_BUF_SIZE
  31. #endif
  32. #endif
  33.  
  34. #ifndef __JMP_BUF_SIZE
  35. #define __JMP_BUF_SIZE 26
  36. #endif
  37.  
  38. typedef int jmp_buf[__JMP_BUF_SIZE];
  39.  
  40. /* Store the current execution state into env.  */
  41. extern int setjmp (jmp_buf __env) __THROW;
  42. /* Jump to the state saved in 'env'. The setjmp call that
  43.    created 'env' will then return 'val'.  If val is zero, then
  44.    setjmp will return 1. */
  45. extern void longjmp (jmp_buf __env, int __val)
  46.      __THROW __attribute__ ((__noreturn__));
  47.  
  48. /* We are in 4.3 BSD-compatibility mode in which `setjmp'
  49.    saves the signal mask like `sigsetjmp (ENV, 1)'.  We have to
  50.    define a macro since ISO C says `setjmp' is one.  */
  51. #define setjmp(env)    setjmp (env)
  52.  
  53. /* POSIX details.  */
  54.  
  55. /* Calling environment, plus possibly a saved signal mask.  */
  56. typedef struct sigjmp_buf_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.   int saved_currently_handling;
  64. } sigjmp_buf[1];
  65.  
  66.  
  67. /* Similar to setjmp. If save sigs is nonzero, the set of
  68.    blocked signals is saved in state and will be restored
  69.    if a siglongjmp is later performed with this state.  */
  70. extern int sigsetjmp (sigjmp_buf __state, int __savesigs) __THROW;
  71.  
  72. /* Jump to the environment saved in env, making the sigsetjmp
  73.    call there return val, or 1 if val is 0.  Restore the signal
  74.    mask if that sigsetjmp call saved it.  */
  75. extern void siglongjmp (const sigjmp_buf __env,
  76.             int __val) __THROW __attribute__ ((__noreturn__));
  77.  
  78. #ifdef __UNIXLIB_INTERNALS
  79. /* Internal functions.  */
  80. extern void __sigsetjmp_helper (sigjmp_buf __state, int __savesigs);
  81. extern void __siglongjmp_helper (const sigjmp_buf __state, int __savesigs);
  82. #endif
  83.  
  84. __END_DECLS
  85.  
  86. #endif
  87.