From f17c7798288c530cda114db266dd6790c70f8b28 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 19 Jul 2013 15:08:53 +0200 Subject: 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(-) create mode 100644 cpukit/posix/include/rtems/posix/timerimpl.h delete mode 100644 cpukit/posix/inline/rtems/posix/timer.inl diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c index 6b875a8487..48bbdc8306 100644 --- a/cpukit/libcsupport/src/resource_snapshot.c +++ b/cpukit/libcsupport/src/resource_snapshot.c @@ -40,7 +40,7 @@ #include #include #include - #include + #include #endif static const Objects_Information *objects_info_table[] = { diff --git a/cpukit/posix/Makefile.am b/cpukit/posix/Makefile.am index 6e69fdd6bd..9bea73b56c 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 0b70cc9950..ff21df0295 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 #include -#include /* Watchdog_Control */ +#include -/** - * @defgroup POSIX_INTERNAL_TIMERS POSIX Timer Private Support - * - * @ingroup POSIXAPI - */ -/**@{*/ +#include #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 -#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 0000000000..73f953b45e --- /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 + +#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 bc1db80c88..0000000000 --- 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 directly; include 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 07e987aac2..7cb8ee8348 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 540fb71cef..5ce17d4e21 100644 --- a/cpukit/posix/src/ptimer.c +++ b/cpukit/posix/src/ptimer.c @@ -44,7 +44,7 @@ #include #include -#include +#include /* * _POSIX_Timer_Manager_initialization diff --git a/cpukit/posix/src/timercreate.c b/cpukit/posix/src/timercreate.c index a8690b6699..8316e58398 100644 --- a/cpukit/posix/src/timercreate.c +++ b/cpukit/posix/src/timercreate.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include int timer_create( clockid_t clock_id, diff --git a/cpukit/posix/src/timerdelete.c b/cpukit/posix/src/timerdelete.c index e17d48b181..686dc78f1d 100644 --- a/cpukit/posix/src/timerdelete.c +++ b/cpukit/posix/src/timerdelete.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include int timer_delete( diff --git a/cpukit/posix/src/timergetoverrun.c b/cpukit/posix/src/timergetoverrun.c index 0708db4f7d..fda4280dd9 100644 --- a/cpukit/posix/src/timergetoverrun.c +++ b/cpukit/posix/src/timergetoverrun.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include int timer_getoverrun( timer_t timerid diff --git a/cpukit/posix/src/timergettime.c b/cpukit/posix/src/timergettime.c index a4b0f3ae58..b000ed4b47 100644 --- a/cpukit/posix/src/timergettime.c +++ b/cpukit/posix/src/timergettime.c @@ -28,7 +28,7 @@ #include #include #include -#include +#include /* * - 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 eddc455f57..66b3e9b007 100644 --- a/cpukit/posix/src/timerinserthelper.c +++ b/cpukit/posix/src/timerinserthelper.c @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include bool _POSIX_Timer_Insert_helper( diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c index 678266ae3c..ae29e3d582 100644 --- a/cpukit/posix/src/timersettime.c +++ b/cpukit/posix/src/timersettime.c @@ -29,7 +29,7 @@ #include #include #include -#include +#include int timer_settime( timer_t timerid, diff --git a/cpukit/posix/src/timertsr.c b/cpukit/posix/src/timertsr.c index ad17ae91c2..eb6ca9fd89 100644 --- a/cpukit/posix/src/timertsr.c +++ b/cpukit/posix/src/timertsr.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include /* * 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 b460406ce2..6cdffa7a28 100644 --- a/cpukit/sapi/src/posixapi.c +++ b/cpukit/sapi/src/posixapi.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/testsuites/psxtests/psxtimer01/psxtimer.c b/testsuites/psxtests/psxtimer01/psxtimer.c index 2f51d33579..e055dea1c7 100644 --- a/testsuites/psxtests/psxtimer01/psxtimer.c +++ b/testsuites/psxtests/psxtimer01/psxtimer.c @@ -32,6 +32,7 @@ #include /* schedule facilities */ #include /* time facilities */ #include /* console facilities */ +#include #include #include "pritime.h" -- cgit v1.2.3