sl@0: /** @file ../include/setjmp.h sl@0: @internalComponent sl@0: */ sl@0: sl@0: /** @fn longjmp(jmp_buf __jmpb, int __retval) sl@0: @param __jmpb sl@0: @param __retval sl@0: sl@0: Refer to setjmp() for the documentation sl@0: sl@0: sl@0: sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @fn setjmp(jmp_buf __jmpb) sl@0: @param __jmpb sl@0: sl@0: Note: This description also covers the following functions - sl@0: longjmp() _setjmp() _longjmp() sl@0: sl@0: @return If the return is from a direct invocation, the setjmp function returns 0. If the return is from a call to longjmp(), sl@0: setjmp() returns a non-zero value. sl@0: After the longjmp is completed, program execution continues as if sl@0: the corresponding invocation of setjmp() had just returned the sl@0: value specified by __retval. If __retval is 0, setjmp() returns 1. sl@0: sl@0: The setjmp, and _setjmp functions save their calling environment in __jmpb. Each of these functions returns 0. sl@0: sl@0: The corresponding longjmp functions restore the environment saved by their most recent respective sl@0: invocations sl@0: of the setjmp function. sl@0: They then return so that program execution continues as if the corresponding sl@0: invocation of the setjmp call had just returned the value specified by __retval, instead of 0. sl@0: sl@0: The longjmp routines may not be called after the routine which called the setjmp routines returns. sl@0: sl@0: All accessible objects have values as of the time longjmp routine was called, except that the values of objects of automatic storage sl@0: invocation duration that do not have the volatile sl@0: type and have been changed between the setjmp invocation and longjmp call are indeterminate. sl@0: sl@0: The setjmp / longjmp pairs save and restore the signal mask while _setjmp / _longjmp pairs save and restore only the register set and the stack. sl@0: sl@0: Examples: sl@0: @code sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: static void f1( int, int, int ); sl@0: static void f2( void ); sl@0: static jmp_buf jmpbuffer; sl@0: sl@0: int main() sl@0: { sl@0: int count; sl@0: register int val; sl@0: volatile int sum; sl@0: sl@0: count = 2; val = 3; sum = 4; sl@0: sl@0: if ( setjmp( jmpbuffer ) != 0 ) sl@0: { sl@0: printf("in main: count = %d, val = %d, sum = %d sl@0: ", count, val, sum ); sl@0: exit(0); sl@0: } sl@0: sl@0: f1(97, 98, 99 ); sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: static void f1 (int i, int j, int k ) sl@0: { sl@0: printf("in f1: count = %d, val = %d, sum = %d sl@0: ", i, j , k ); sl@0: f2(); sl@0: } sl@0: sl@0: static void f2( void ) sl@0: { sl@0: longjmp( jmpbuffer, 1 ); sl@0: } sl@0: sl@0: @endcode sl@0: Output sl@0: @code sl@0: in f1: count = 97, val = 98, sum = 99 sl@0: in main: count = 2, val = 3, sum = 4 sl@0: sl@0: @endcode sl@0: sl@0: Limitations: sl@0: sl@0: The signal related functionalities aren't applicable to the Symbian sl@0: OS implementation as there is no support for signals. This means that the setjmp and _setjmp routines have the same functionality and so do longjmp and _longjmp . sl@0: sl@0: sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: sl@0: /** @def _setjmp sl@0: sl@0: The _longjmp() and _setjmp() functions shall be equivalent to longjmp() and setjmp(), respectively, with the additional restriction that _longjmp() and _setjmp() shall not manipulate the signal mask. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */ sl@0: sl@0: /** @def _longjmp sl@0: sl@0: The _longjmp() and _setjmp() functions shall be equivalent to longjmp() and setjmp(), respectively, with the additional restriction that _longjmp() and _setjmp() shall not manipulate the signal mask. sl@0: sl@0: @publishedAll sl@0: @externallyDefinedApi sl@0: */