|AVR Libc Home Page||AVR Libc Development Pages|
|Main Page||User Manual||Library Reference||FAQ||Alphabetical Index||Example Projects|
|int||setjmp (jmp_buf __jmpb)|
|void||longjmp (jmp_buf __jmpb, int __ret) __ATTR_NORETURN__|
While the C language has the dreaded
goto statement, it can only be used to jump to a label in the same (local) function. In order to jump directly to another (non-local) function, the C library provides the setjmp() and longjmp() functions. setjmp() and longjmp() are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program.
For a very detailed discussion of setjmp()/longjmp(), see Chapter 7 of Advanced Programming in the UNIX Environment, by W. Richard Stevens.
Non-local jump to a saved stack context.
longjmp() restores the environment saved by the last call of setjmp() with the corresponding __jmpb argument. After longjmp() is completed, program execution continues as if the corresponding call of setjmp() had just returned the value __ret.
|__jmpb||Information saved by a previous call to setjmp().|
|__ret||Value to return to the caller of setjmp().|
Save stack context for non-local goto.
|__jmpb||Variable of type |