summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2000-01-12 18:47:22 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2000-01-12 18:47:22 +0000
commite38cb52d2d9544db77bbae4619ec15e0ee0d0b86 (patch)
tree0c70d5ec0a2043c22694d2aafe74f1ec406b2616 /cpukit/posix
parent+ Modified return codes (diff)
downloadrtems-e38cb52d2d9544db77bbae4619ec15e0ee0d0b86.tar.bz2
Debugged and yellow line tested routines.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/mqueuesendsupp.c34
-rw-r--r--cpukit/posix/src/mqueuesetattr.c40
-rw-r--r--cpukit/posix/src/mqueuetranslatereturncode.c38
3 files changed, 71 insertions, 41 deletions
diff --git a/cpukit/posix/src/mqueuesendsupp.c b/cpukit/posix/src/mqueuesendsupp.c
index 8029b6c03f..ec82a058f2 100644
--- a/cpukit/posix/src/mqueuesendsupp.c
+++ b/cpukit/posix/src/mqueuesendsupp.c
@@ -71,7 +71,7 @@ int _POSIX_Message_queue_Send_support(
set_errno_and_return_minus_one( EBADF );
}
- status = _CORE_message_queue_Submit(
+ _CORE_message_queue_Submit(
&the_mq->Message_queue,
(void *) msg_ptr,
msg_len,
@@ -81,30 +81,20 @@ int _POSIX_Message_queue_Send_support(
#else
NULL,
#endif
- _POSIX_Message_queue_Priority_to_core( msg_prio )
+ _POSIX_Message_queue_Priority_to_core( msg_prio ),
+ (the_mq->oflag & O_NONBLOCK) ? FALSE : TRUE,
+ timeout /* no timeout */
);
- if ( status != CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL ) {
- _Thread_Enable_dispatch();
- set_errno_and_return_minus_one(
- _POSIX_Message_queue_Translate_core_message_queue_return_code(status)
- );
- }
-
- /*
- * For now, we can't do a blocking send. So if we get here, it was
- * a successful send. The return code in the TCB won't be set by
- * the SuperCore since it does not support blocking mqueue sends.
- */
-
-#if 1
- _Thread_Enable_dispatch();
- return 0;
-#else
_Thread_Enable_dispatch();
- return _Thread_Executing->Wait.return_code;
-#endif
- }
+ if ( !_Thread_Executing->Wait.return_code )
+ return 0;
+ set_errno_and_return_minus_one(
+ _POSIX_Message_queue_Translate_core_message_queue_return_code(
+ _Thread_Executing->Wait.return_code
+ )
+ );
+ }
return POSIX_BOTTOM_REACHED();
}
diff --git a/cpukit/posix/src/mqueuesetattr.c b/cpukit/posix/src/mqueuesetattr.c
index 46507063a3..6cbdb2a638 100644
--- a/cpukit/posix/src/mqueuesetattr.c
+++ b/cpukit/posix/src/mqueuesetattr.c
@@ -40,18 +40,25 @@ int mq_setattr(
)
{
register POSIX_Message_queue_Control *the_mq;
+ CORE_message_queue_Control *the_core_mq;
Objects_Locations location;
CORE_message_queue_Attributes *the_mq_attr;
+ if ( !mqstat )
+ set_errno_and_return_minus_one( EINVAL );
+
the_mq = _POSIX_Message_queue_Get( mqdes, &location );
switch ( location ) {
case OBJECTS_ERROR:
- set_errno_and_return_minus_one( EINVAL );
+ set_errno_and_return_minus_one( EBADF );
case OBJECTS_REMOTE:
_Thread_Dispatch();
return POSIX_MP_NOT_IMPLEMENTED();
set_errno_and_return_minus_one( EINVAL );
case OBJECTS_LOCAL:
+
+ the_core_mq = &the_mq->Message_queue;
+
/*
* Return the old values.
*/
@@ -59,23 +66,28 @@ int mq_setattr(
/* XXX this is the same stuff as is in mq_getattr... and probably */
/* XXX should be in an inlined private routine */
- the_mq_attr = &the_mq->Message_queue.Attributes;
-
- omqstat->mq_flags = the_mq->flags;
- omqstat->mq_msgsize = the_mq->Message_queue.maximum_message_size;
- omqstat->mq_maxmsg = the_mq->Message_queue.maximum_pending_messages;
- omqstat->mq_curmsgs = the_mq->Message_queue.number_of_pending_messages;
+ if ( omqstat ) {
+ omqstat->mq_flags = the_mq->oflag;
+ omqstat->mq_msgsize = the_core_mq->maximum_message_size;
+ omqstat->mq_maxmsg = the_core_mq->maximum_pending_messages;
+ omqstat->mq_curmsgs = the_core_mq->number_of_pending_messages;
+ }
/*
- * Ignore everything except the O_NONBLOCK bit.
+ * If blocking was in effect and is not now, then there
+ * may be threads blocked on this message queue which need
+ * to be unblocked to make the state of the message queue
+ * consistent for future use.
*/
-
- if ( mqstat->mq_flags & O_NONBLOCK )
- the_mq->blocking = FALSE;
- else
- the_mq->blocking = TRUE;
- the_mq->flags = mqstat->mq_flags;
+ the_mq_attr = &the_core_mq->Attributes;
+
+ if ( !(the_mq->oflag & O_NONBLOCK) && /* were blocking */
+ (mqstat->mq_flags & O_NONBLOCK) ) { /* and now are not */
+ _CORE_message_queue_Flush_waiting_threads( the_core_mq );
+ }
+
+ the_mq->oflag = mqstat->mq_flags;
_Thread_Enable_dispatch();
return 0;
diff --git a/cpukit/posix/src/mqueuetranslatereturncode.c b/cpukit/posix/src/mqueuetranslatereturncode.c
index 2cdb4ab9b0..edc5e2954d 100644
--- a/cpukit/posix/src/mqueuetranslatereturncode.c
+++ b/cpukit/posix/src/mqueuetranslatereturncode.c
@@ -44,22 +44,50 @@ int _POSIX_Message_queue_Translate_core_message_queue_return_code(
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 ENOSYS; /* XXX */
+ return ENOMEM;
+
+ /*
+ * No message available on receive poll
+ */
case CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_NOWAIT:
- return ENOSYS; /* XXX */
+ 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 ENOSYS; /* XXX */
+ return ETIMEDOUT;
+
+ /*
+ * RTEMS POSIX API implementation does not support multiprocessing.
+ */
case THREAD_STATUS_PROXY_BLOCKING:
- return ENOSYS; /* XXX */
+ return ENOSYS;
}
- _Internal_error_Occurred( /* XXX */
+ _Internal_error_Occurred(
INTERNAL_ERROR_POSIX_API,
TRUE,
the_message_queue_status