[libChf] more cleaning and simplification
This commit is contained in:
parent
a009695d72
commit
14fb5547d3
5 changed files with 41 additions and 65 deletions
|
@ -128,12 +128,6 @@
|
|||
|
||||
#include "ui4x/config.h"
|
||||
|
||||
/* CHF_EXTENDED_INFO:
|
||||
Define this symbol if extended information is desired during condition
|
||||
handling; this is usually useful only for debugging purposes.
|
||||
*/
|
||||
#define CHF_EXTENDED_INFO
|
||||
|
||||
/* DEBUG:
|
||||
Define this symbol to include the debugging code for all source modules
|
||||
in the executable image.
|
||||
|
|
|
@ -669,12 +669,6 @@ identifier. Even if this macro could in principle be redefined through the
|
|||
source, it is generally inconvenient to have functions belonging to different
|
||||
application's modules in the same source file, so it is discouraged.
|
||||
This definition is mandatory.
|
||||
|
||||
@item CHF_EXTENDED_INFO
|
||||
If this macro is set, all conditions generated by the source module
|
||||
will include the file name and the line number as additional information
|
||||
items. This can be useful for debugging purposes. This definition is
|
||||
optional.
|
||||
@end table
|
||||
|
||||
@strong{Win32:} The @code{tchar.h} system header must be included
|
||||
|
|
|
@ -154,59 +154,19 @@ typedef /* Message retrieval 'exit' function */
|
|||
Condition generation macros
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#if defined( CHF_EXTENDED_INFO )
|
||||
# define CHF_Condition( module_id ) \
|
||||
#define CHF_Condition( module_id ) \
|
||||
ChfGenerate( \
|
||||
module_id, \
|
||||
__FILE__, __LINE__,
|
||||
|
||||
# define CHF_ErrnoCondition ChfGenerate( CHF_ERRNO_SET, __FILE__, __LINE__, errno, CHF_ERROR )
|
||||
|
||||
#else
|
||||
# define CHF_Condition( module_id ) \
|
||||
ChfGenerate( \
|
||||
module_id, \
|
||||
CHF_UNKNOWN_FILE_NAME, CHF_UNKNOWN_LINE_NUMBER,
|
||||
|
||||
# define CHF_ErrnoCondition ChfGenerate( CHF_ERRNO_SET, CHF_UNKNOWN_FILE_NAME, CHF_UNKNOWN_LINE_NUMBER, errno, CHF_ERROR )
|
||||
|
||||
#endif
|
||||
#define CHF_ErrnoCondition ChfGenerate( CHF_ERRNO_SET, __FILE__, __LINE__, errno, CHF_ERROR )
|
||||
|
||||
#define ChfEnd \
|
||||
)
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
Structured condition handling
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#define CHF_Try \
|
||||
{ \
|
||||
sigjmp_buf _chf_sigjmp_buf; \
|
||||
if ( sigsetjmp( _chf_sigjmp_buf, 1 ) == 0 ) { \
|
||||
ChfPushHandler( CHF_NULL_HANDLER, _chf_sigjmp_buf, CHF_NULL_POINTER );
|
||||
|
||||
#define CHF_Catch \
|
||||
ChfPopHandler( CHF_MODULE_ID ); \
|
||||
} \
|
||||
else \
|
||||
{
|
||||
|
||||
#define CHF_EndTry \
|
||||
ChfDiscard(); \
|
||||
} \
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
Function prototypes
|
||||
------------------------------------------------------------------------- */
|
||||
/* used above */
|
||||
|
||||
/* Pop a handler */
|
||||
void ChfPopHandler( const int module_id );
|
||||
|
||||
/* Discard the current conditions */
|
||||
void ChfDiscard( void );
|
||||
|
||||
/* Generate a condition into the stack */
|
||||
void ChfGenerate( const int module_id, const char* file_name, const int line_number, const int condition_code, const ChfSeverity severity,
|
||||
... );
|
||||
|
@ -223,14 +183,14 @@ int ChfStaticInit( const char* app_name, /* Application's name */
|
|||
const int handler_stack_size, /* Size of the handler stack */
|
||||
const int exit_code /* Abnormal exit code */
|
||||
);
|
||||
|
||||
/* Push a new handler into the stack */
|
||||
void ChfPushHandler( const int module_id, ChfHandler new_handler, /* Handler to be added */
|
||||
void* unwind_context, /* Unwind context */
|
||||
void* handler_context /* Private handler context */
|
||||
);
|
||||
|
||||
/* Signal the current conditions */
|
||||
void ChfSignal( const int module_id );
|
||||
/* Retrieve a condition message */
|
||||
const char* ChfGetMessage( const int module_id, const int condition_code, const char* default_message );
|
||||
|
||||
#endif /*!_CHF_H*/
|
||||
|
|
|
@ -104,6 +104,27 @@ typedef struct ChfContext_S /* CHF Context */
|
|||
# define chf_context _chf_context
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
Structured condition handling
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
/* #define CHF_Try \ */
|
||||
/* { \ */
|
||||
/* sigjmp_buf _chf_sigjmp_buf; \ */
|
||||
/* if ( sigsetjmp( _chf_sigjmp_buf, 1 ) == 0 ) { \ */
|
||||
/* ChfPushHandler( CHF_NULL_HANDLER, _chf_sigjmp_buf, CHF_NULL_POINTER ); */
|
||||
|
||||
/* #define CHF_Catch \ */
|
||||
/* ChfPopHandler( CHF_MODULE_ID ); \ */
|
||||
/* } \ */
|
||||
/* else \ */
|
||||
/* { */
|
||||
|
||||
/* #define CHF_EndTry \ */
|
||||
/* ChfDiscard(); \ */
|
||||
/* } \ */
|
||||
/* } */
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
Global variables
|
||||
------------------------------------------------------------------------- */
|
||||
|
@ -137,6 +158,12 @@ int ChfMsgcatInit( const char* app_name, /* Application's name */
|
|||
const int exit_code /* Abnormal exit code */
|
||||
);
|
||||
|
||||
/* /\* Pop a handler *\/ */
|
||||
/* void ChfPopHandler( const int module_id ); */
|
||||
|
||||
/* /\* Discard the current conditions *\/ */
|
||||
/* void ChfDiscard( void ); */
|
||||
|
||||
/* Exit */
|
||||
/* void ChfExit( void ); */
|
||||
|
||||
|
@ -149,4 +176,7 @@ char* ChfBuildMessage( const ChfDescriptor* descriptor );
|
|||
/* Retrieve top condition */
|
||||
const ChfDescriptor* ChfGetTopCondition( const int module_id );
|
||||
|
||||
/* Retrieve a condition message */
|
||||
const char* ChfGetMessage( const int module_id, const int condition_code, const char* default_message );
|
||||
|
||||
#endif /*!_CHF_PRIV_H*/
|
||||
|
|
|
@ -1559,12 +1559,12 @@ void ModMapCheck( Address addr, char ob[ MOD_MAP_CHECK_OB_SIZE ] )
|
|||
offset = ModOffset( addr );
|
||||
|
||||
if ( ( mod = mod_map.page_table[ page ].index ) == MOD_NO_MOD_INDEX )
|
||||
sprintf( ob, ChfGetMessage( CHF_MODULE_ID, MOD_M_NOT_MAPPED, "" ), addr );
|
||||
sprintf( ob, "A[%05X] -> *Not Mapped*", addr );
|
||||
else {
|
||||
Address rel_addr;
|
||||
rel_addr = mod_map.page_table[ page ].rel_base_addr | offset;
|
||||
|
||||
sprintf( ob, ChfGetMessage( CHF_MODULE_ID, MOD_M_MAPPED, "" ), addr, mod_description[ mod ].name, rel_addr );
|
||||
sprintf( ob, "A[%05X] -> M[%s] R[%05X]", addr, mod_description[ mod ].name, rel_addr );
|
||||
}
|
||||
|
||||
ChfSignal( MOD_CHF_MODULE_ID );
|
||||
|
@ -1595,16 +1595,14 @@ void ModMapTable( char ob[ MOD_MAP_TABLE_OB_SIZE ] )
|
|||
{
|
||||
int mod;
|
||||
|
||||
sprintf( ob, "%s\n", ChfGetMessage( CHF_MODULE_ID, MOD_M_MAP_TABLE_TITLE, "" ) );
|
||||
sprintf( ob, "%s\n", "Device\t\t\tAddress\tSize\tStatus" );
|
||||
ob += strlen( ob );
|
||||
|
||||
for ( mod = 0; mod < N_MOD; mod++ ) {
|
||||
sprintf( ob, ChfGetMessage( CHF_MODULE_ID, MOD_M_MAP_TABLE_ROW, "" ), mod_description[ mod ].name,
|
||||
mod_map.map_info[ mod ].abs_base_addr, mod_map.map_info[ mod ].size,
|
||||
mod_map.map_info[ mod ].config == MOD_CONFIGURED ? ChfGetMessage( CHF_MODULE_ID, MOD_M_MAP_CONFIGURED, "C" )
|
||||
: ( mod_map.map_info[ mod ].config == MOD_SIZE_CONFIGURED
|
||||
? ChfGetMessage( CHF_MODULE_ID, MOD_M_MAP_SZ_CONFIGURED, "S" )
|
||||
: ChfGetMessage( CHF_MODULE_ID, MOD_M_MAP_UNCONFIGURED, "U" ) ) );
|
||||
sprintf( ob, "%s\t%05X\t%05X\t%s", mod_description[ mod ].name, mod_map.map_info[ mod ].abs_base_addr, mod_map.map_info[ mod ].size,
|
||||
mod_map.map_info[ mod ].config == MOD_CONFIGURED
|
||||
? "Configured"
|
||||
: ( mod_map.map_info[ mod ].config == MOD_SIZE_CONFIGURED ? "Size_configured" : "*Unconfigured*" ) );
|
||||
|
||||
strcat( ob, "\n" );
|
||||
ob += strlen( ob );
|
||||
|
|
Loading…
Add table
Reference in a new issue