libunwind-setjmp.tex 3.2 KB

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