[libChf] privatize or comment functions
This commit is contained in:
parent
d5bf86c1f5
commit
a009695d72
3 changed files with 98 additions and 84 deletions
|
@ -199,24 +199,21 @@ typedef /* Message retrieval 'exit' function */
|
||||||
/* -------------------------------------------------------------------------
|
/* -------------------------------------------------------------------------
|
||||||
Function prototypes
|
Function prototypes
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
/* Generic initialization */
|
/* used above */
|
||||||
int ChfInit( const char* app_name, /* Application's name */
|
|
||||||
const ChfOptions options, /* Options */
|
/* Pop a handler */
|
||||||
void* mrs_data, /* Message retrieval private data */
|
void ChfPopHandler( const int module_id );
|
||||||
ChfMrsGet mrs_get, /* 'GetMessage' function */
|
|
||||||
ChfMrsExit mrs_exit, /* 'Exit' function */
|
/* Discard the current conditions */
|
||||||
const int condition_stack_size, /* Size of the condition stack */
|
void ChfDiscard( void );
|
||||||
const int handler_stack_size, /* Size of the handler stack */
|
|
||||||
const int exit_code /* Abnormal exit code */
|
/* 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,
|
||||||
/* Initialization with msgcat subsystem */
|
... );
|
||||||
int ChfMsgcatInit( const char* app_name, /* Application's name */
|
|
||||||
const ChfOptions options, /* Options */
|
/******************/
|
||||||
const char* msgcat_name, /* Name of the message catalog */
|
/* used in saturn */
|
||||||
const int condition_stack_size, /* Size of the condition stack */
|
/******************/
|
||||||
const int handler_stack_size, /* Size of the handler stack */
|
|
||||||
const int exit_code /* Abnormal exit code */
|
|
||||||
);
|
|
||||||
/* Initialization with static message tables */
|
/* Initialization with static message tables */
|
||||||
int ChfStaticInit( const char* app_name, /* Application's name */
|
int ChfStaticInit( const char* app_name, /* Application's name */
|
||||||
const ChfOptions options, /* Options */
|
const ChfOptions options, /* Options */
|
||||||
|
@ -226,29 +223,14 @@ int ChfStaticInit( const char* app_name, /* Application's name */
|
||||||
const int handler_stack_size, /* Size of the handler stack */
|
const int handler_stack_size, /* Size of the handler stack */
|
||||||
const int exit_code /* Abnormal exit code */
|
const int exit_code /* Abnormal exit code */
|
||||||
);
|
);
|
||||||
/* Exit */
|
|
||||||
void ChfExit( void );
|
|
||||||
/* Abort application */
|
|
||||||
void ChfAbort( const int abort_code );
|
|
||||||
/* Push a new handler into the stack */
|
/* Push a new handler into the stack */
|
||||||
void ChfPushHandler( const int module_id, ChfHandler new_handler, /* Handler to be added */
|
void ChfPushHandler( const int module_id, ChfHandler new_handler, /* Handler to be added */
|
||||||
void* unwind_context, /* Unwind context */
|
void* unwind_context, /* Unwind context */
|
||||||
void* handler_context /* Private handler context */
|
void* handler_context /* Private handler context */
|
||||||
);
|
);
|
||||||
/* Pop a handler */
|
|
||||||
void ChfPopHandler( const int module_id );
|
|
||||||
/* Build a condition message */
|
|
||||||
char* ChfBuildMessage( const ChfDescriptor* descriptor );
|
|
||||||
/* Signal the current conditions */
|
/* Signal the current conditions */
|
||||||
void ChfSignal( const int module_id );
|
void ChfSignal( 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,
|
|
||||||
... );
|
|
||||||
/* Retrieve a condition message */
|
/* Retrieve a condition message */
|
||||||
const char* ChfGetMessage( const int module_id, const int condition_code, const char* default_message );
|
const char* ChfGetMessage( const int module_id, const int condition_code, const char* default_message );
|
||||||
/* Retrieve top condition */
|
|
||||||
const ChfDescriptor* ChfGetTopCondition( const int module_id );
|
|
||||||
|
|
||||||
#endif /*!_CHF_H*/
|
#endif /*!_CHF_H*/
|
||||||
|
|
|
@ -117,4 +117,36 @@ extern ChfContext _chf_context; /* CHF Context */
|
||||||
ChfContext* _ChfGetContext( void );
|
ChfContext* _ChfGetContext( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Generic initialization */
|
||||||
|
int ChfInit( const char* app_name, /* Application's name */
|
||||||
|
const ChfOptions options, /* Options */
|
||||||
|
void* mrs_data, /* Message retrieval private data */
|
||||||
|
ChfMrsGet mrs_get, /* 'GetMessage' function */
|
||||||
|
ChfMrsExit mrs_exit, /* 'Exit' function */
|
||||||
|
const int condition_stack_size, /* Size of the condition stack */
|
||||||
|
const int handler_stack_size, /* Size of the handler stack */
|
||||||
|
const int exit_code /* Abnormal exit code */
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Initialization with msgcat subsystem */
|
||||||
|
int ChfMsgcatInit( const char* app_name, /* Application's name */
|
||||||
|
const ChfOptions options, /* Options */
|
||||||
|
const char* msgcat_name, /* Name of the message catalog */
|
||||||
|
const int condition_stack_size, /* Size of the condition stack */
|
||||||
|
const int handler_stack_size, /* Size of the handler stack */
|
||||||
|
const int exit_code /* Abnormal exit code */
|
||||||
|
);
|
||||||
|
|
||||||
|
/* Exit */
|
||||||
|
/* void ChfExit( void ); */
|
||||||
|
|
||||||
|
/* Abort application */
|
||||||
|
void ChfAbort( const int abort_code );
|
||||||
|
|
||||||
|
/* Build a condition message */
|
||||||
|
char* ChfBuildMessage( const ChfDescriptor* descriptor );
|
||||||
|
|
||||||
|
/* Retrieve top condition */
|
||||||
|
const ChfDescriptor* ChfGetTopCondition( const int module_id );
|
||||||
|
|
||||||
#endif /*!_CHF_PRIV_H*/
|
#endif /*!_CHF_PRIV_H*/
|
||||||
|
|
|
@ -572,62 +572,62 @@ int ChfInit( /* Generic initialization */
|
||||||
- added multithreading support
|
- added multithreading support
|
||||||
|
|
||||||
.- */
|
.- */
|
||||||
void ChfExit( void )
|
/* void ChfExit( void ) */
|
||||||
{
|
/* { */
|
||||||
/* Check that CHF has been correctly initialized */
|
/* /\* Check that CHF has been correctly initialized *\/ */
|
||||||
#ifndef _REENTRANT
|
/* #ifndef _REENTRANT */
|
||||||
if ( _chf_context.state == CHF_UNKNOWN )
|
/* if ( _chf_context.state == CHF_UNKNOWN ) */
|
||||||
ChfAbort( CHF_ABORT_INIT );
|
/* ChfAbort( CHF_ABORT_INIT ); */
|
||||||
#else
|
/* #else */
|
||||||
/* Reentrant check; lock context_mutex first */
|
/* /\* Reentrant check; lock context_mutex first *\/ */
|
||||||
if ( pthread_mutex_lock( &context_mutex ) )
|
/* if ( pthread_mutex_lock( &context_mutex ) ) */
|
||||||
ChfAbort( CHF_ABORT_PTHREAD );
|
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||||
if ( _chf_context.state == CHF_UNKNOWN ) {
|
/* if ( _chf_context.state == CHF_UNKNOWN ) { */
|
||||||
if ( pthread_mutex_unlock( &context_mutex ) )
|
/* if ( pthread_mutex_unlock( &context_mutex ) ) */
|
||||||
ChfAbort( CHF_ABORT_PTHREAD );
|
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||||
ChfAbort( CHF_ABORT_INIT );
|
/* ChfAbort( CHF_ABORT_INIT ); */
|
||||||
}
|
/* } */
|
||||||
#endif
|
/* #endif */
|
||||||
|
|
||||||
/* Destroy the context associated with this thread now; this is necessary
|
/* /\* Destroy the context associated with this thread now; this is necessary */
|
||||||
to ensure that the context is actually destroyed when a single-threaded
|
/* to ensure that the context is actually destroyed when a single-threaded */
|
||||||
application links with the multithreaded version of Chf: in this case,
|
/* application links with the multithreaded version of Chf: in this case, */
|
||||||
pthread_exit() is called *after* ChfExit(), the Chf data key no longer
|
/* pthread_exit() is called *after* ChfExit(), the Chf data key no longer */
|
||||||
exists when pthread_exit() is called and the destructor registered
|
/* exists when pthread_exit() is called and the destructor registered */
|
||||||
with pthread_key_create() does not take place.
|
/* with pthread_key_create() does not take place. */
|
||||||
The data pointer associated with the Chf data key is set to NULL to
|
/* The data pointer associated with the Chf data key is set to NULL to */
|
||||||
avoid any subsequent reactivation of the destructor.
|
/* avoid any subsequent reactivation of the destructor. */
|
||||||
*/
|
/* *\/ */
|
||||||
#ifdef _REENTRANT
|
/* #ifdef _REENTRANT */
|
||||||
DestroyContext( &chf_context );
|
/* DestroyContext( &chf_context ); */
|
||||||
if ( pthread_setspecific( data_key, ( void* )NULL ) ) {
|
/* if ( pthread_setspecific( data_key, ( void* )NULL ) ) { */
|
||||||
( void )pthread_mutex_unlock( &context_mutex );
|
/* ( void )pthread_mutex_unlock( &context_mutex ); */
|
||||||
ChfAbort( CHF_ABORT_PTHREAD );
|
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||||
}
|
/* } */
|
||||||
#endif
|
/* #endif */
|
||||||
|
|
||||||
/* Shut down the message retrieval subsystem first */
|
/* /\* Shut down the message retrieval subsystem first *\/ */
|
||||||
_chf_context.mrs_exit( _chf_context.mrs_data );
|
/* _chf_context.mrs_exit( _chf_context.mrs_data ); */
|
||||||
|
|
||||||
#ifndef _REENTRANT
|
/* #ifndef _REENTRANT */
|
||||||
/* Free the dynamic memory previously allocated */
|
/* /\* Free the dynamic memory previously allocated *\/ */
|
||||||
free( _chf_context.message_buffer );
|
/* free( _chf_context.message_buffer ); */
|
||||||
free( _chf_context.handler_stack );
|
/* free( _chf_context.handler_stack ); */
|
||||||
free( _chf_context.condition_stack );
|
/* free( _chf_context.condition_stack ); */
|
||||||
#else
|
/* #else */
|
||||||
/* Destroy the Chf data key */
|
/* /\* Destroy the Chf data key *\/ */
|
||||||
if ( pthread_key_delete( data_key ) )
|
/* if ( pthread_key_delete( data_key ) ) */
|
||||||
ChfAbort( CHF_ABORT_PTHREAD );
|
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||||
#endif
|
/* #endif */
|
||||||
|
|
||||||
/* Reset CHF state to prevent subsequent calls to ChfExit() itself */
|
/* /\* Reset CHF state to prevent subsequent calls to ChfExit() itself *\/ */
|
||||||
_chf_context.state = CHF_UNKNOWN;
|
/* _chf_context.state = CHF_UNKNOWN; */
|
||||||
|
|
||||||
#ifdef _REENTRANT
|
/* #ifdef _REENTRANT */
|
||||||
if ( pthread_mutex_unlock( &context_mutex ) )
|
/* if ( pthread_mutex_unlock( &context_mutex ) ) */
|
||||||
ChfAbort( CHF_ABORT_PTHREAD );
|
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||||
#endif
|
/* #endif */
|
||||||
}
|
/* } */
|
||||||
|
|
||||||
/* .+
|
/* .+
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue