| <head> |
| <title>setjmp(3) - Plan 9 from User Space</title> |
| <meta content="text/html; charset=utf-8" http-equiv=Content-Type> |
| </head> |
| <body bgcolor=#ffffff> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=10><td> |
| <tr><td width=20><td> |
| <tr><td width=20><td><b>SETJMP(3)</b><td align=right><b>SETJMP(3)</b> |
| <tr><td width=20><td colspan=2> |
| <br> |
| <p><font size=+1><b>NAME </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| setjmp, longjmp, notejmp – non-local goto<br> |
| |
| </table> |
| <p><font size=+1><b>SYNOPSIS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>#include <u.h><br> |
| #include <libc.h> |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>int setjmp(jmp_buf env) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void longjmp(jmp_buf env, int val) |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| </font></tt> |
| <tt><font size=+1>void notejmp(void *uregs, jmp_buf env, int val)<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>DESCRIPTION </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| These routines are useful for dealing with errors and interrupts |
| encountered in a low-level subroutine of a program. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Setjmp</i> saves its stack environment in <i>env</i> for later use by <i>longjmp</i>. |
| It returns value 0. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Longjmp</i> restores the environment saved by the last call of <i>setjmp</i>. |
| It then causes execution to continue as if the call of <i>setjmp</i> |
| had just returned with value <i>val</i>. The invoker of <i>setjmp</i> must not |
| itself have returned in the interim. All accessible data have |
| values as of the time <i>longjmp</i> was called. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Notejmp</i> is the same as <i>longjmp</i> except that it is to be called |
| from within a note handler (see <a href="../man3/notify.html"><i>notify</i>(3)</a>). The <i>uregs</i> argument |
| should be the first argument passed to the note handler. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>Setjmp</i> and <i>longjmp</i> can also be used to switch stacks.<br> |
| |
| </table> |
| <p><font size=+1><b>SOURCE </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <tt><font size=+1>/usr/local/plan9/src/lib9/jmp.c<br> |
| </font></tt> |
| </table> |
| <p><font size=+1><b>SEE ALSO </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <a href="../man3/notify.html"><i>notify</i>(3)</a><br> |
| |
| </table> |
| <p><font size=+1><b>BUGS </b></font><br> |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| |
| <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td> |
| |
| <i>Notejmp</i> cannot recover from an address trap or bus error (page |
| fault) on the 680x0 architectures. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| To avoid name conflicts with the underlying system, <i>setjmp</i>, <i>longjmp</i>, |
| <i>notejmp</i>, and <i>jmp_buf</i> are preprocessor macros defined as <i>p9setjmp</i>, |
| <i>p9longjmp</i>, <i>p9notejmp</i>, and <i>p9jmp_buf</i>; see <a href="../man3/intro.html"><i>intro</i>(3)</a>. |
| <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table> |
| |
| <i>P9setjmp</i> is implemented as a preprocessor macro that calls <i>sigsetjmp</i> |
| (see Unix’s <i>setjmp</i>(3)).<br> |
| |
| </table> |
| |
| <td width=20> |
| <tr height=20><td> |
| </table> |
| <!-- TRAILER --> |
| <table border=0 cellpadding=0 cellspacing=0 width=100%> |
| <tr height=15><td width=10><td><td width=10> |
| <tr><td><td> |
| <center> |
| <a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a> |
| </center> |
| </table> |
| <!-- TRAILER --> |
| </body></html> |