![Symbian Developer Library](../../../../a_stock/images/mainheading.gif)
![]() |
![]() |
|
Interface status: | externallyDefinedApi |
_setjmp setjmp
The _longjmp
and _setjmp
functions shall be equivalent to longjmp(jmp_buf,int)
longjmp(jmp_buf,int)
and setjmp(jmp_buf)
setjmp(jmp_buf)
, respectively, with the additional restriction that _longjmp
and _setjmp
shall not manipulate the signal mask.
Interface status: | externallyDefinedApi |
_longjmp longjmp
The _longjmp
and _setjmp
functions shall be equivalent to longjmp(jmp_buf,int)
longjmp(jmp_buf,int)
and setjmp(jmp_buf)
setjmp(jmp_buf)
, respectively, with the additional restriction that _longjmp
and _setjmp
shall not manipulate the signal mask.
Interface status: | externallyDefinedApi |
IMPORT_C void longjmp(jmp_buf, int);
|
Interface status: | externallyDefinedApi |
IMPORT_C int setjmp(jmp_buf);
The setjmp, and _setjmp functions save their calling environment in __jmpb. Each of these functions returns 0.
The corresponding longjmp functions restore the environment saved by their most recent respective invocations of the setjmp function. They then return so that program execution continues as if the corresponding invocation of the setjmp call had just returned the value specified by __retval, instead of 0.
The longjmp routines may not be called after the routine which called the setjmp routines returns.
All accessible objects have values as of the time longjmp routine was called, except that the values of objects of automatic storage invocation duration that do not have the volatile type and have been changed between the setjmp invocation and longjmp call are indeterminate.
The setjmp / longjmp pairs save and restore the signal mask while _setjmp / _longjmp pairs save and restore only the register set and the stack.
Examples:
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
static void f1( int, int, int );
static void f2( void );
static jmp_buf jmpbuffer;
int main()
{
int count;
register int val;
volatile int sum;
count = 2; val = 3; sum = 4;
if ( setjmp( jmpbuffer ) != 0 )
{
printf("in main: count = %d, val = %d, sum = %d
", count, val, sum );
exit(0);
}
f1(97, 98, 99 );
return 0;
}
static void f1 (int i, int j, int k )
{
printf("in f1: count = %d, val = %d, sum = %d
", i, j , k );
f2();
}
static void f2( void )
{
longjmp( jmpbuffer, 1 );
}
Output
in f1: count = 97, val = 98, sum = 99
in main: count = 2, val = 3, sum = 4
Limitations:
The signal related functionalities aren't applicable to the Symbian 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 .
|
|