82dd41fb80604fadc6f34ceacd64541844542953
[platform/upstream/bash.git] / bashjmp.h
1 /* bashjmp.h -- wrapper for setjmp.h with necessary bash definitions. */
2
3 #ifndef _BASHJMP_H_
4 #define _BASHJMP_H_
5
6 #include <setjmp.h>
7
8 /* This *must* be included *after* config.h */
9
10 #if defined (HAVE_POSIX_SIGSETJMP)
11 #  define procenv_t     sigjmp_buf
12 #  undef setjmp
13 #  define setjmp(x)     sigsetjmp((x), 1)
14 #  undef longjmp
15 #  define longjmp(x, n) siglongjmp((x), (n))
16 #else
17 #  define procenv_t     jmp_buf
18 #endif
19
20 extern procenv_t        top_level;
21 extern procenv_t        subshell_top_level;
22 extern procenv_t        return_catch;   /* used by `return' builtin */
23
24 #define SHFUNC_RETURN() longjmp (return_catch, 1)
25
26 #define COPY_PROCENV(old, save) \
27         xbcopy ((char *)old, (char *)save, sizeof (procenv_t));
28
29 /* Values for the second argument to longjmp/siglongjmp. */
30 #define NOT_JUMPED 0            /* Not returning from a longjmp. */
31 #define FORCE_EOF 1             /* We want to stop parsing. */
32 #define DISCARD 2               /* Discard current command. */
33 #define EXITPROG 3              /* Unconditionally exit the program now. */
34
35 #endif /* _BASHJMP_H_ */