[rtems commit] Optional POSIX Spinlock initialization

Sebastian Huber sebh at rtems.org
Wed Feb 3 09:34:12 UTC 2016


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

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

Optional POSIX Spinlock initialization

Update #2408.

---

 cpukit/posix/include/rtems/posix/spinlockimpl.h | 10 +---------
 cpukit/posix/src/pspin.c                        | 11 ++++++++++-
 cpukit/sapi/src/posixapi.c                      |  5 -----
 cpukit/score/include/rtems/sysinit.h            |  1 +
 testsuites/sptests/spsysinit01/init.c           | 17 +++++++++++++++++
 5 files changed, 29 insertions(+), 15 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/spinlockimpl.h b/cpukit/posix/include/rtems/posix/spinlockimpl.h
index 8a2f583..01fe372 100644
--- a/cpukit/posix/include/rtems/posix/spinlockimpl.h
+++ b/cpukit/posix/include/rtems/posix/spinlockimpl.h
@@ -34,15 +34,7 @@ extern "C" {
  * this class of objects.
  */
 
-POSIX_EXTERN Objects_Information  _POSIX_Spinlock_Information;
-
-/**
- * @brief POSIX spinlock manager initialization.
- *
- * This routine performs the initialization necessary for this manager.
- */
-
-void _POSIX_Spinlock_Manager_initialization(void);
+extern Objects_Information _POSIX_Spinlock_Information;
 
 /**
  * @brief Translate core spinlock status code.
diff --git a/cpukit/posix/src/pspin.c b/cpukit/posix/src/pspin.c
index 781420c..62e6f3a 100644
--- a/cpukit/posix/src/pspin.c
+++ b/cpukit/posix/src/pspin.c
@@ -21,12 +21,15 @@
 
 #include <rtems/system.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 #include <rtems/posix/spinlockimpl.h>
 
+Objects_Information _POSIX_Spinlock_Information;
+
 /**
  *  @brief _POSIX_Spinlock_Manager_initialization
  */
-void _POSIX_Spinlock_Manager_initialization(void)
+static void _POSIX_Spinlock_Manager_initialization(void)
 {
   _Objects_Initialize_information(
     &_POSIX_Spinlock_Information,    /* object information table */
@@ -44,3 +47,9 @@ void _POSIX_Spinlock_Manager_initialization(void)
 #endif
   );
 }
+
+RTEMS_SYSINIT_ITEM(
+  _POSIX_Spinlock_Manager_initialization,
+  RTEMS_SYSINIT_POSIX_SPINLOCK,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index 2ff526f..08b47de 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -34,7 +34,6 @@
 #include <rtems/posix/config.h>
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/posix/psignalimpl.h>
-#include <rtems/posix/spinlockimpl.h>
 #endif
 
 void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno )
@@ -54,8 +53,4 @@ void _POSIX_API_Initialize(void)
    */
 
   _POSIX_Key_Manager_initialization();
-
-  #ifdef RTEMS_POSIX_API
-    _POSIX_Spinlock_Manager_initialization();
-  #endif
 }
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index 27ee0c9..8f18764 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -51,6 +51,7 @@ extern "C" {
 #define RTEMS_SYSINIT_POSIX_TIMER                000366
 #define RTEMS_SYSINIT_POSIX_BARRIER              000367
 #define RTEMS_SYSINIT_POSIX_RWLOCK               000368
+#define RTEMS_SYSINIT_POSIX_SPINLOCK             000369
 #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 e5d6dc9..042c600 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -36,6 +36,7 @@
 #include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/rwlockimpl.h>
 #include <rtems/posix/semaphoreimpl.h>
+#include <rtems/posix/spinlockimpl.h>
 #include <rtems/posix/timerimpl.h>
 #endif /* RTEMS_POSIX_API */
 #include <rtems/rtems/barrierimpl.h>
@@ -107,6 +108,8 @@ typedef enum {
   POSIX_BARRIER_POST,
   POSIX_RWLOCK_PRE,
   POSIX_RWLOCK_POST,
+  POSIX_SPINLOCK_PRE,
+  POSIX_SPINLOCK_POST,
   POSIX_CLEANUP_PRE,
   POSIX_CLEANUP_POST,
 #endif /* RTEMS_POSIX_API */
@@ -467,6 +470,18 @@ LAST(RTEMS_SYSINIT_POSIX_RWLOCK)
   next_step(POSIX_RWLOCK_POST);
 }
 
+FIRST(RTEMS_SYSINIT_POSIX_SPINLOCK)
+{
+  assert(_POSIX_Spinlock_Information.maximum == 0);
+  next_step(POSIX_SPINLOCK_PRE);
+}
+
+LAST(RTEMS_SYSINIT_POSIX_SPINLOCK)
+{
+  assert(_POSIX_Spinlock_Information.maximum != 0);
+  next_step(POSIX_SPINLOCK_POST);
+}
+
 static size_t user_extensions_pre_posix_cleanup;
 
 FIRST(RTEMS_SYSINIT_POSIX_CLEANUP)
@@ -608,6 +623,8 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
 
+#define CONFIGURE_MAXIMUM_POSIX_SPINLOCKS 1
+
 #define CONFIGURE_MAXIMUM_POSIX_TIMERS 1
 
 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1




More information about the vc mailing list