summaryrefslogtreecommitdiff
path: root/cpukit/score/src/coretodset.c
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/coretodset.c
parentfe7cc1eac729f909ca7c75aa071bdfdab28ca5a8 (diff)
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/coretodset.c')
-rw-r--r--cpukit/score/src/coretodset.c31
1 files changed, 9 insertions, 22 deletions
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();
}