libunwind-setjmp -- libunwind-based non-local gotos


#include <setjmp.h>

int setjmp(jmp_buf env);
void longjmp(jmp_buf env, int val);
int _setjmp(jmp_buf env);
void _longjmp(jmp_buf env, int val);
int sigsetjmp(sigjmp_buf env, int savemask);
void siglongjmp(sigjmp_buf env, int val);


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



The library an application should be linked against to ensure it uses the libunwind-based non-local goto routines.

See Also

libunwind(3), setjmp(3), longjmp(3), _setjmp(3), _longjmp(3), sigsetjmp(3), siglongjmp(3)


David Mosberger-Tang