Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <setjmp.h>
Link against: libc.lib

_setjmp

Interface status: externallyDefinedApi

_setjmp setjmp

Description

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.

[Top]


_longjmp

Interface status: externallyDefinedApi

_longjmp longjmp

Description

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.

[Top]


longjmp(jmp_buf,int)

Interface status: externallyDefinedApi

IMPORT_C void longjmp(jmp_buf, int);

Description

Parameters

jmp_bufjmp_buf

int

Refer to setjmp(jmp_buf)setjmp(jmp_buf) for the documentation

[Top]


setjmp(jmp_buf)

Interface status: externallyDefinedApi

IMPORT_C int setjmp(jmp_buf);

Description

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 .

Parameters

jmp_bufjmp_buf

Note: This description also covers the following functions - longjmp(jmp_buf,int)longjmp(jmp_buf,int) _setjmp _longjmp

Return value

int

If the return is from a direct invocation, the setjmp function returns 0. If the return is from a call to longjmp(jmp_buf,int)longjmp(jmp_buf,int), setjmp(jmp_buf)setjmp(jmp_buf) returns a non-zero value. After the longjmp is completed, program execution continues as if the corresponding invocation of setjmp(jmp_buf)setjmp(jmp_buf) had just returned the value specified by __retval. If __retval is 0, setjmp(jmp_buf)setjmp(jmp_buf) returns 1.