mostang.com!davidm | 824d661 | 2003-02-08 10:10:59 +0000 | [diff] [blame] | 1 | \documentclass{article} |
| 2 | \usepackage[fancyhdr,pdf]{latex2man} |
| 3 | |
| 4 | \input{common.tex} |
| 5 | |
| 6 | \begin{document} |
| 7 | |
| 8 | \begin{Name}{3}{libunwind-setjmp}{David Mosberger-Tang}{Programming Library}{libunwind-based non-local gotos} |
| 9 | libunwind-setjmp -- libunwind-based non-local gotos |
| 10 | \end{Name} |
| 11 | |
| 12 | \section{Synopsis} |
| 13 | |
| 14 | \File{\#include $<$setjmp.h$>$}\\ |
| 15 | |
| 16 | \noindent |
| 17 | \Type{int} \Func{setjmp}(\Type{jmp\_buf}~\Var{env});\\ |
| 18 | \Type{void} \Func{longjmp}(\Type{jmp\_buf}~\Var{env}, \Type{int}~\Var{val});\\ |
| 19 | \Type{int} \Func{\_setjmp}(\Type{jmp\_buf}~\Var{env});\\ |
| 20 | \Type{void} \Func{\_longjmp}(\Type{jmp\_buf}~\Var{env}, \Type{int}~\Var{val});\\ |
| 21 | \Type{int} \Func{setjmp}(\Type{sigjmp\_buf}~\Var{env}, \Type{int}~\Var{savemask});\\ |
| 22 | \Type{void} \Func{siglongjmp}(\Type{sigjmp\_buf}~\Var{env}, \Type{int}~\Var{val});\\ |
| 23 | |
| 24 | \section{Description} |
| 25 | |
| 26 | The \Prog{unwind-setjmp} library offers a \Prog{libunwind}-based |
| 27 | implementation of non-local gotos. This implementation is intended to |
| 28 | be a drop-in replacement for the normal, system-provided routines of |
| 29 | the same name. The main advantage of using the \Prog{unwind-setjmp} |
| 30 | library is that setting up a non-local goto via one of the |
| 31 | \Func{setjmp}() routines is very fast. Typically, just 2 or 3 words |
| 32 | need to be saved in the jump-buffer (plus one call to |
| 33 | \Func{sigprocmask}(2), in the case of \Func{sigsetjmp}). On the |
| 34 | other hand, executing a non-local goto by calling one of the |
| 35 | \Func{longjmp}() routines tends to be much slower than with the |
| 36 | system-provided routines. In fact, the time spent on a |
| 37 | \Func{longjmp}() will be proportional to the number of call frames |
| 38 | that exist between the points where \Func{setjmp}() and |
| 39 | \Func{longjmp}() were called. For this reason, the |
| 40 | \Prog{unwind-setjmp} library is beneficial primarily in applications |
| 41 | that frequently call \Func{setjmp}() but only rarely call |
| 42 | \Func{longjmp}(). |
| 43 | |
| 44 | \section{Caveats} |
| 45 | |
| 46 | \begin{itemize} |
| 47 | \item The correct operation of this library depends on the presence of |
| 48 | correct unwind information. On newer platforms, this is rarely an |
| 49 | issue. On older platforms, care needs to be taken to |
| 50 | ensure that each of the functions whose stack frames may have to be |
| 51 | unwound during a \Func{longjmp}() have correct unwind information |
| 52 | (on those platforms, there is usually a compiler-switch, such as |
| 53 | \Opt{-funwind-tables}, to request the generation of unwind |
| 54 | information). |
| 55 | \item The contents of \Type{jmp\_buf} and \Type{sigjmp\_buf} as setup |
| 56 | and used by these routines is completely different from the ones |
| 57 | used by the system-provided routines. Thus, a jump-buffer created |
| 58 | by the libunwind-based \Func{setjmp}()/\Func{\_setjmp} may only be |
| 59 | used in a call to the libunwind-based |
| 60 | \Func{longjmp}()/\Func{\_longjmp}(). The analogous applies for |
| 61 | \Type{sigjmp\_buf} with \Func{sigsetjmp}() and \Func{siglongjmp}(). |
| 62 | \end{itemize} |
| 63 | |
| 64 | \section{Files} |
| 65 | |
| 66 | \begin{Description} |
| 67 | \item[\Opt{-l}\File{unwind-setjmp}] The library an application should |
| 68 | be linked against to ensure it uses the libunwind-based non-local |
| 69 | goto routines. |
| 70 | \end{Description} |
| 71 | |
| 72 | |
| 73 | \section{See Also} |
| 74 | |
| 75 | \SeeAlso{libunwind(3)}, |
| 76 | setjmp(3), longjmp(3), |
| 77 | \_setjmp(3), \_longjmp(3), |
| 78 | sigsetjmp(3), siglongjmp(3) |
| 79 | |
| 80 | \section{Author} |
| 81 | |
| 82 | \noindent |
| 83 | David Mosberger-Tang\\ |
| 84 | Hewlett-Packard Labs\\ |
| 85 | Palo-Alto, CA 94304\\ |
| 86 | Email: \Email{davidm@hpl.hp.com}\\ |
| 87 | WWW: \URL{http://www.hpl.hp.com/research/linux/libunwind/}. |
| 88 | \LatexManEnd |
| 89 | |
| 90 | \end{document} |