2009-07-21 Joel Sherrill <joel.sherrill@OARcorp.com>

* posix/include/rtems/posix/key.h, posix/src/keycreate.c,
	posix/src/keydelete.c, posix/src/keyrundestructors.c: Restructure a
	bit to make it easier to do coverage analysis. Eliminate is_active
	member of control structure because it was redundant with very the
	key object was open or closed.
This commit is contained in:
Joel Sherrill
2009-07-22 00:09:31 +00:00
parent 4b45c1393c
commit 12a191ae15
5 changed files with 40 additions and 39 deletions

View File

@@ -1,3 +1,11 @@
2009-07-21 Joel Sherrill <joel.sherrill@OARcorp.com>
* posix/include/rtems/posix/key.h, posix/src/keycreate.c,
posix/src/keydelete.c, posix/src/keyrundestructors.c: Restructure a
bit to make it easier to do coverage analysis. Eliminate is_active
member of control structure because it was redundant with very the
key object was open or closed.
2009-07-21 Joel Sherrill <joel.sherrill@OARcorp.com>
* rtems/src/eventseize.c, rtems/src/eventsurrender.c,

View File

@@ -24,62 +24,58 @@
extern "C" {
#endif
/*
* Data Structure used to manage a POSIX key
/**
* This is the data Structure used to manage a POSIX key.
*
* NOTE: The Values is a table indexed by the index portion of the
* ID of the currently executing thread.
* @note The Values is a table indexed by the index portion of the
* ID of the currently executing thread.
*/
typedef struct {
/** This field is the Object control structure. */
Objects_Control Object;
bool is_active;
/** This field points to the optional destructor method. */
void (*destructor)( void * );
/** This field points to the values per thread. */
void **Values[ OBJECTS_APIS_LAST + 1 ];
} POSIX_Keys_Control;
/*
/**
* The following defines the information control block used to manage
* this class of objects.
*/
POSIX_EXTERN Objects_Information _POSIX_Keys_Information;
/*
* _POSIX_Keys_Manager_initialization
*
* DESCRIPTION:
/**
* @brief _POSIX_Keys_Manager_initialization
*
* This routine performs the initialization necessary for this manager.
*/
void _POSIX_Key_Manager_initialization(void);
/*
* _POSIX_Keys_Run_destructors
*
* DESCRIPTION:
/**
* @brief _POSIX_Keys_Run_destructors
*
* This function executes all the destructors associated with the thread's
* keys. This function will execute until all values have been set to NULL.
*
* NOTE: This is the routine executed when a thread exits to
* run through all the keys and do the destructor action.
* @param[in] thread is the thread whose keys should have all their
* destructors run.
*
* @note This is the routine executed when a thread exits to
* run through all the keys and do the destructor action.
*/
void _POSIX_Keys_Run_destructors(
Thread_Control *thread
);
/*
* _POSIX_Keys_Free
*
* DESCRIPTION:
/**
* @brief _POSIX_Keys_Free
*
* This routine frees a keys control block to the
* inactive chain of free keys control blocks.
*
* @param[in] the_key is the POSIX key to free.
*/
RTEMS_INLINE_ROUTINE void _POSIX_Keys_Free (
POSIX_Keys_Control *the_key
);

View File

@@ -96,8 +96,6 @@ int pthread_key_create(
}
the_key->is_active = true;
_Objects_Open_u32( &_POSIX_Keys_Information, &the_key->Object, 0 );
*key = the_key->Object.id;

View File

@@ -42,11 +42,7 @@ int pthread_key_delete(
case OBJECTS_LOCAL:
_Objects_Close( &_POSIX_Keys_Information, &the_key->Object );
the_key->is_active = false;
for ( the_api = 1;
the_api <= OBJECTS_APIS_LAST;
the_api++ )
for ( the_api = 1; the_api <= OBJECTS_APIS_LAST; the_api++ )
if ( the_key->Values[ the_api ] )
_Workspace_Free( the_key->Values[ the_api ] );

View File

@@ -59,13 +59,16 @@ void _POSIX_Keys_Run_destructors(
the_key = (POSIX_Keys_Control *)
_POSIX_Keys_Information.local_table[ index ];
if ( the_key && the_key->is_active && the_key->destructor ) {
value = the_key->Values[ thread_api ][ thread_index ];
if ( value ) {
(*the_key->destructor)( value );
if ( the_key->Values[ thread_api ][ thread_index ] )
are_all_null = false;
}
if ( !the_key )
continue;
if ( !the_key->destructor )
continue;
value = the_key->Values[ thread_api ][ thread_index ];
if ( value ) {
(*the_key->destructor)( value );
if ( the_key->Values[ thread_api ][ thread_index ] )
are_all_null = false;
}
}