From 3f72dda6ee518d3ea04341ad4df079ecb1895ef7 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 25 May 2016 08:37:28 +0200 Subject: posix: Fix pthread_spin_unlock() error status Update #2719. --- cpukit/posix/src/pspinlocktranslatereturncode.c | 3 +-- cpukit/score/include/rtems/score/corespinlockimpl.h | 8 ++------ cpukit/score/src/corespinlockrelease.c | 13 ++++--------- 3 files changed, 7 insertions(+), 17 deletions(-) (limited to 'cpukit') diff --git a/cpukit/posix/src/pspinlocktranslatereturncode.c b/cpukit/posix/src/pspinlocktranslatereturncode.c index af8c8acffa..6d3e9b05d8 100644 --- a/cpukit/posix/src/pspinlocktranslatereturncode.c +++ b/cpukit/posix/src/pspinlocktranslatereturncode.c @@ -31,8 +31,7 @@ static int _POSIX_Spinlock_Return_codes[CORE_SPINLOCK_STATUS_LAST + 1] = { EPERM, /* CORE_SPINLOCK_NOT_HOLDER */ -1, /* CORE_SPINLOCK_TIMEOUT */ EBUSY, /* CORE_SPINLOCK_IS_BUSY */ - EBUSY, /* CORE_SPINLOCK_UNAVAILABLE */ - 0 /* CORE_SPINLOCK_NOT_LOCKED */ + EBUSY /* CORE_SPINLOCK_UNAVAILABLE */ }; diff --git a/cpukit/score/include/rtems/score/corespinlockimpl.h b/cpukit/score/include/rtems/score/corespinlockimpl.h index fe6f9b67f5..057a469b05 100644 --- a/cpukit/score/include/rtems/score/corespinlockimpl.h +++ b/cpukit/score/include/rtems/score/corespinlockimpl.h @@ -56,15 +56,11 @@ typedef enum { /** This status indicates that the spinlock is currently locked and thus * unavailable. */ - CORE_SPINLOCK_UNAVAILABLE, - /** This status indicates that the spinlock is not currently locked and thus - * should not be released. - */ - CORE_SPINLOCK_NOT_LOCKED + CORE_SPINLOCK_UNAVAILABLE } CORE_spinlock_Status; /** This is a shorthand for the last status code. */ -#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_NOT_LOCKED +#define CORE_SPINLOCK_STATUS_LAST CORE_SPINLOCK_UNAVAILABLE /** This indicates the lock is available. */ #define CORE_SPINLOCK_UNLOCKED 0 diff --git a/cpukit/score/src/corespinlockrelease.c b/cpukit/score/src/corespinlockrelease.c index c10337a123..c0abcc109f 100644 --- a/cpukit/score/src/corespinlockrelease.c +++ b/cpukit/score/src/corespinlockrelease.c @@ -31,18 +31,13 @@ CORE_spinlock_Status _CORE_spinlock_Release( _ISR_Disable( level ); - /* - * It must locked before it can be unlocked. - */ - if ( the_spinlock->lock == CORE_SPINLOCK_UNLOCKED ) { - _ISR_Enable( level ); - return CORE_SPINLOCK_NOT_LOCKED; - } - /* * It must locked by the current thread before it can be unlocked. */ - if ( the_spinlock->holder != _Thread_Executing->Object.id ) { + if ( + the_spinlock->lock != CORE_SPINLOCK_LOCKED + || the_spinlock->holder != _Thread_Executing + ) { _ISR_Enable( level ); return CORE_SPINLOCK_NOT_HOLDER; } -- cgit v1.2.3