diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 07:01:03 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 16:16:26 +0200 |
commit | 05f9b02e3c0927e69f96bafaac359a53c7f92322 (patch) | |
tree | cd888a5621379b636bf18b5aab6647ca7e18908a /cpukit/posix/src/prwlockinit.c | |
parent | score: Use _RBTree_Insert_inline() (diff) | |
download | rtems-05f9b02e3c0927e69f96bafaac359a53c7f92322.tar.bz2 |
posix: Add and use _POSIX_Get_object_body()
Diffstat (limited to 'cpukit/posix/src/prwlockinit.c')
-rw-r--r-- | cpukit/posix/src/prwlockinit.c | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/cpukit/posix/src/prwlockinit.c b/cpukit/posix/src/prwlockinit.c index 8847c17c30..fcf4e29a34 100644 --- a/cpukit/posix/src/prwlockinit.c +++ b/cpukit/posix/src/prwlockinit.c @@ -21,50 +21,20 @@ #endif #include <rtems/posix/rwlockimpl.h> -#include <rtems/score/apimutex.h> - -static bool _POSIX_RWLock_Check_id_and_auto_init( - pthread_mutex_t *rwlock -) -{ - if ( rwlock == NULL ) { - return false; - } - - if ( *rwlock == PTHREAD_RWLOCK_INITIALIZER ) { - int eno; - - _Once_Lock(); - - if ( *rwlock == PTHREAD_RWLOCK_INITIALIZER ) { - eno = pthread_rwlock_init( rwlock, NULL ); - } else { - eno = 0; - } - - _Once_Unlock(); - - if ( eno != 0 ) { - return false; - } - } - - return true; -} +#include <rtems/posix/posixapi.h> POSIX_RWLock_Control *_POSIX_RWLock_Get( pthread_rwlock_t *rwlock, ISR_lock_Context *lock_context ) { - if ( !_POSIX_RWLock_Check_id_and_auto_init( rwlock ) ) { - return NULL; - } - - return (POSIX_RWLock_Control *) _Objects_Get_local( - *rwlock, + _POSIX_Get_object_body( + POSIX_RWLock_Control, + rwlock, lock_context, - &_POSIX_RWLock_Information + &_POSIX_RWLock_Information, + PTHREAD_RWLOCK_INITIALIZER, + pthread_rwlock_init ); } |