Is there an ANSI C or GNU C equivalent to the #pragma cancel_handler
provided in IBM's ILE C compiler?
http://publib.boulder.ibm.com/infoce.../cpprog436.htm
What #pragma cancel_handler does is provide the building blocks for try
.... finally code block in a C function.
I am researching the degree of difficulty involved in porting ILE C
code from an IBM AS400 to GNU C.
thanks,
-Steve
FTA:
Cancel handlers provide an important function by allowing you to get
control for clean-up and recovery actions when call stack entries are
ended by something other than a normal return.
On the #pragma cancel_handler directive, the name of the cancel handler
routine (a bound ILE procedure) is specified, along with a user-defined
communications area. It is through the communications area that
information is passed from the application to the handler function.
When the cancel handler function is called, it is passed a pointer to a
structure of type _CNL_Hndlr_Parm s_T which is defined in the <except.h>
header file. This structure contains a pointer to the communications
area in addition to some other useful information that is passed by the
system. This additional information includes the reason why the call
was cancelled.
void CancelHandlerFo rReport( _CNL_Hndlr_Parm s_T *cancel_info )
{
printf("In Cancel Handler for function 'Report' ...\n");
}
void CancelHandlerFo rMain( _CNL_Hndlr_Parm s_T *cancel_info )
{
printf("In Cancel Handler for function 'main' ...\n");
}
int main( void )
{
volatile unsigned return_code; /* communications area */
#pragma cancel_handler( CancelHandlerFo rMain, return_code )
return_code = 0;
#pragma disable_handler
}