HP 3000 Manuals

Calling Trap Intrinsics [ HP C/iX Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Reference Manual

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 );
     }



MPE/iX 5.0 Documentation