summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-09-29 09:55:54 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-09-29 09:55:54 +0000
commit8d7aea0d28cd7504ea406537040d1bbe2f634a29 (patch)
tree5f9247e2d03b415da2ea560334f8f70ed332be0d /cpukit/score/src
parent2011-09-29 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-8d7aea0d28cd7504ea406537040d1bbe2f634a29.tar.bz2
2011-09-29 Sebastian Huber <sebastian.huber@embedded-brains.de>
* score/include/rtems/score/tod.h: Declare _TOD_Set_with_timestamp() and _TOD_Get_as_timestamp(). * score/src/coretodset.c: Define _TOD_Set_with_timestamp(). * score/src/coretodget.c: Define _TOD_Get_as_timestamp(). * rtems/src/clockset.c: Use _TOD_Set_with_timestamp(). * score/include/rtems/score/timestamp64.h, score/src/ts64set.c: Changed parameter types of _Timestamp64_Set(). * rtems/src/clocktodtoseconds.c: Year 2100 is not a leap year.
Diffstat (limited to 'cpukit/score/src')
-rw-r--r--cpukit/score/src/coretodget.c18
-rw-r--r--cpukit/score/src/coretodset.c31
-rw-r--r--cpukit/score/src/ts64set.c4
3 files changed, 15 insertions, 38 deletions
diff --git a/cpukit/score/src/coretodget.c b/cpukit/score/src/coretodget.c
index 953f3cb753..79e7dfff5e 100644
--- a/cpukit/score/src/coretodget.c
+++ b/cpukit/score/src/coretodget.c
@@ -22,19 +22,8 @@
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
-/*
- * _TOD_Get
- *
- * This routine is used to obtain the current date and time.
- *
- * Input parameters:
- * time - pointer to the time and date structure
- *
- * Output parameters: NONE
- */
-
-void _TOD_Get(
- struct timespec *time
+void _TOD_Get_as_timestamp(
+ Timestamp_Control *tod
)
{
ISR_Level level;
@@ -52,5 +41,6 @@ void _TOD_Get(
_Timestamp_Set( &offset, 0, nanoseconds );
_Timestamp_Add_to( &now, &offset );
- _Timestamp_To_timespec( &now, time );
+
+ *tod = now;
}
diff --git a/cpukit/score/src/coretodset.c b/cpukit/score/src/coretodset.c
index 909e1fee7a..c8fe2ac351 100644
--- a/cpukit/score/src/coretodset.c
+++ b/cpukit/score/src/coretodset.c
@@ -23,39 +23,26 @@
#include <rtems/score/tod.h>
#include <rtems/score/watchdog.h>
-/*
- * _TOD_Set
- *
- * This rountine sets the current date and time with the specified
- * new date and time structure.
- *
- * Input parameters:
- * time - pointer to the time and date structure
- *
- * Output parameters: NONE
- */
-
-void _TOD_Set(
- const struct timespec *time
+void _TOD_Set_with_timestamp(
+ const Timestamp_Control *tod
)
{
- long seconds;
+ Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod );
+ Watchdog_Interval seconds_now;
_Thread_Disable_dispatch();
_TOD_Deactivate();
- seconds = _TOD_Seconds_since_epoch();
+ seconds_now = _TOD_Seconds_since_epoch();
- if ( time->tv_sec < seconds )
- _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds - time->tv_sec );
+ if ( seconds_next < seconds_now )
+ _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next );
else
- _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, time->tv_sec - seconds );
+ _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now );
- /* POSIX format TOD (timespec) */
- _Timestamp_Set( &_TOD_Now, time->tv_sec, time->tv_nsec );
+ _TOD_Now = *tod;
_TOD_Is_set = true;
_TOD_Activate();
-
_Thread_Enable_dispatch();
}
diff --git a/cpukit/score/src/ts64set.c b/cpukit/score/src/ts64set.c
index 2a3aaca8fe..ab03f13c47 100644
--- a/cpukit/score/src/ts64set.c
+++ b/cpukit/score/src/ts64set.c
@@ -22,8 +22,8 @@
#if CPU_TIMESTAMP_USE_INT64 == TRUE
void _Timestamp64_Set(
Timestamp64_Control *_time,
- long _seconds,
- long _nanoseconds
+ Timestamp64_Control _seconds,
+ Timestamp64_Control _nanoseconds
)
{
_Timestamp64_implementation_Set( _time, _seconds, _nanoseconds );