[rtems commit] posix: Create timer implementation header

Sebastian Huber sebh at rtems.org
Mon Jul 22 14:51:44 UTC 2013


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jul 19 15:08:53 2013 +0200

posix: Create timer implementation header

Move implementation specific parts of timer.h and timer.inl into new
header file timerimpl.h.  The timer.h contains now only the application
visible API.

---

 cpukit/libcsupport/src/resource_snapshot.c   |    2 +-
 cpukit/posix/Makefile.am                     |    2 +-
 cpukit/posix/include/rtems/posix/timer.h     |   74 +-----------
 cpukit/posix/include/rtems/posix/timerimpl.h |  156 ++++++++++++++++++++++++++
 cpukit/posix/inline/rtems/posix/timer.inl    |   93 ---------------
 cpukit/posix/preinstall.am                   |    8 +-
 cpukit/posix/src/ptimer.c                    |    2 +-
 cpukit/posix/src/timercreate.c               |    2 +-
 cpukit/posix/src/timerdelete.c               |    2 +-
 cpukit/posix/src/timergetoverrun.c           |    2 +-
 cpukit/posix/src/timergettime.c              |    2 +-
 cpukit/posix/src/timerinserthelper.c         |    2 +-
 cpukit/posix/src/timersettime.c              |    2 +-
 cpukit/posix/src/timertsr.c                  |    2 +-
 cpukit/sapi/src/posixapi.c                   |    2 +-
 testsuites/psxtests/psxtimer01/psxtimer.c    |    1 +
 16 files changed, 179 insertions(+), 175 deletions(-)

diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c
index 6b875a8..48bbdc8 100644
--- a/cpukit/libcsupport/src/resource_snapshot.c
+++ b/cpukit/libcsupport/src/resource_snapshot.c
@@ -40,7 +40,7 @@
   #include <rtems/posix/rwlockimpl.h>
   #include <rtems/posix/semaphoreimpl.h>
   #include <rtems/posix/spinlock.h>
-  #include <rtems/posix/timer.h>
+  #include <rtems/posix/timerimpl.h>
 #endif
 
 static const Objects_Information *objects_info_table[] = {
diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am
index 6e69fdd..9bea73b 100644
--- a/cpukit/posix/Makefile.am
+++ b/cpukit/posix/Makefile.am
@@ -46,6 +46,7 @@ include_rtems_posix_HEADERS += include/rtems/posix/semaphoreimpl.h
 include_rtems_posix_HEADERS += include/rtems/posix/threadsup.h
 include_rtems_posix_HEADERS += include/rtems/posix/time.h
 include_rtems_posix_HEADERS += include/rtems/posix/timer.h
+include_rtems_posix_HEADERS += include/rtems/posix/timerimpl.h
 include_rtems_posix_HEADERS += include/rtems/posix/barrier.h
 include_rtems_posix_HEADERS += include/rtems/posix/barrierimpl.h
 include_rtems_posix_HEADERS += include/rtems/posix/rwlock.h
@@ -53,7 +54,6 @@ include_rtems_posix_HEADERS += include/rtems/posix/rwlockimpl.h
 include_rtems_posix_HEADERS += include/rtems/posix/spinlock.h
 
 include_rtems_posix_HEADERS += inline/rtems/posix/key.inl
-include_rtems_posix_HEADERS += inline/rtems/posix/timer.inl
 include_rtems_posix_HEADERS += inline/rtems/posix/spinlock.inl
 
 ## src
diff --git a/cpukit/posix/include/rtems/posix/timer.h b/cpukit/posix/include/rtems/posix/timer.h
index 0b70cc9..ff21df0 100644
--- a/cpukit/posix/include/rtems/posix/timer.h
+++ b/cpukit/posix/include/rtems/posix/timer.h
@@ -19,44 +19,21 @@
 #ifndef _RTEMS_POSIX_TIMER_H
 #define _RTEMS_POSIX_TIMER_H
 
-#include <rtems/posix/config.h>
 #include <rtems/score/object.h>
-#include <rtems/score/watchdog.h> /* Watchdog_Control */
+#include <rtems/score/watchdog.h>
 
-/**
- * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support
- *
- * @ingroup POSIXAPI
- */
-/**@{*/
+#include <pthread.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/* Timer is free */
-#define POSIX_TIMER_STATE_FREE        0x01
-
-/* Created timer but not running */
-#define POSIX_TIMER_STATE_CREATE_NEW  0x02
-
-/* Created timer and running */
-#define POSIX_TIMER_STATE_CREATE_RUN  0x03
-
-/* Created, ran and stopped timer */
-#define POSIX_TIMER_STATE_CREATE_STOP 0x04
-
-/* Indicates that the fire time is relative to the current one */
-#define POSIX_TIMER_RELATIVE       0
-
-/*
- * POSIX defines TIMER_ABSTIME but no constant for relative.  So
- * we have one internally but we need to be careful it has a different
- * value.
+/**
+ * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support
+ *
+ * @ingroup POSIXAPI
  */
-#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME)
-#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME"
-#endif
+/**@{*/
 
 /*
  * Data for a timer
@@ -73,43 +50,6 @@ typedef struct {
   struct timespec   time;       /* Time at which the timer was started   */
 } POSIX_Timer_Control;
 
