rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 1 | .TH SETJMP 3 |
| 2 | .SH NAME |
| 3 | setjmp, longjmp, notejmp \- non-local goto |
| 4 | .SH SYNOPSIS |
| 5 | .B #include <u.h> |
| 6 | .br |
| 7 | .B #include <libc.h> |
| 8 | .PP |
| 9 | .ta \w'\fLvoid 'u |
| 10 | .B |
| 11 | int setjmp(jmp_buf env) |
| 12 | .PP |
| 13 | .B |
| 14 | void longjmp(jmp_buf env, int val) |
| 15 | .PP |
| 16 | .B |
| 17 | void notejmp(void *uregs, jmp_buf env, int val) |
| 18 | .SH DESCRIPTION |
| 19 | These routines are useful for dealing with errors |
| 20 | and interrupts encountered in |
| 21 | a low-level subroutine of a program. |
| 22 | .PP |
| 23 | .I Setjmp |
| 24 | saves its stack environment in |
| 25 | .I env |
| 26 | for later use by |
| 27 | .IR longjmp . |
| 28 | It returns value 0. |
| 29 | .PP |
| 30 | .I Longjmp |
| 31 | restores the environment saved by the last call of |
| 32 | .IR setjmp . |
| 33 | It then causes execution to |
| 34 | continue as if the call of |
| 35 | .I setjmp |
| 36 | had just returned with value |
| 37 | .IR val . |
| 38 | The invoker of |
| 39 | .I setjmp |
| 40 | must not itself have returned in the interim. |
| 41 | All accessible data have values as of the time |
| 42 | .I longjmp |
| 43 | was called. |
| 44 | .PP |
| 45 | .I Notejmp |
| 46 | is the same as |
| 47 | .I longjmp |
| 48 | except that it is to be called from within a note handler (see |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 49 | .IR notify (3)). |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 50 | The |
| 51 | .I uregs |
| 52 | argument should be the first argument passed to the note handler. |
| 53 | .PP |
| 54 | .I Setjmp |
| 55 | and |
| 56 | .I longjmp |
| 57 | can also be used to switch stacks. |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 58 | .SH SOURCE |
rsc | c3674de | 2005-01-11 17:37:33 +0000 | [diff] [blame] | 59 | .B \*9/src/lib9/jmp.c |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 60 | .SH SEE ALSO |
rsc | bf8a59f | 2004-04-11 03:42:27 +0000 | [diff] [blame] | 61 | .IR notify (3) |
rsc | cfa37a7 | 2004-04-10 18:53:55 +0000 | [diff] [blame] | 62 | .SH BUGS |
| 63 | .PP |
| 64 | .I Notejmp |
| 65 | cannot recover from an address trap or bus error (page fault) on the 680x0 |
| 66 | architectures. |
rsc | c8b6342 | 2005-01-13 04:49:19 +0000 | [diff] [blame] | 67 | .PP |
| 68 | To avoid name conflicts with the underlying system, |
| 69 | .IR setjmp , |
| 70 | .IR longjmp , |
| 71 | .IR notejmp , |
| 72 | and |
| 73 | .I jmp_buf |
| 74 | are preprocessor macros defined as |
| 75 | .IR p9setjmp , |
| 76 | .IR p9longjmp , |
| 77 | .IR p9notejmp , |
| 78 | and |
| 79 | .IR p9jmp_buf ; |
| 80 | see |
| 81 | .IR intro (3). |
| 82 | .PP |
| 83 | .I P9setjmp |
| 84 | is implemented as a preprocessor macro that calls |
| 85 | .I sigsetjmp |
| 86 | (see |
| 87 | Unix's \fIsetjmp\fR(3)). |