diff options
Diffstat (limited to 'cpukit/posix/src/prwlocktrywrlock.c')
-rw-r--r-- | cpukit/posix/src/prwlocktrywrlock.c | 60 |
1 files changed, 17 insertions, 43 deletions
diff --git a/cpukit/posix/src/prwlocktrywrlock.c b/cpukit/posix/src/prwlocktrywrlock.c index 065199b88a..a44a54ffb5 100644 --- a/cpukit/posix/src/prwlocktrywrlock.c +++ b/cpukit/posix/src/prwlocktrywrlock.c @@ -18,57 +18,31 @@ #include "config.h" #endif -#include <pthread.h> -#include <errno.h> - #include <rtems/posix/rwlockimpl.h> -#include <rtems/score/thread.h> - -/* - * pthread_rwlock_trywrlock - * - * This directive attempts to obtain a Write only lock on an rwlock instance. - * - * Input parameters: - * rwlock - pointer to rwlock id - * - * Output parameters: - * 0 - if successful - * error code - if unsuccessful - */ int pthread_rwlock_trywrlock( pthread_rwlock_t *rwlock ) { - POSIX_RWLock_Control *the_rwlock; - Objects_Locations location; - Thread_Control *executing; - - the_rwlock = _POSIX_RWLock_Get( rwlock, &location ); - switch ( location ) { - - case OBJECTS_LOCAL: + POSIX_RWLock_Control *the_rwlock; + ISR_lock_Context lock_context; + Thread_Control *executing; - executing = _Thread_Executing; - _CORE_RWLock_Seize_for_writing( - &the_rwlock->RWLock, - executing, - false, /* we are not willing to wait */ - 0 - ); + the_rwlock = _POSIX_RWLock_Get( rwlock, &lock_context ); - _Objects_Put( &the_rwlock->Object ); - return _POSIX_RWLock_Translate_core_RWLock_return_code( - (CORE_RWLock_Status) executing->Wait.return_code - ); - -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + if ( the_rwlock == NULL ) { + return EINVAL; } - return EINVAL; + executing = _Thread_Executing; + _CORE_RWLock_Seize_for_writing( + &the_rwlock->RWLock, + executing, + false, /* we are not willing to wait */ + 0, + &lock_context + ); + return _POSIX_RWLock_Translate_core_RWLock_return_code( + (CORE_RWLock_Status) executing->Wait.return_code + ); } |