Skip to main content

longjmp

Function longjmp 

Source
pub unsafe extern "C" fn longjmp(jbuf: JmpBuf, val: c_int) -> !
Expand description

Given a calling environment jbuf (which one can acquire via call_with_setjmp) and a non-zero value val, moves the stack and program counters to match the return position of where jbuf was established via a call to setjmp, and then returns val from that spot.

You should only provide non-zero values for val. A zero-value may or may not be replaced with a non-zero value for the return to the non-local jump environment, depending on the underlying C library that is linked in. (It may be silently replaced with a non-zero value, as a non-zero value is the only way for the internal machinery to distinguish between the first return from the initial call versus a non-local return).

FIXME: include safety note here, including the issues with destructors