summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/mqueuetranslatereturncode.c
diff options
context:
space:
mode:
authorGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-11-30 20:34:13 +0000
committerGlenn Humphrey <glenn.humphrey@oarcorp.com>2007-11-30 20:34:13 +0000
commit860c34e3a6e0f5c2a0d352e82cd438eebdaf0652 (patch)
treefc6301fd6e1f452046d78d0ed8714079c43b2c27 /cpukit/posix/src/mqueuetranslatereturncode.c
parent2007-11-30 Till Straumann <strauman@slac.stanford.edu> (diff)
downloadrtems-860c34e3a6e0f5c2a0d352e82cd438eebdaf0652.tar.bz2
2007-11-30 Glenn Humphrey <glenn.humphrey@OARcorp.com>
* posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/semaphore.h, posix/src/cancel.c, posix/src/conddestroy.c, posix/src/condsignalsupp.c, posix/src/condwaitsupp.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keysetspecific.c, posix/src/mqueueclose.c, posix/src/mqueuegetattr.c, posix/src/mqueuenotify.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuesetattr.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutexdestroy.c, posix/src/mutexgetprioceiling.c, posix/src/mutexinit.c, posix/src/mutexlocksupp.c, posix/src/mutexsetprioceiling.c, posix/src/mutexunlock.c, posix/src/pbarrierdestroy.c, posix/src/pbarriertranslatereturncode.c, posix/src/pbarrierwait.c, posix/src/prwlockdestroy.c, posix/src/prwlockrdlock.c, posix/src/prwlocktimedrdlock.c, posix/src/prwlocktimedwrlock.c, posix/src/prwlocktranslatereturncode.c, posix/src/prwlocktryrdlock.c, posix/src/prwlocktrywrlock.c, posix/src/prwlockunlock.c, posix/src/prwlockwrlock.c, posix/src/pspindestroy.c, posix/src/pspinlock.c, posix/src/pspinlocktranslatereturncode.c, posix/src/pspintrylock.c, posix/src/pspinunlock.c, posix/src/pthreaddetach.c, posix/src/pthreadequal.c, posix/src/pthreadgetschedparam.c, posix/src/pthreadjoin.c, posix/src/pthreadkill.c, posix/src/pthreadsetschedparam.c, posix/src/ptimer1.c, posix/src/semaphorewaitsupp.c, posix/src/semclose.c, posix/src/semdestroy.c, posix/src/semgetvalue.c, posix/src/sempost.c, posix/src/types.c, rtems/src/msgqtranslatereturncode.c, rtems/src/semobtain.c, rtems/src/timerfireafter.c, score/include/rtems/system.h, score/include/rtems/score/corebarrier.h, score/include/rtems/score/coremsg.h, score/include/rtems/score/coremutex.h, score/include/rtems/score/coresem.h: Restructed to move the OBJECTS_LOCAL case to the top of the switch statement and eliminate the fall-through return of POSIX_BOTTOM_REACHED. These changes produced simplier assembly code and allowed for complete test coverage. Also applied some consistency to the functions that translate the core status codes to POSIX status codes. * posix/src/mutextranslatereturncode.c, posix/src/semaphoretranslatereturncode.c: New files. * posix/src/mutexfromcorestatus.c: Removed.
Diffstat (limited to '')
-rw-r--r--cpukit/posix/src/mqueuetranslatereturncode.c87
1 files changed, 24 insertions, 63 deletions
diff --git a/cpukit/posix/src/mqueuetranslatereturncode.c b/cpukit/posix/src/mqueuetranslatereturncode.c
index 74e67d0cf7..9fe57a9920 100644
--- a/cpukit/posix/src/mqueuetranslatereturncode.c
+++ b/cpukit/posix/src/mqueuetranslatereturncode.c
@@ -1,8 +1,7 @@
/*
* POSIX Message Queue Error Translation
*
- *
- * COPYRIGHT (c) 1989-1999.
+ * COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -17,17 +16,10 @@
#endif
#include <pthread.h>
-#include <limits.h>
#include <errno.h>
-#include <fcntl.h>
-#include <mqueue.h>
#include <rtems/system.h>
-#include <rtems/score/watchdog.h>
-#include <rtems/seterr.h>
-#include <rtems/posix/mqueue.h>
-#include <rtems/posix/time.h>
-#include <rtems/score/interr.h>
+#include <rtems/score/coremsg.h>
/*PAGE
@@ -38,64 +30,33 @@
* the_message_queue_status - message_queue status code to translate
*
* Output parameters:
- * rtems status code - translated POSIX status code
+ * status code - translated POSIX status code
*
*/
+static
+ int _POSIX_Message_queue_Return_codes[CORE_MESSAGE_QUEUE_STATUS_LAST + 1] = {
+ 0, /* CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL */
+ EMSGSIZE, /* CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE */
+ EAGAIN, /* CORE_MESSAGE_QUEUE_STATUS_TOO_MANY */
+ ENOMEM, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED */
+ EAGAIN, /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT */
+ EBADF, /* CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED */
+ ETIMEDOUT, /* CORE_MESSAGE_QUEUE_STATUS_TIMEOUT */
+ ENOSYS /* CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT */
+};
+
+
int _POSIX_Message_queue_Translate_core_message_queue_return_code(
uint32_t the_message_queue_status
)
{
- switch ( the_message_queue_status ) {
- case CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL:
- return 0;
-
- /*
- * Bad message size
- */
- case CORE_MESSAGE_QUEUE_STATUS_INVALID_SIZE:
- return EMSGSIZE;
-
- /*
- * Queue is full of pending messages.
- */
- case CORE_MESSAGE_QUEUE_STATUS_TOO_MANY:
- return EAGAIN;
-
- /*
- * Out of message buffers to queue pending message
- */
- case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED:
- return ENOMEM;
-
- /*
- * No message available on receive poll
- */
- case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
- return EAGAIN;
-
- /*
- * Queue was deleted while thread blocked on it.
- */
- case CORE_MESSAGE_QUEUE_STATUS_WAS_DELETED:
- return EBADF;
-
- /*
- * POSIX Real-Time Extensions add timeouts to send and receive.
- */
- case CORE_MESSAGE_QUEUE_STATUS_TIMEOUT:
- return ETIMEDOUT;
-
- /*
- * RTEMS POSIX API implementation does not support multiprocessing.
- */
- case THREAD_STATUS_PROXY_BLOCKING:
- return ENOSYS;
- }
- _Internal_error_Occurred(
- INTERNAL_ERROR_POSIX_API,
- TRUE,
- the_message_queue_status
- );
- return POSIX_BOTTOM_REACHED();
+ /*
+ * Internal consistency check for bad status from SuperCore
+ */
+ #if defined(RTEMS_DEBUG)
+ if ( the_message_queue_status > CORE_MESSAGE_QUEUE_STATUS_LAST )
+ return EINVAL;
+ #endif
+ return _POSIX_Message_queue_Return_codes[the_message_queue_status];
}