From c8982e5f6a4857444676165deab1e08dc91a6847 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 26 Apr 2016 21:20:31 +0200 Subject: posix: Simplify message queues The mq_open() function returns a descriptor to a POSIX message queue object identified by a name. This is similar to sem_open(). In contrast to the POSIX semaphore the POSIX message queues use a separate object for the descriptor. This extra object is superfluous, since the object identifier can be used directly for this purpose, just like for the semaphores. Update #2702. Update #2555. --- cpukit/posix/include/rtems/posix/config.h | 11 ---- cpukit/posix/include/rtems/posix/mqueue.h | 7 +-- cpukit/posix/include/rtems/posix/mqueueimpl.h | 89 +++++---------------------- 3 files changed, 17 insertions(+), 90 deletions(-) (limited to 'cpukit/posix/include') diff --git a/cpukit/posix/include/rtems/posix/config.h b/cpukit/posix/include/rtems/posix/config.h index 08d764b46a..636f1e7d79 100644 --- a/cpukit/posix/include/rtems/posix/config.h +++ b/cpukit/posix/include/rtems/posix/config.h @@ -92,17 +92,6 @@ typedef struct { */ uint32_t maximum_message_queues; - /** - * This field contains the maximum number of POSIX API - * message queue file descriptors which are configured - * for this application. - * - * @note There can be one or more file descriptors used with - * each message queue. This value should be greater than - * or equal to the number of message queues. - */ - uint32_t maximum_message_queue_descriptors; - /** * This field contains the maximum number of POSIX API * semaphores which are configured for this application. diff --git a/cpukit/posix/include/rtems/posix/mqueue.h b/cpukit/posix/include/rtems/posix/mqueue.h index df9daff999..cdf94514af 100644 --- a/cpukit/posix/include/rtems/posix/mqueue.h +++ b/cpukit/posix/include/rtems/posix/mqueue.h @@ -58,14 +58,9 @@ typedef struct { bool linked; uint32_t open_count; struct sigevent notification; + int oflag; } POSIX_Message_queue_Control; -typedef struct { - Objects_Control Object; - POSIX_Message_queue_Control *Queue; - int oflag; -} POSIX_Message_queue_Control_fd; - /** @} */ #ifdef __cplusplus diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h index 1cdf6191c7..491f716a47 100644 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h @@ -23,6 +23,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -33,12 +35,6 @@ extern "C" { */ extern Objects_Information _POSIX_Message_queue_Information; -/** - * The is used to manage the set of "file descriptors" associated with - * the message queues. - */ -extern Objects_Information _POSIX_Message_queue_Information_fds; - /** * @brief Delete a POSIX Message Queue * @@ -46,7 +42,8 @@ extern Objects_Information _POSIX_Message_queue_Information_fds; * doing most of the work involved with removing a message queue. */ void _POSIX_Message_queue_Delete( - POSIX_Message_queue_Control *the_mq + POSIX_Message_queue_Control *the_mq, + ISR_lock_Context *lock_context ); /*@ @@ -88,17 +85,11 @@ int _POSIX_Message_queue_Send_support( Watchdog_Interval timeout ); -/** - * @brief POSIX Message Queue Allocate - * - * This function allocates a message queue control block from - * the inactive chain of free message queue control blocks. - */ -RTEMS_INLINE_ROUTINE - POSIX_Message_queue_Control *_POSIX_Message_queue_Allocate( void ) +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * + _POSIX_Message_queue_Allocate_unprotected( void ) { return (POSIX_Message_queue_Control *) - _Objects_Allocate( &_POSIX_Message_queue_Information ); + _Objects_Allocate_unprotected( &_POSIX_Message_queue_Information ); } /** @@ -115,24 +106,13 @@ RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free( } -/** - * @brief POSIX Message Queue Get - * - * This function maps message queue IDs to message queue control blocks. - * If ID corresponds to a local message queue, then it returns - * the_mq control pointer which maps to ID and location - * is set to OBJECTS_LOCAL. if the message queue ID is global and - * resides on a remote node, then location is set to OBJECTS_REMOTE, - * and the_message queue is undefined. Otherwise, location is set - * to OBJECTS_ERROR and the_mq is undefined. - */ -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get ( - Objects_Id id, - Objects_Locations *location +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( + Objects_Id id, + ISR_lock_Context *lock_context ) { return (POSIX_Message_queue_Control *) - _Objects_Get( &_POSIX_Message_queue_Information, id, location ); + _Objects_Get_local( id, &_POSIX_Message_queue_Information, lock_context ); } /* @@ -171,26 +151,6 @@ RTEMS_INLINE_ROUTINE unsigned int _POSIX_Message_queue_Priority_from_core( int _POSIX_Message_queue_Translate_core_message_queue_return_code( uint32_t the_message_queue_status ); - -/** - * @brief POSIX Message Queue Allocate File Descriptor - */ -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd * - _POSIX_Message_queue_Allocate_fd( void ) -{ - return (POSIX_Message_queue_Control_fd *) - _Objects_Allocate( &_POSIX_Message_queue_Information_fds ); -} - -/** - * @brief POSIX Message Queue Free File Descriptor - */ -RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Free_fd ( - POSIX_Message_queue_Control_fd *the_mq_fd -) -{ - _Objects_Free( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object ); -} /** * @brief POSIX Message Queue Remove from Namespace @@ -202,33 +162,16 @@ RTEMS_INLINE_ROUTINE void _POSIX_Message_queue_Namespace_remove ( _Objects_Namespace_remove( &_POSIX_Message_queue_Information, &the_mq->Object ); } - -/* - * @brief POSIX Message Queue Get File Descriptor - */ -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd *_POSIX_Message_queue_Get_fd ( - mqd_t id, - Objects_Locations *location -) -{ - return (POSIX_Message_queue_Control_fd *) _Objects_Get( - &_POSIX_Message_queue_Information_fds, - (Objects_Id)id, - location - ); -} -RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control_fd * -_POSIX_Message_queue_Get_fd_interrupt_disable( +RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control * +_POSIX_Message_queue_Get_interrupt_disable( mqd_t id, - Objects_Locations *location, ISR_lock_Context *lock_context ) { - return (POSIX_Message_queue_Control_fd *) _Objects_Get_isr_disable( - &_POSIX_Message_queue_Information_fds, - (Objects_Id)id, - location, + return (POSIX_Message_queue_Control *) _Objects_Get_local( + (Objects_Id) id, + &_POSIX_Message_queue_Information, lock_context ); } -- cgit v1.2.3