diff --git a/src/emulator.c b/src/emulator.c index a54eb5a..b3bc57b 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -268,9 +268,9 @@ static ChfAction EmulatorLoopHandler( const ChfDescriptor* d, const ChfState s, /* 2.1: Chf release 2 fixed the spelling of 'SIGNALING' */ case CHF_SIGNALING: /* ChfSignal() in progress */ - if ( ChfGetModuleId( d ) == CPU_CHF_MODULE_ID ) { + if ( d->module_id == CPU_CHF_MODULE_ID ) { /* Condition from CPU modules; check Condition Code */ - switch ( ChfGetConditionCode( d ) ) { + switch ( d->condition_code ) { case CPU_I_SHUTDN: { /* 3.1: CPU_SPIN_SHUTDN is not defined, and the cpu emulator diff --git a/src/libChf/docs/chf.texi b/src/libChf/docs/chf.texi index 69124c8..68ac2df 100644 --- a/src/libChf/docs/chf.texi +++ b/src/libChf/docs/chf.texi @@ -1130,74 +1130,6 @@ the macros the Chf library provides for this purpose. @end deftp -The following macros are provided to access a condition descriptor: - -@deftypefn Macro {ChfDescriptor *} ChfGetNextDescriptor (Chf Descriptor *d) -@cindex Next condition descriptor - -Returns to the caller the condition descriptor that hierarchically -follows @code{d} in the current condition group, or the special -value @code{CHF_NULL_DESCRIPTOR} if @code{d} is the last descriptor of the -group. - -@end deftypefn - -@deftypefn Macro int ChfGetModuleId (Chf Descriptor *d) -@cindex Module identifier - -Returns to the caller the identifier of the module that generated -the condition @code{d}. - -@end deftypefn - -@deftypefn Macro int ChfGetConditionCode (Chf Descriptor *d) -@cindex Condition Code - -Returns to the caller the condition code of the condition @code{d}. - -@end deftypefn - -@deftypefn Macro ChfSeverity ChfGetSeverity (Chf Descriptor *d) -@cindex Severity - -Returns to the caller the severity level of the condition @code{d}. -@xref{ChfSeverity}. - -@end deftypefn - -@deftypefn Macro int ChfGetLineNumber (Chf Descriptor *d) -@cindex Line number - -Returns to the caller the source line number where the condition @code{d} -was generated. This piece of information is available only if the -Chf compile-time option @code{CHF_EXTENDED_INFO} was set when the source -file that generated the condition was compiled, otherwise the special -value @code{CHF_UNKNOWN_LINE_NUMBER} is returned instead. - -@end deftypefn - -@deftypefn Macro {const char *} ChfGetFileName (Chf Descriptor *d) -@cindex File name - -Returns to the caller the file name where the condition @code{d} -was generated. This piece of information is available only if the -Chf compile-time option @code{CHF_EXTENDED_INFO} was set when the source -file that generated the condition was compiled, otherwise the special -value @code{CHF_UNKNOWN_FILE_NAME} is returned instead. - -@end deftypefn - -@deftypefn Macro {char *} ChfGetPartialMessage (Chf Descriptor *d) -@cindex Partial condition message - -Returns to the caller the partial condition message that was associated -with the condition @code{d} when it was generated. The partial condition -message contains the result of the execution of @code{sprintf()} using -the message template associated with the condition as format, and the -ancillary condition arguments as additional arguments. - -@end deftypefn - @node Condition handling state, Handler actions, Condition descriptors, General condition handling diff --git a/src/libChf/src/Chf.h b/src/libChf/src/Chf.h index 33ecc42..92fb08b 100644 --- a/src/libChf/src/Chf.h +++ b/src/libChf/src/Chf.h @@ -199,18 +199,6 @@ typedef /* Message retrieval 'exit' function */ } \ } -/* ------------------------------------------------------------------------- - Other macros - ------------------------------------------------------------------------- */ - -#define ChfGetNextDescriptor( d ) ( d )->next -#define ChfGetModuleId( d ) ( d )->module_id -#define ChfGetConditionCode( d ) ( d )->condition_code -#define ChfGetSeverity( d ) ( d )->severity -#define ChfGetLineNumber( d ) ( d )->line_number -#define ChfGetFileName( d ) ( d )->file_name -#define ChfGetPartialMessage( d ) ( d )->message - /* ------------------------------------------------------------------------- Function prototypes ------------------------------------------------------------------------- */ diff --git a/src/libChf/src/chf_abrt.c b/src/libChf/src/chf_abrt.c index 442ef40..2acb57f 100644 --- a/src/libChf/src/chf_abrt.c +++ b/src/libChf/src/chf_abrt.c @@ -42,23 +42,6 @@ # include #endif -/* Abort codes message table; the relative position of the messages must - match the numeric codes CHF_ABORT_xxxx defined in ChfPriv.h -*/ -static const char* message_table[] = { ( const char* )NULL, - "Not initialized", - "Temporary message buffer overflow", - "Invalid action from last chance handler", - "Already initialized", - "Unwind request while unwinding", - "Improperly handled condition", - "Fatal condition while unwinding", - "Condition stack overflow", - "Can't prime a new Chf context", - "Pthread interaction failed" }; - -#define MESSAGE_TABLE_SIZE ( sizeof( message_table ) / sizeof( const char* ) ) - /* .+ .title : ChfAbort @@ -109,10 +92,26 @@ static const char* message_table[] = { ( const char* )NULL, void ChfAbort( /* Abort application */ const int abort_code ) { + + /* Abort codes message table; the relative position of the messages must + match the numeric codes CHF_ABORT_xxxx defined in ChfPriv.h + */ + const char* message_table[] = { ( const char* )NULL, + "Not initialized", + "Temporary message buffer overflow", + "Invalid action from last chance handler", + "Already initialized", + "Unwind request while unwinding", + "Improperly handled condition", + "Fatal condition while unwinding", + "Condition stack overflow", + "Can't prime a new Chf context", + "Pthread interaction failed" }; + if ( abort_code != CHF_ABORT_SILENT ) { fputs( CHF_ABORT_HEADER, stderr ); - if ( abort_code < 0 || abort_code >= ( int )MESSAGE_TABLE_SIZE ) + if ( abort_code < 0 || abort_code >= ( int )( sizeof( message_table ) / sizeof( const char* ) ) ) fprintf( stderr, CHF_ABORT_BAD_CODE_FMT, abort_code ); else diff --git a/src/libChf/src/chf_hdlr.c b/src/libChf/src/chf_hdlr.c index d712459..7f12683 100644 --- a/src/libChf/src/chf_hdlr.c +++ b/src/libChf/src/chf_hdlr.c @@ -83,7 +83,7 @@ static ChfAction StructuredHelper( const ChfDescriptor* desc, const ChfState sta ChfAction action; const ChfDescriptor* d; - return ( ( state == CHF_SIGNALING && ChfGetSeverity( desc ) == CHF_FATAL ) ? CHF_UNWIND_KEEP : CHF_RESIGNAL ); + return ( ( state == CHF_SIGNALING && desc->severity == CHF_FATAL ) ? CHF_UNWIND_KEEP : CHF_RESIGNAL ); } /* .+ diff --git a/src/libChf/src/chf_init.c b/src/libChf/src/chf_init.c index 0addc9d..50be3ed 100644 --- a/src/libChf/src/chf_init.c +++ b/src/libChf/src/chf_init.c @@ -169,12 +169,12 @@ static ChfAction DefaultHandler( const ChfDescriptor* desc, const ChfState state is done atomically if multithreading support is enabled. In Win32, the default handler does not print anything. */ - if ( ChfGetSeverity( desc ) > CHF_SUCCESS ) { + if ( desc->severity > CHF_SUCCESS ) { #ifdef _REENTRANT if ( pthread_mutex_lock( &fputs_mutex ) ) ChfAbort( CHF_ABORT_PTHREAD ); #endif - for ( d = desc; d != CHF_NULL_DESCRIPTOR; d = ChfGetNextDescriptor( d ) ) + for ( d = desc; d != CHF_NULL_DESCRIPTOR; d = d->next ) fputs( ChfBuildMessage( d ), stderr ); #ifdef _REENTRANT if ( pthread_mutex_unlock( &fputs_mutex ) ) @@ -183,7 +183,7 @@ static ChfAction DefaultHandler( const ChfDescriptor* desc, const ChfState state } /* Determine the handler action */ - switch ( ChfGetSeverity( desc ) ) { + switch ( desc->severity ) { case CHF_SUCCESS: case CHF_INFO: case CHF_WARNING: @@ -374,15 +374,15 @@ char* ChfBuildMessage( /* Build a condition message */ tmp_p = scopy( tmp_p, "\t", tmp_end ); /* The message continues with the module name */ - ChfSprintf( def_message, CHF_DEF_MID_MSG_FMT, ChfGetModuleId( descriptor ) ); + ChfSprintf( def_message, CHF_DEF_MID_MSG_FMT, descriptor->module_id ); - tmp_p = scopy( tmp_p, ChfGetMessage( CHF_MODULE_NAMES_SET, ChfGetModuleId( descriptor ), def_message ), tmp_end ); + tmp_p = scopy( tmp_p, ChfGetMessage( CHF_MODULE_NAMES_SET, descriptor->module_id, def_message ), tmp_end ); /* Add also the extended information, if any */ - if ( ChfGetLineNumber( descriptor ) != CHF_UNKNOWN_LINE_NUMBER ) { + if ( descriptor->line_number != CHF_UNKNOWN_LINE_NUMBER ) { tmp_p = scopy( tmp_p, " ", tmp_end ); - ChfSprintf( def_message, CHF_EXTENDED_INFO_FMT, ChfGetFileName( descriptor ), ChfGetLineNumber( descriptor ) ); + ChfSprintf( def_message, CHF_EXTENDED_INFO_FMT, descriptor->file_name, descriptor->line_number ); tmp_p = scopy( tmp_p, def_message, tmp_end ); } @@ -391,14 +391,14 @@ char* ChfBuildMessage( /* Build a condition message */ /* Add the severity code of the message */ tmp_p = scopy( tmp_p, - ( ( severity = ChfGetSeverity( descriptor ) ) < CHF_SUCCESS || severity > CHF_FATAL ) ? CHF_UNKNOWN_SEVERITY - : severity_name[ severity ], + ( ( severity = descriptor->severity ) < CHF_SUCCESS || severity > CHF_FATAL ) ? CHF_UNKNOWN_SEVERITY + : severity_name[ severity ], tmp_end ); tmp_p = scopy( tmp_p, separator, tmp_end ); /* The message ends with the partial message from the descriptor */ - tmp_p = scopy( tmp_p, ChfGetPartialMessage( descriptor ), tmp_end ); + tmp_p = scopy( tmp_p, descriptor->message, tmp_end ); ( void )scopy( tmp_p, CHF_MESSAGE_TERMINATOR, tmp_end ); return chf_context.message_buffer; diff --git a/src/libChf/src/chf_sig.c b/src/libChf/src/chf_sig.c index cee7ecb..5401b7b 100644 --- a/src/libChf/src/chf_sig.c +++ b/src/libChf/src/chf_sig.c @@ -165,8 +165,8 @@ void ChfSignal( const int module_id ) if ( chf_context.condition_sp > chf_context.condition_base ) { if ( chf_context.state == CHF_SIGNALING ) { /* Force the new severity to CHF_FATAL if necessary */ - if ( ChfGetSeverity( current_condition ) == CHF_FATAL ) - ChfGetSeverity( chf_context.condition_sp - 1 ) = CHF_FATAL; + if ( current_condition->severity == CHF_FATAL ) + ( chf_context.condition_sp - 1 )->severity = CHF_FATAL; /* Link together the condition groups */ chf_context.condition_base->next = current_condition; @@ -181,7 +181,7 @@ void ChfSignal( const int module_id ) /* The action CHF_CONTINUE is not allowed if the current condition severity is CHF_FATAL; it's automatically changed to CHF_RESIGNAL */ - if ( handler_result == CHF_CONTINUE && ChfGetSeverity( current_condition ) == CHF_FATAL ) + if ( handler_result == CHF_CONTINUE && current_condition->severity == CHF_FATAL ) handler_result = CHF_RESIGNAL; }