From 8d7aea0d28cd7504ea406537040d1bbe2f634a29 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 29 Sep 2011 09:55:54 +0000 Subject: 2011-09-29 Sebastian Huber * 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. --- cpukit/score/src/coretodset.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'cpukit/score/src/coretodset.c') 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 #include -/* - * _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(); } -- cgit v1.2.3