summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-25 14:23:48 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-26 21:44:30 +0200
commit39bcf7417ea39806e4817a9ce72cfc20c060c4bf (patch)
treedc05ee9c4d99d8eb98adae586c462e5e84227a1b /cpukit
parentdbedcf93f0209c2c1a21439fdb64a6a983390c8c (diff)
downloadrtems-39bcf7417ea39806e4817a9ce72cfc20c060c4bf.tar.bz2
Fix semaphore post overflow status
Close #2720.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/posix/src/semaphoretranslatereturncode.c5
-rw-r--r--cpukit/posix/src/sempost.c14
-rw-r--r--cpukit/rtems/src/semrelease.c1
-rw-r--r--cpukit/rtems/src/semtranslatereturncode.c2
-rw-r--r--cpukit/score/include/rtems/score/coresemimpl.h3
-rw-r--r--cpukit/score/src/mpci.c2
6 files changed, 18 insertions, 9 deletions
diff --git a/cpukit/posix/src/semaphoretranslatereturncode.c b/cpukit/posix/src/semaphoretranslatereturncode.c
index d7b99eaf67..04b293d349 100644
--- a/cpukit/posix/src/semaphoretranslatereturncode.c
+++ b/cpukit/posix/src/semaphoretranslatereturncode.c
@@ -27,8 +27,5 @@ const int _POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1] = {
EAGAIN, /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */
EINVAL, /* CORE_SEMAPHORE_WAS_DELETED */
ETIMEDOUT, /* CORE_SEMAPHORE_TIMEOUT */
- /* The next error can not occur since we set the maximum
- * count to the largest value the count can hold.
- */
- ENOSYS, /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
+ EOVERFLOW /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
};
diff --git a/cpukit/posix/src/sempost.c b/cpukit/posix/src/sempost.c
index 86d2f5acf6..f4633dcf70 100644
--- a/cpukit/posix/src/sempost.c
+++ b/cpukit/posix/src/sempost.c
@@ -19,6 +19,7 @@
#endif
#include <semaphore.h>
+#include <limits.h>
#include <rtems/posix/semaphoreimpl.h>
@@ -28,6 +29,7 @@ int sem_post(
{
POSIX_Semaphore_Control *the_semaphore;
Thread_queue_Context queue_context;
+ CORE_semaphore_Status status;
the_semaphore = _POSIX_Semaphore_Get( sem, &queue_context );
@@ -35,9 +37,17 @@ int sem_post(
rtems_set_errno_and_return_minus_one( EINVAL );
}
- _CORE_semaphore_Surrender(
+ status = _CORE_semaphore_Surrender(
&the_semaphore->Semaphore,
+ SEM_VALUE_MAX,
&queue_context
);
- return 0;
+
+ if ( status == CORE_SEMAPHORE_STATUS_SUCCESSFUL ) {
+ return 0;
+ }
+
+ rtems_set_errno_and_return_minus_one(
+ _POSIX_Semaphore_Translate_core_semaphore_return_code( status )
+ );
}
diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c
index 197e4d81b0..aa80e8385f 100644
--- a/cpukit/rtems/src/semrelease.c
+++ b/cpukit/rtems/src/semrelease.c
@@ -68,6 +68,7 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
} else {
semaphore_status = _CORE_semaphore_Surrender(
&the_semaphore->Core_control.semaphore,
+ UINT32_MAX,
&queue_context
);
return _Semaphore_Translate_core_semaphore_return_code( semaphore_status );
diff --git a/cpukit/rtems/src/semtranslatereturncode.c b/cpukit/rtems/src/semtranslatereturncode.c
index 9aa94206be..ea7e8bcb6b 100644
--- a/cpukit/rtems/src/semtranslatereturncode.c
+++ b/cpukit/rtems/src/semtranslatereturncode.c
@@ -37,5 +37,5 @@ const rtems_status_code _Semaphore_Translate_core_semaphore_return_code_[] = {
RTEMS_UNSATISFIED, /* CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT */
RTEMS_OBJECT_WAS_DELETED, /* CORE_SEMAPHORE_WAS_DELETED */
RTEMS_TIMEOUT, /* CORE_SEMAPHORE_TIMEOUT */
- RTEMS_INTERNAL_ERROR, /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
+ RTEMS_UNSATISFIED /* CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED */
};
diff --git a/cpukit/score/include/rtems/score/coresemimpl.h b/cpukit/score/include/rtems/score/coresemimpl.h
index 1660c1d089..5dad11bc46 100644
--- a/cpukit/score/include/rtems/score/coresemimpl.h
+++ b/cpukit/score/include/rtems/score/coresemimpl.h
@@ -149,6 +149,7 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Destroy(
*/
RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
CORE_semaphore_Control *the_semaphore,
+ uint32_t maximum_count,
Thread_queue_Context *queue_context
)
{
@@ -171,7 +172,7 @@ RTEMS_INLINE_ROUTINE CORE_semaphore_Status _CORE_semaphore_Surrender(
queue_context
);
} else {
- if ( the_semaphore->count < UINT32_MAX )
+ if ( the_semaphore->count < maximum_count )
the_semaphore->count += 1;
else
status = CORE_SEMAPHORE_MAXIMUM_COUNT_EXCEEDED;
diff --git a/cpukit/score/src/mpci.c b/cpukit/score/src/mpci.c
index 4022a800f1..3442bbd2c7 100644
--- a/cpukit/score/src/mpci.c
+++ b/cpukit/score/src/mpci.c
@@ -374,7 +374,7 @@ void _MPCI_Announce ( void )
Thread_queue_Context queue_context;
_ISR_lock_ISR_disable( &queue_context.Lock_context );
- (void) _CORE_semaphore_Surrender( &_MPCI_Semaphore, &queue_context );
+ (void) _CORE_semaphore_Surrender( &_MPCI_Semaphore, UINT32_MAX, &queue_context );
}
void _MPCI_Internal_packets_Send_process_packet (