1LIBUNWIND-SETJMP(3)          Programming Library           LIBUNWIND-SETJMP(3)
2
3
4

NAME

6       libunwind-setjmp -- libunwind-based non-local gotos
7

SYNOPSIS

9       #include <setjmp.h>
10
11       int setjmp(jmp_buf env);
12       void longjmp(jmp_buf env, int val);
13       int _setjmp(jmp_buf env);
14       void _longjmp(jmp_buf env, int val);
15       int sigsetjmp(sigjmp_buf env, int savemask);
16       void siglongjmp(sigjmp_buf env, int val);
17

DESCRIPTION

19       The  unwind-setjmp  library  offers a libunwind-based implementation of
20       non-local gotos. This  implementation  is  intended  to  be  a  drop-in
21       replacement  for the normal, system-provided routines of the same name.
22       The main advantage of using the unwind-setjmp library is  that  setting
23       up a non-local goto via one of the setjmp() routines is very fast. Typ‐
24       ically, just 2 or 3 words need to be saved in the jump-buffer (plus one
25       call  to sigprocmask(2), in the case of sigsetjmp).  On the other hand,
26       executing a non-local goto by calling one  of  the  longjmp()  routines
27       tends  to  be  much  slower  than with the system-provided routines. In
28       fact, the time spent on a longjmp() will be proportional to the  number
29       of  call  frames  that  exist  between  the  points  where setjmp() and
30       longjmp() were called. For this reason, the  unwind-setjmp  library  is
31       beneficial  primarily in applications that frequently call setjmp() but
32       only rarely call longjmp().
33

CAVEATS

35       *      The correct operation of this library depends on the presence of
36              correct  unwind  information. On newer platforms, this is rarely
37              an issue. On older platforms, care needs to be taken  to  ensure
38              that  each  of  the  functions whose stack frames may have to be
39              unwound during a longjmp() have correct unwind  information  (on
40              those  platforms,  there  is  usually a compiler-switch, such as
41              -funwind-tables, to request the generation  of  unwind  informa‐
42              tion).
43
44       *      The  contents  of  jmp_buf  and  sigjmp_buf as setup and used by
45              these routines is completely different from the ones used by the
46              system-provided  routines.  Thus,  a  jump-buffer created by the
47              libunwind-based setjmp()/_setjmp may only be used in a  call  to
48              the libunwind-based longjmp()/_longjmp().  The analogous applies
49              for sigjmp_buf with sigsetjmp() and siglongjmp().
50

FILES

52       -lunwind-setjmp
53               The library an application should be linked against  to  ensure
54              it uses the libunwind-based non-local goto routines.
55

SEE ALSO

57       libunwind(3),    setjmp(3),    longjmp(3),   _setjmp(3),   _longjmp(3),
58       sigsetjmp(3), siglongjmp(3)
59

AUTHOR

61       David Mosberger-Tang
62       Email: dmosberger@gmail.com
63       WWW: http://www.nongnu.org/libunwind/.
64
65
66
67Programming Library             16 August 2007             LIBUNWIND-SETJMP(3)
Impressum