[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
|
||||
------------------------------------------------------------------------- */
|
||||
/* 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 */
|
||||
);
|
||||
/* 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,
|
||||
... );
|
||||
|
||||
/******************/
|
||||
/* used in saturn */
|
||||
/******************/
|
||||
/* Initialization with static message tables */
|
||||
int ChfStaticInit( const char* app_name, /* Application's name */
|
||||
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 exit_code /* Abnormal exit code */
|
||||
);
|
||||
/* Exit */
|
||||
void ChfExit( void );
|
||||
/* Abort application */
|
||||
void ChfAbort( const int abort_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 */
|
||||
);
|
||||
/* Pop a handler */
|
||||
void ChfPopHandler( const int module_id );
|
||||
/* Build a condition message */
|
||||
char* ChfBuildMessage( const ChfDescriptor* descriptor );
|
||||
/* Signal the current conditions */
|
||||
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 */
|
||||
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*/
|
||||
|
|
|
@ -117,4 +117,36 @@ extern ChfContext _chf_context; /* CHF Context */
|
|||
ChfContext* _ChfGetContext( void );
|
||||
#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*/
|
||||
|
|
|
@ -572,62 +572,62 @@ int ChfInit( /* Generic initialization */
|
|||
- added multithreading support
|
||||
|
||||
.- */
|
||||
void ChfExit( void )
|
||||
{
|
||||
/* Check that CHF has been correctly initialized */
|
||||
#ifndef _REENTRANT
|
||||
if ( _chf_context.state == CHF_UNKNOWN )
|
||||
ChfAbort( CHF_ABORT_INIT );
|
||||
#else
|
||||
/* Reentrant check; lock context_mutex first */
|
||||
if ( pthread_mutex_lock( &context_mutex ) )
|
||||
ChfAbort( CHF_ABORT_PTHREAD );
|
||||
if ( _chf_context.state == CHF_UNKNOWN ) {
|
||||
if ( pthread_mutex_unlock( &context_mutex ) )
|
||||
ChfAbort( CHF_ABORT_PTHREAD );
|
||||
ChfAbort( CHF_ABORT_INIT );
|
||||
}
|
||||
#endif
|
||||
/* void ChfExit( void ) */
|
||||
/* { */
|
||||
/* /\* Check that CHF has been correctly initialized *\/ */
|
||||
/* #ifndef _REENTRANT */
|
||||
/* if ( _chf_context.state == CHF_UNKNOWN ) */
|
||||
/* ChfAbort( CHF_ABORT_INIT ); */
|
||||
/* #else */
|
||||
/* /\* Reentrant check; lock context_mutex first *\/ */
|
||||
/* if ( pthread_mutex_lock( &context_mutex ) ) */
|
||||
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||
/* if ( _chf_context.state == CHF_UNKNOWN ) { */
|
||||
/* if ( pthread_mutex_unlock( &context_mutex ) ) */
|
||||
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||
/* ChfAbort( CHF_ABORT_INIT ); */
|
||||
/* } */
|
||||
/* #endif */
|
||||
|
||||
/* Destroy the context associated with this thread now; this is necessary
|
||||
to ensure that the context is actually destroyed when a single-threaded
|
||||
application links with the multithreaded version of Chf: in this case,
|
||||
pthread_exit() is called *after* ChfExit(), the Chf data key no longer
|
||||
exists when pthread_exit() is called and the destructor registered
|
||||
with pthread_key_create() does not take place.
|
||||
The data pointer associated with the Chf data key is set to NULL to
|
||||
avoid any subsequent reactivation of the destructor.
|
||||
*/
|
||||
#ifdef _REENTRANT
|
||||
DestroyContext( &chf_context );
|
||||
if ( pthread_setspecific( data_key, ( void* )NULL ) ) {
|
||||
( void )pthread_mutex_unlock( &context_mutex );
|
||||
ChfAbort( CHF_ABORT_PTHREAD );
|
||||
}
|
||||
#endif
|
||||
/* /\* Destroy the context associated with this thread now; this is necessary */
|
||||
/* to ensure that the context is actually destroyed when a single-threaded */
|
||||
/* application links with the multithreaded version of Chf: in this case, */
|
||||
/* pthread_exit() is called *after* ChfExit(), the Chf data key no longer */
|
||||
/* exists when pthread_exit() is called and the destructor registered */
|
||||
/* with pthread_key_create() does not take place. */
|
||||
/* The data pointer associated with the Chf data key is set to NULL to */
|
||||
/* avoid any subsequent reactivation of the destructor. */
|
||||
/* *\/ */
|
||||
/* #ifdef _REENTRANT */
|
||||
/* DestroyContext( &chf_context ); */
|
||||
/* if ( pthread_setspecific( data_key, ( void* )NULL ) ) { */
|
||||
/* ( void )pthread_mutex_unlock( &context_mutex ); */
|
||||
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||
/* } */
|
||||
/* #endif */
|
||||
|
||||
/* Shut down the message retrieval subsystem first */
|
||||
_chf_context.mrs_exit( _chf_context.mrs_data );
|
||||
/* /\* Shut down the message retrieval subsystem first *\/ */
|
||||
/* _chf_context.mrs_exit( _chf_context.mrs_data ); */
|
||||
|
||||
#ifndef _REENTRANT
|
||||
/* Free the dynamic memory previously allocated */
|
||||
free( _chf_context.message_buffer );
|
||||
free( _chf_context.handler_stack );
|
||||
free( _chf_context.condition_stack );
|
||||
#else
|
||||
/* Destroy the Chf data key */
|
||||
if ( pthread_key_delete( data_key ) )
|
||||
ChfAbort( CHF_ABORT_PTHREAD );
|
||||
#endif
|
||||
/* #ifndef _REENTRANT */
|
||||
/* /\* Free the dynamic memory previously allocated *\/ */
|
||||
/* free( _chf_context.message_buffer ); */
|
||||
/* free( _chf_context.handler_stack ); */
|
||||
/* free( _chf_context.condition_stack ); */
|
||||
/* #else */
|
||||
/* /\* Destroy the Chf data key *\/ */
|
||||
/* if ( pthread_key_delete( data_key ) ) */
|
||||
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||
/* #endif */
|
||||
|
||||
/* Reset CHF state to prevent subsequent calls to ChfExit() itself */
|
||||
_chf_context.state = CHF_UNKNOWN;
|
||||
/* /\* Reset CHF state to prevent subsequent calls to ChfExit() itself *\/ */
|
||||
/* _chf_context.state = CHF_UNKNOWN; */
|
||||
|
||||
#ifdef _REENTRANT
|
||||
if ( pthread_mutex_unlock( &context_mutex ) )
|
||||
ChfAbort( CHF_ABORT_PTHREAD );
|
||||
#endif
|
||||
}
|
||||
/* #ifdef _REENTRANT */
|
||||
/* if ( pthread_mutex_unlock( &context_mutex ) ) */
|
||||
/* ChfAbort( CHF_ABORT_PTHREAD ); */
|
||||
/* #endif */
|
||||
/* } */
|
||||
|
||||
/* .+
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue