TNS/E Native Application Conversion Guide
C and C++ Conversion Tasks
TNS/E Native Application Conversion Guide—529659-003
3-12
Using the setjmp() and longjmp() Functions
Using the setjmp() and longjmp() Functions
Calling the setjmp() function in a function marked as inline and then doing a
subsequent longjmp() to the location of the calling function is a practice that should
be avoided. Programs that use setjmp() and longjmp() in this way generally
expect that functions marked as inline are actually inlined, and that the longjmp()
call will restore the execution context of the function that called setjmp(). In TNS
programs compiled at optimization level 0, this is sometimes the case and the
longmp() call might work as expected. But in a TNS/E native program compiled at
optimization level 0, functions marked as inline are never actually inlined, and the
longjmp() call will not work as expected. A preferred practice is to use a macro
instead of an inline function.
Using the semctl() Function
The semctl() function has an optional fourth parameter that is required in certain
cases. As described in the
Open System Services System Calls Reference Manual
,
the value passed in that parameter must be defined in the calling program as a semun
union, as in this example:
union semun {
int
val
;
struct semid_ds *
buf
;
unsigned short int *
array
;
}
arg
union semun semopts;
semopts.val = 1;
if (semctl(semid, 0, SETVAL, semopts) ==-1)
On TNS/R systems, you can also pass a value directly, without the use of the semun
union (for example, as a simple scalar), as in this example:
if (semctl(semid, 0, SETVAL, 1) ==1)
A value passed in this way gives the expected results.
However, on TNS/E systems, you must define the parameter value as a semun union.
Code that does not do so will not function as expected.










