summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src
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/posix/src
parenttestsuites: Fix locked_printf() test printer (diff)
downloadrtems-39bcf7417ea39806e4817a9ce72cfc20c060c4bf.tar.bz2
Fix semaphore post overflow status
Close #2720.
Diffstat (limited to 'cpukit/posix/src')
-rw-r--r--cpukit/posix/src/semaphoretranslatereturncode.c5
-rw-r--r--cpukit/posix/src/sempost.c14
2 files changed, 13 insertions, 6 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 )
+ );
}