From 3015ed641a41059dec9abad1eb3872a006ee6324 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 14 Dec 2015 16:33:39 +0100 Subject: Optional POSIX Message Queue initialization Update #2408. --- cpukit/posix/include/rtems/posix/mqueueimpl.h | 23 ++--------------------- cpukit/posix/src/mqueue.c | 13 ++++++++++++- cpukit/sapi/src/posixapi.c | 2 -- cpukit/score/include/rtems/sysinit.h | 1 + testsuites/sptests/spsysinit01/init.c | 17 +++++++++++++++++ 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h index 90269bf57b..6646fa2c65 100644 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h @@ -31,32 +31,13 @@ extern "C" { * This defines the information control block used to manage * this class of objects. */ -POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information; +extern Objects_Information _POSIX_Message_queue_Information; /** * The is used to manage the set of "file descriptors" associated with * the message queues. */ -POSIX_EXTERN Objects_Information _POSIX_Message_queue_Information_fds; - -/** - * @brief Initialize message_queue manager related data structures. - * - * This routine performs the initialization necessary for this manager. - * - * @note The structure of the routines is identical to that of POSIX - * Message_queues to leave the option of having unnamed message - * queues at a future date. They are currently not part of the - * POSIX standard but unnamed message_queues are. This is also - * the reason for the apparently unnecessary tracking of - * the process_shared attribute. [In addition to the fact that - * it would be trivial to add pshared to the mq_attr structure - * and have process private message queues.] - * - * @note This code ignores the O_RDONLY/O_WRONLY/O_RDWR flag at open time. - * - */ -void _POSIX_Message_queue_Manager_initialization(void); +extern Objects_Information _POSIX_Message_queue_Information_fds; /** * @brief POSIX Message Queue Create Support diff --git a/cpukit/posix/src/mqueue.c b/cpukit/posix/src/mqueue.c index 43878b708c..0f261f6947 100644 --- a/cpukit/posix/src/mqueue.c +++ b/cpukit/posix/src/mqueue.c @@ -28,10 +28,15 @@ #include #include +#include #include #include #include +Objects_Information _POSIX_Message_queue_Information; + +Objects_Information _POSIX_Message_queue_Information_fds; + /* * _POSIX_Message_queue_Manager_initialization * @@ -42,7 +47,7 @@ * Output parameters: NONE */ -void _POSIX_Message_queue_Manager_initialization(void) +static void _POSIX_Message_queue_Manager_initialization(void) { _Objects_Initialize_information( &_POSIX_Message_queue_Information, /* object information table */ @@ -76,3 +81,9 @@ void _POSIX_Message_queue_Manager_initialization(void) #endif ); } + +RTEMS_SYSINIT_ITEM( + _POSIX_Message_queue_Manager_initialization, + RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE, + RTEMS_SYSINIT_ORDER_MIDDLE +); diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c index da2b42b56c..8d99678196 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -61,7 +60,6 @@ void _POSIX_API_Initialize(void) _POSIX_Key_Manager_initialization(); #ifdef RTEMS_POSIX_API - _POSIX_Message_queue_Manager_initialization(); _POSIX_Semaphore_Manager_initialization(); _POSIX_Timer_Manager_initialization(); _POSIX_Barrier_Manager_initialization(); diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h index 1ca95a154d..bce999e60b 100644 --- a/cpukit/score/include/rtems/sysinit.h +++ b/cpukit/score/include/rtems/sysinit.h @@ -46,6 +46,7 @@ extern "C" { #define RTEMS_SYSINIT_POSIX_THREADS 000361 #define RTEMS_SYSINIT_POSIX_CONDITION_VARIABLE 000362 #define RTEMS_SYSINIT_POSIX_MUTEX 000363 +#define RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE 000364 #define RTEMS_SYSINIT_POSIX_CLEANUP 00036a #define RTEMS_SYSINIT_IDLE_THREADS 000380 #define RTEMS_SYSINIT_BSP_LIBC 000400 diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c index 39c4fbec49..9e97fdb1fb 100644 --- a/testsuites/sptests/spsysinit01/init.c +++ b/testsuites/sptests/spsysinit01/init.c @@ -29,6 +29,7 @@ #include #ifdef RTEMS_POSIX_API #include +#include #include #include #include @@ -92,6 +93,8 @@ typedef enum { POSIX_CONDITION_VARIABLE_POST, POSIX_MUTEX_PRE, POSIX_MUTEX_POST, + POSIX_MESSAGE_QUEUE_PRE, + POSIX_MESSAGE_QUEUE_POST, POSIX_CLEANUP_PRE, POSIX_CLEANUP_POST, #endif /* RTEMS_POSIX_API */ @@ -392,6 +395,18 @@ LAST(RTEMS_SYSINIT_POSIX_MUTEX) next_step(POSIX_MUTEX_POST); } +FIRST(RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE) +{ + assert(_POSIX_Message_queue_Information.maximum == 0); + next_step(POSIX_MESSAGE_QUEUE_PRE); +} + +LAST(RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE) +{ + assert(_POSIX_Message_queue_Information.maximum != 0); + next_step(POSIX_MESSAGE_QUEUE_POST); +} + static size_t user_extensions_pre_posix_cleanup; FIRST(RTEMS_SYSINIT_POSIX_CLEANUP) @@ -521,6 +536,8 @@ static void Init(rtems_task_argument arg) #ifdef RTEMS_POSIX_API +#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES 1 + #define CONFIGURE_MAXIMUM_POSIX_MUTEXES 1 #define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1 -- cgit v1.2.3