-/*
- *  _POSIX_Timers_Manager_initialization
- *
- *  DESCRIPTION:
- *
- *  This routine performs the initialization necessary for this manager.
- */
-void _POSIX_Timer_Manager_initialization(void);
-
-/*
- *  @brief Operation that is run when a timer expires
- *
- *  Timer TSR
- */
-void _POSIX_Timer_TSR(Objects_Id timer, void *data);
-
-/*
- *  Watchdog Insert helper
- */
-bool _POSIX_Timer_Insert_helper(
-  Watchdog_Control               *timer,
-  Watchdog_Interval               ticks,
-  Objects_Id                      id,
-  Watchdog_Service_routine_entry  TSR,
-  void                           *arg
-);
-
-/*
- *  The following defines the information control block used to manage
- *  this class of objects.
- */
-POSIX_EXTERN Objects_Information  _POSIX_Timer_Information;
-
-#ifndef __RTEMS_APPLICATION__
-#include <rtems/posix/timer.inl>
-#endif
-
 /** @} */
 
 #ifdef __cplusplus
diff --git a/cpukit/posix/include/rtems/posix/timerimpl.h b/cpukit/posix/include/rtems/posix/timerimpl.h
new file mode 100644
index 0000000..73f953b
--- /dev/null
+++ b/cpukit/posix/include/rtems/posix/timerimpl.h
@@ -0,0 +1,156 @@
+/**
+ * @file
+ *
+ * @brief Inlined Routines from the POSIX Timer Manager
+ * 
+ * This file contains the static inline implementation of the inlined routines
+ * from the POSIX Timer Manager.
+ */
+
+/*
+ *  COPYRIGHT (c) 1989-2011.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ */
+
+#ifndef _RTEMS_POSIX_TIMERIMPL_H
+#define _RTEMS_POSIX_TIMERIMPL_H
+
+#include <rtems/posix/timer.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Timer is free */
+#define POSIX_TIMER_STATE_FREE        0x01
+
+/* Created timer but not running */
+#define POSIX_TIMER_STATE_CREATE_NEW  0x02
+
+/* Created timer and running */
+#define POSIX_TIMER_STATE_CREATE_RUN  0x03
+
+/* Created, ran and stopped timer */
+#define POSIX_TIMER_STATE_CREATE_STOP 0x04
+
+/* Indicates that the fire time is relative to the current one */
+#define POSIX_TIMER_RELATIVE       0
+
+/*
+ * POSIX defines TIMER_ABSTIME but no constant for relative.  So
+ * we have one internally but we need to be careful it has a different
+ * value.
+ */
+#if (POSIX_TIMER_RELATIVE == TIMER_ABSTIME)
+#error "POSIX_TIMER_RELATIVE == TIMER_ABSTIME"
+#endif
+
+/*
+ *  _POSIX_Timers_Manager_initialization
+ *
+ *  DESCRIPTION:
+ *
+ *  This routine performs the initialization necessary for this manager.
+ */
+void _POSIX_Timer_Manager_initialization(void);
+
+/*
+ *  @brief Operation that is run when a timer expires
+ *
+ *  Timer TSR
+ */
+void _POSIX_Timer_TSR(Objects_Id timer, void *data);
+
+/*
+ *  Watchdog Insert helper
+ */
+bool _POSIX_Timer_Insert_helper(
+  Watchdog_Control               *timer,
+  Watchdog_Interval               ticks,
+  Objects_Id                      id,
+  Watchdog_Service_routine_entry  TSR,
+  void                           *arg
+);
+
+/*
+ *  The following defines the information control block used to manage
+ *  this class of objects.
+ */
+POSIX_EXTERN Objects_Information  _POSIX_Timer_Information;
+
+/*
+ *  _POSIX_Timer_Allocate
+ *
+ *  DESCRIPTION:
+ *
+ *  This function allocates a timer control block from
+ *  the inactive chain of free timer control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
+{
+  return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
+}
+
+/*
+ *  _POSIX_Timer_Free
+ *
+ *  DESCRIPTION:
+ *
+ *  This routine frees a timer control block to the
+ *  inactive chain of free timer control blocks.
+ */
+
+RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
+  POSIX_Timer_Control *the_timer
+)
+{
+  _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
+}
+
+/*
+ *  _POSIX_Timer_Get
+ *
+ *  DESCRIPTION:
+ *
+ *  This function maps timer IDs to timer control blocks.
+ *  If ID corresponds to a local timer, then it returns
+ *  the timer control pointer which maps to ID and location
+ *  is set to OBJECTS_LOCAL.  Otherwise, location is set
+ *  to OBJECTS_ERROR and the returned value is undefined.
+ */
+
+RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
+  timer_t            id,
+  Objects_Locations *location
+)
+{
+  return (POSIX_Timer_Control *)
+    _Objects_Get( &_POSIX_Timer_Information, (Objects_Id) id, location );
+}
+
+/*
+ *  _POSIX_Timer_Is_null
+ *
+ *  DESCRIPTION:
+ *
+ *  This function returns TRUE if the_timer is NULL and FALSE otherwise.
+ */
+
+RTEMS_INLINE_ROUTINE bool _POSIX_Timer_Is_null (
+  POSIX_Timer_Control *the_timer
+)
+{
+  return (the_timer == NULL);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+/* end of include file */
diff --git a/cpukit/posix/inline/rtems/posix/timer.inl b/cpukit/posix/inline/rtems/posix/timer.inl
deleted file mode 100644
index bc1db80..0000000
--- a/cpukit/posix/inline/rtems/posix/timer.inl
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * @file
- *
- * @brief Inlined Routines from the POSIX Timer Manager
- * 
- * This file contains the static inline implementation of the inlined routines
- * from the POSIX Timer Manager.
- */
-
-/*
- *  COPYRIGHT (c) 1989-2011.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
- */
-
-#ifndef _RTEMS_POSIX_TIMER_H
-# error "Never use <rtems/posix/timer.inl> directly; include <rtems/posix/timer.h> instead."
-#endif
-
-#ifndef _RTEMS_POSIX_TIMER_INL
-#define _RTEMS_POSIX_TIMER_INL
-
-/*
- *  _POSIX_Timer_Allocate
- *
- *  DESCRIPTION:
- *
- *  This function allocates a timer control block from
- *  the inactive chain of free timer control blocks.
- */
-
-RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Allocate( void )
-{
-  return (POSIX_Timer_Control *) _Objects_Allocate( &_POSIX_Timer_Information );
-}
-
-/*
- *  _POSIX_Timer_Free
- *
- *  DESCRIPTION:
- *
- *  This routine frees a timer control block to the
- *  inactive chain of free timer control blocks.
- */
-
-RTEMS_INLINE_ROUTINE void _POSIX_Timer_Free (
-  POSIX_Timer_Control *the_timer
-)
-{
-  _Objects_Free( &_POSIX_Timer_Information, &the_timer->Object );
-}
-
-/*
- *  _POSIX_Timer_Get
- *
- *  DESCRIPTION:
- *
- *  This function maps timer IDs to timer control blocks.
- *  If ID corresponds to a local timer, then it returns
- *  the timer control pointer which maps to ID and location
- *  is set to OBJECTS_LOCAL.  Otherwise, location is set
- *  to OBJECTS_ERROR and the returned value is undefined.
- */
-
-RTEMS_INLINE_ROUTINE POSIX_Timer_Control *_POSIX_Timer_Get (
-  timer_t            id,
-  Objects_Locations *location
-)
-{
-  return (POSIX_Timer_Control *)
-    _Objects_Get( &_POSIX_Timer_Information, (Objects_Id) id, location );
-}
-
-/*
- *  _POSIX_Timer_Is_null
- *
- *  DESCRIPTION:
- *
- *  This function returns TRUE if the_timer is NULL and FALSE otherwise.
- */
-
-RTEMS_INLINE_ROUTINE bool _POSIX_Timer_Is_null (
-  POSIX_Timer_Control *the_timer
-)
-{
-  return (the_timer == NULL);
-}
-
-#endif
-/* end of include file */
diff --git a/cpukit/posix/preinstall.am b/cpukit/posix/preinstall.am
index 07e987a..7cb8ee8 100644
--- a/cpukit/posix/preinstall.am
+++ b/cpukit/posix/preinstall.am
@@ -128,6 +128,10 @@ $(PROJECT_INCLUDE)/rtems/posix/timer.h: include/rtems/posix/timer.h $(PROJECT_IN
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timer.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timer.h
 
+$(PROJECT_INCLUDE)/rtems/posix/timerimpl.h: include/rtems/posix/timerimpl.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timerimpl.h
+
 $(PROJECT_INCLUDE)/rtems/posix/barrier.h: include/rtems/posix/barrier.h $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/barrier.h
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/barrier.h
@@ -152,10 +156,6 @@ $(PROJECT_INCLUDE)/rtems/posix/key.inl: inline/rtems/posix/key.inl $(PROJECT_INC
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/key.inl
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/key.inl
 
-$(PROJECT_INCLUDE)/rtems/posix/timer.inl: inline/rtems/posix/timer.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
-	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/timer.inl
-PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/timer.inl
-
 $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl: inline/rtems/posix/spinlock.inl $(PROJECT_INCLUDE)/rtems/posix/$(dirstamp)
 	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/posix/spinlock.inl
diff --git a/cpukit/posix/src/ptimer.c b/cpukit/posix/src/ptimer.c
index 540fb71..5ce17d4 100644
--- a/cpukit/posix/src/ptimer.c
+++ b/cpukit/posix/src/ptimer.c
@@ -44,7 +44,7 @@
 #include <stdio.h>
 #include <signal.h>
 
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 /*
  * _POSIX_Timer_Manager_initialization
diff --git a/cpukit/posix/src/timercreate.c b/cpukit/posix/src/timercreate.c
index a8690b6..8316e58 100644
--- a/cpukit/posix/src/timercreate.c
+++ b/cpukit/posix/src/timercreate.c
@@ -29,7 +29,7 @@
 #include <rtems/score/thread.h>
 #include <rtems/posix/sigset.h>
 #include <rtems/posix/time.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 int timer_create(
   clockid_t        clock_id,
diff --git a/cpukit/posix/src/timerdelete.c b/cpukit/posix/src/timerdelete.c
index e17d48b..686dc78 100644
--- a/cpukit/posix/src/timerdelete.c
+++ b/cpukit/posix/src/timerdelete.c
@@ -28,7 +28,7 @@
 #include <rtems/seterr.h>
 #include <rtems/score/thread.h>
 #include <rtems/posix/time.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 
 int timer_delete(
diff --git a/cpukit/posix/src/timergetoverrun.c b/cpukit/posix/src/timergetoverrun.c
index 0708db4..fda4280 100644
--- a/cpukit/posix/src/timergetoverrun.c
+++ b/cpukit/posix/src/timergetoverrun.c
@@ -24,7 +24,7 @@
 #include <rtems/system.h>
 #include <rtems/seterr.h>
 #include <rtems/score/thread.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 int timer_getoverrun(
   timer_t   timerid
diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c
index a4b0f3a..b000ed4 100644
--- a/cpukit/posix/src/timergettime.c
+++ b/cpukit/posix/src/timergettime.c
@@ -28,7 +28,7 @@
 #include <rtems/score/thread.h>
 #include <rtems/score/tod.h>
 #include <rtems/score/timespec.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 /*
  *          - When a timer is initialized, the value of the time in
diff --git a/cpukit/posix/src/timerinserthelper.c b/cpukit/posix/src/timerinserthelper.c
index eddc455..66b3e9b 100644
--- a/cpukit/posix/src/timerinserthelper.c
+++ b/cpukit/posix/src/timerinserthelper.c
@@ -26,7 +26,7 @@
 #include <rtems/seterr.h>
 #include <rtems/score/isr.h>
 #include <rtems/score/watchdog.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 #include <rtems/posix/ptimer.h>
 
 bool _POSIX_Timer_Insert_helper(
diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c
index 678266a..ae29e3d 100644
--- a/cpukit/posix/src/timersettime.c
+++ b/cpukit/posix/src/timersettime.c
@@ -29,7 +29,7 @@
 #include <rtems/score/tod.h>
 #include <rtems/posix/time.h>
 #include <rtems/posix/ptimer.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 int timer_settime(
   timer_t                  timerid,
diff --git a/cpukit/posix/src/timertsr.c b/cpukit/posix/src/timertsr.c
index ad17ae9..eb6ca9f 100644
--- a/cpukit/posix/src/timertsr.c
+++ b/cpukit/posix/src/timertsr.c
@@ -30,7 +30,7 @@
 #include <rtems/score/tod.h>
 #include <rtems/posix/time.h>
 #include <rtems/posix/ptimer.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 
 /*
  *  This is the operation that is run when a timer expires
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index b460406..6cdffa7 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -39,7 +39,7 @@
 #include <rtems/posix/psignalimpl.h>
 #include <rtems/posix/pthreadimpl.h>
 #include <rtems/posix/rwlockimpl.h>
-#include <rtems/posix/timer.h>
+#include <rtems/posix/timerimpl.h>
 #include <rtems/posix/semaphoreimpl.h>
 #include <rtems/posix/spinlock.h>
 #include <rtems/posix/time.h>
diff --git a/testsuites/psxtests/psxtimer01/psxtimer.c b/testsuites/psxtests/psxtimer01/psxtimer.c
index 2f51d33..e055dea 100644
--- a/testsuites/psxtests/psxtimer01/psxtimer.c
+++ b/testsuites/psxtests/psxtimer01/psxtimer.c
@@ -32,6 +32,7 @@
 #include <sched.h>    /* schedule facilities */
 #include <time.h>     /* time facilities */
 #include <stdio.h>    /* console facilities */
+#include <rtems/posix/timerimpl.h>
 #include <rtems/score/timespec.h>
 #include "pritime.h"
 




More information about the vc mailing list