[rtems commit] Optional POSIX Timer initialization

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


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

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

Optional POSIX Timer initialization

Update #2408.

---

 cpukit/posix/include/rtems/posix/ptimer.h    |  7 -------
 cpukit/posix/include/rtems/posix/timerimpl.h |  9 +--------
 cpukit/posix/src/ptimer.c                    | 11 ++++++++++-
 cpukit/sapi/src/posixapi.c                   |  2 --
 cpukit/score/include/rtems/sysinit.h         |  1 +
 testsuites/sptests/spsysinit01/init.c        | 17 +++++++++++++++++
 6 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/ptimer.h b/cpukit/posix/include/rtems/posix/ptimer.h
index 16ac2b8..f6de4cc 100644
--- a/cpukit/posix/include/rtems/posix/ptimer.h
+++ b/cpukit/posix/include/rtems/posix/ptimer.h
@@ -36,13 +36,6 @@ extern "C" {
 #include <rtems/posix/config.h>
 
 /**
- *  @brief POSIX Timer Manager Initialization
- *
- *  This routine performs the initialization necessary for this manager.
- */
-void _POSIX_Timer_Manager_initialization(void);
-
-/**
  *  @brief Create a Per-Process Timer
  */
 int timer_create(
diff --git a/cpukit/posix/include/rtems/posix/timerimpl.h b/cpukit/posix/include/rtems/posix/timerimpl.h
index b297d32..8b5b42e 100644
--- a/cpukit/posix/include/rtems/posix/timerimpl.h
+++ b/cpukit/posix/include/rtems/posix/timerimpl.h
@@ -51,13 +51,6 @@ extern "C" {
 #endif
 
 /**
- *  @brief POSIX Timer Manager Initialization
- *
- *  This routine performs the initialization necessary for this manager.
- */
-void _POSIX_Timer_Manager_initialization(void);
-
-/**
  *  @brief POSIX Timer Manager Timer Service Routine Helper
  *
  *  This is the operation that is run when a timer expires.
@@ -79,7 +72,7 @@ bool _POSIX_Timer_Insert_helper(
  *  The following defines the information control block used to manage
  *  this class of objects.
  */
-POSIX_EXTERN Objects_Information  _POSIX_Timer_Information;
+extern Objects_Information _POSIX_Timer_Information;
 
 /**
  *  @brief POSIX Timer Allocate
diff --git a/cpukit/posix/src/ptimer.c b/cpukit/posix/src/ptimer.c
index a1e0637..810112a 100644
--- a/cpukit/posix/src/ptimer.c
+++ b/cpukit/posix/src/ptimer.c
@@ -33,6 +33,7 @@
 /************************************/
 
 #include <unistd.h>
+#include <rtems/sysinit.h>
 #include <rtems/rtems/status.h>
 #include <rtems/rtems/types.h>
 #include <rtems/rtems/timer.h>
@@ -44,6 +45,8 @@
 
 #include <rtems/posix/timerimpl.h>
 
+Objects_Information _POSIX_Timer_Information;
+
 /*
  * _POSIX_Timer_Manager_initialization
  *
@@ -53,7 +56,7 @@
  *  the timers are stored
  */
 
-void _POSIX_Timer_Manager_initialization(void)
+static void _POSIX_Timer_Manager_initialization(void)
 {
   _Objects_Initialize_information(
     &_POSIX_Timer_Information,  /* object information table */
@@ -72,3 +75,9 @@ void _POSIX_Timer_Manager_initialization(void)
 #endif
   );
 }
+
+RTEMS_SYSINIT_ITEM(
+  _POSIX_Timer_Manager_initialization,
+  RTEMS_SYSINIT_POSIX_TIMER,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index f1997bf..f645946 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -36,7 +36,6 @@
 #include <rtems/posix/priorityimpl.h>
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/rwlockimpl.h>
-#include <rtems/posix/timerimpl.h>
 #include <rtems/posix/spinlockimpl.h>
 #endif
 
@@ -59,7 +58,6 @@ void _POSIX_API_Initialize(void)
   _POSIX_Key_Manager_initialization();
 
   #ifdef RTEMS_POSIX_API
-    _POSIX_Timer_Manager_initialization();
     _POSIX_Barrier_Manager_initialization();
     _POSIX_RWLock_Manager_initialization();
     _POSIX_Spinlock_Manager_initialization();
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index b32723c..95865c4 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -48,6 +48,7 @@ extern "C" {
 #define RTEMS_SYSINIT_POSIX_MUTEX                000363
 #define RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE        000364
 #define RTEMS_SYSINIT_POSIX_SEMAPHORE            000365
+#define RTEMS_SYSINIT_POSIX_TIMER                000366
 #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 6854d70..1679cb6 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -34,6 +34,7 @@
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/semaphoreimpl.h>
+#include <rtems/posix/timerimpl.h>
 #endif /* RTEMS_POSIX_API */
 #include <rtems/rtems/barrierimpl.h>
 #include <rtems/rtems/dpmemimpl.h>
@@ -98,6 +99,8 @@ typedef enum {
   POSIX_MESSAGE_QUEUE_POST,
   POSIX_SEMAPHORE_PRE,
   POSIX_SEMAPHORE_POST,
+  POSIX_TIMER_PRE,
+  POSIX_TIMER_POST,
   POSIX_CLEANUP_PRE,
   POSIX_CLEANUP_POST,
 #endif /* RTEMS_POSIX_API */
@@ -422,6 +425,18 @@ LAST(RTEMS_SYSINIT_POSIX_SEMAPHORE)
   next_step(POSIX_SEMAPHORE_POST);
 }
 
+FIRST(RTEMS_SYSINIT_POSIX_TIMER)
+{
+  assert(_POSIX_Timer_Information.maximum == 0);
+  next_step(POSIX_TIMER_PRE);
+}
+
+LAST(RTEMS_SYSINIT_POSIX_TIMER)
+{
+  assert(_POSIX_Timer_Information.maximum != 0);
+  next_step(POSIX_TIMER_POST);
+}
+
 static size_t user_extensions_pre_posix_cleanup;
 
 FIRST(RTEMS_SYSINIT_POSIX_CLEANUP)
@@ -559,6 +574,8 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
 
+#define CONFIGURE_MAXIMUM_POSIX_TIMERS 1
+
 #define CONFIGURE_MAXIMUM_POSIX_THREADS 1
 
 #endif /* RTEMS_POSIX_API */



More information about the vc mailing list