[rtems commit] Optional POSIX Message Queue initialization

Sebastian Huber sebh at rtems.org
Wed Feb 3 09:33:19 UTC 2016


Module:    rtems
Branch:    master
Commit:    3015ed641a41059dec9abad1eb3872a006ee6324
Changeset: http://git.rtems.org/rtems/commit/?id=3015ed641a41059dec9abad1eb3872a006ee6324

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Dec 14 16:33:39 2015 +0100

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 90269bf..6646fa2 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 43878b7..0f261f6 100644
--- a/cpukit/posix/src/mqueue.c
+++ b/cpukit/posix/src/mqueue.c
@@ -28,10 +28,15 @@
 
 #include <rtems/system.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 #include <rtems/score/watchdog.h>
 #include <rtems/seterr.h>
 #include <rtems/posix/mqueueimpl.h>
 
+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 da2b42b..8d99678 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -33,7 +33,6 @@
 #include <rtems/config.h>
 #include <rtems/posix/barrierimpl.h>
 #include <rtems/posix/config.h>
-#include <rtems/posix/mqueueimpl.h>
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/rwlockimpl.h>
@@ -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 1ca95a1..bce999e 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 39c4fbe..9e97fdb 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -29,6 +29,7 @@
 #include <rtems/extensionimpl.h>
 #ifdef RTEMS_POSIX_API
 #include <rtems/posix/condimpl.h>
+#include <rtems/posix/mqueueimpl.h>
 #include <rtems/posix/muteximpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/pthreadimpl.h>
@@ -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




More information about the vc mailing list