forked from Imagelibrary/rtems
Added support for converting a mutex id to a pointer and returning
with interrupts disabled.
This commit is contained in:
@@ -41,39 +41,57 @@ RTEMS_INLINE_ROUTINE void _POSIX_Mutex_Free (
|
||||
/*PAGE
|
||||
*
|
||||
* _POSIX_Mutex_Get
|
||||
*
|
||||
* NOTE: The support macro makes it possible for both to use exactly
|
||||
* the same code to check for NULL id pointer and
|
||||
* PTHREAD_MUTEX_INITIALIZER without adding overhead.
|
||||
*/
|
||||
|
||||
#define ___POSIX_Mutex_Get_support( _id, _location ) \
|
||||
do { \
|
||||
int _status; \
|
||||
\
|
||||
if ( !_id ) { \
|
||||
*_location = OBJECTS_ERROR; \
|
||||
return (POSIX_Mutex_Control *) 0; \
|
||||
} \
|
||||
\
|
||||
if ( *_id == PTHREAD_MUTEX_INITIALIZER ) { \
|
||||
/* \
|
||||
* Do an "auto-create" here. \
|
||||
*/ \
|
||||
\
|
||||
_status = pthread_mutex_init( _id, 0 ); \
|
||||
if ( _status ) { \
|
||||
*_location = OBJECTS_ERROR; \
|
||||
return (POSIX_Mutex_Control *) 0; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get (
|
||||
Objects_Id *id,
|
||||
Objects_Locations *location
|
||||
)
|
||||
{
|
||||
int status;
|
||||
|
||||
if ( !id ) {
|
||||
*location = OBJECTS_ERROR;
|
||||
return (POSIX_Mutex_Control *) 0;
|
||||
}
|
||||
|
||||
if ( *id == PTHREAD_MUTEX_INITIALIZER ) {
|
||||
/*
|
||||
* Do an "auto-create" here.
|
||||
*/
|
||||
|
||||
status = pthread_mutex_init( id, 0 );
|
||||
if ( status ) {
|
||||
*location = OBJECTS_ERROR;
|
||||
return (POSIX_Mutex_Control *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Now call Objects_Get()
|
||||
*/
|
||||
___POSIX_Mutex_Get_support( id, location );
|
||||
|
||||
return (POSIX_Mutex_Control *)
|
||||
_Objects_Get( &_POSIX_Mutex_Information, *id, location );
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
|
||||
Objects_Id *id,
|
||||
Objects_Locations *location,
|
||||
ISR_Level *level
|
||||
)
|
||||
{
|
||||
___POSIX_Mutex_Get_support( id, location );
|
||||
|
||||
return (POSIX_Mutex_Control *)
|
||||
_Objects_Get_isr_disable( &_POSIX_Mutex_Information, *id, location, level );
|
||||
}
|
||||
|
||||
|
||||
/*PAGE
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user