HP C/iX Reference Manual (31506-90011)
180 Chapter10
Using Intrinsics
Calling Trap Intrinsics
Calling Trap Intrinsics
The MPE/iX trap intrinsics often require a plabel parameter that is either by value or by
reference. The HP C/iX implementation of plabel is simply the "pointer to function" type.
Whenever a function pointer is used, the compiler is actually generating a plabel. Since
plabel is not a basic data type across languages, and other languages do not support the
integer value zero as a valid null pointer, the intrinsic mechanism describes plabels as
integers in both the documentation and SYSINTR file. This means that a cast must be
applied to the plabel parameters for trap intrinsics that are called from C, or the compiler
issues an error. Remember that using a function name in a context other than a function
call yields "pointer to function."
Example
#pragma intrinsic XCONTRAP
#include <stdio.h>
void func1(void)
{
printf("control-Y was hit\n");
}
main(void)
{
void (*oldfunc1)();
/* First parm is plabel by value, */
/* second plabel is by reference. */
XCONTRAP( (int)func1, (int*)&oldfunc1 );
}