Changeset 8d7aea0d in rtems
- Timestamp:
- 09/29/11 09:55:54 (12 years ago)
- Branches:
- 4.11, 5, master
- Children:
- 7cb170b3
- Parents:
- fe7cc1ea
- Location:
- cpukit
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/ChangeLog
rfe7cc1ea r8d7aea0d 1 2011-09-29 Sebastian Huber <sebastian.huber@embedded-brains.de> 2 3 * score/include/rtems/score/tod.h: Declare _TOD_Set_with_timestamp() 4 and _TOD_Get_as_timestamp(). 5 * score/src/coretodset.c: Define _TOD_Set_with_timestamp(). 6 * score/src/coretodget.c: Define _TOD_Get_as_timestamp(). 7 * rtems/src/clockset.c: Use _TOD_Set_with_timestamp(). 8 * score/include/rtems/score/timestamp64.h, score/src/ts64set.c: 9 Changed parameter types of _Timestamp64_Set(). 10 * rtems/src/clocktodtoseconds.c: Year 2100 is not a leap year. 11 1 12 2011-09-28 Sebastian Huber <sebastian.huber@embedded-brains.de> 2 13 -
cpukit/rtems/src/clockset.c
rfe7cc1ea r8d7aea0d 31 31 * 32 32 * Input parameters: 33 * t ime_buffer- pointer to the time and date structure33 * tod - pointer to the time and date structure 34 34 * 35 35 * Output parameters: … … 39 39 40 40 rtems_status_code rtems_clock_set( 41 const rtems_time_of_day *t ime_buffer41 const rtems_time_of_day *tod 42 42 ) 43 43 { 44 struct timespec newtime; 45 46 if ( !time_buffer ) 44 if ( !tod ) 47 45 return RTEMS_INVALID_ADDRESS; 48 46 49 if ( _TOD_Validate( time_buffer ) ) { 50 newtime.tv_sec = _TOD_To_seconds( time_buffer ); 51 newtime.tv_nsec = time_buffer->ticks * 52 rtems_configuration_get_nanoseconds_per_tick(); 47 if ( _TOD_Validate( tod ) ) { 48 Timestamp_Control tod_as_timestamp; 49 uint32_t seconds = _TOD_To_seconds( tod ); 50 uint32_t nanoseconds = tod->ticks 51 * rtems_configuration_get_nanoseconds_per_tick(); 52 53 _Timestamp_Set( &tod_as_timestamp, seconds, nanoseconds ); 53 54 54 55 _Thread_Disable_dispatch(); 55 _TOD_Set ( &newtime);56 _TOD_Set_with_timestamp( &tod_as_timestamp ); 56 57 _Thread_Enable_dispatch(); 58 57 59 return RTEMS_SUCCESSFUL; 58 60 } 61 59 62 return RTEMS_INVALID_CLOCK; 60 63 } -
cpukit/rtems/src/clocktodtoseconds.c
rfe7cc1ea r8d7aea0d 18 18 #include <rtems/system.h> 19 19 #include <rtems/rtems/clock.h> 20 21 #define TOD_SECONDS_AT_2100_03_01_00_00 4107538800UL 20 22 21 23 /* … … 79 81 time += the_tod->second; 80 82 83 /* The year 2100 is not a leap year */ 84 if ( time 85 >= (TOD_SECONDS_AT_2100_03_01_00_00 - TOD_SECONDS_1970_THROUGH_1988)) { 86 time -= TOD_SECONDS_PER_DAY; 87 } 88 81 89 time += TOD_SECONDS_1970_THROUGH_1988; 82 90 -
cpukit/score/include/rtems/score/timestamp64.h
rfe7cc1ea r8d7aea0d 56 56 static inline void _Timestamp64_implementation_Set( 57 57 Timestamp64_Control *_time, 58 long _seconds, 59 long _nanoseconds 60 ) 61 { 62 Timestamp64_Control _seconds64 = _seconds; 63 Timestamp64_Control _nanoseconds64 = _nanoseconds; 64 65 *_time = _seconds64 * 1000000000L + _nanoseconds64; 58 Timestamp64_Control _seconds, 59 Timestamp64_Control _nanoseconds 60 ) 61 { 62 *_time = _seconds * 1000000000L + _nanoseconds; 66 63 } 67 64 … … 82 79 void _Timestamp64_Set( 83 80 Timestamp64_Control *_time, 84 long_seconds,85 long_nanoseconds81 Timestamp64_Control _seconds, 82 Timestamp64_Control _nanoseconds 86 83 ); 87 84 #endif … … 407 404 ) 408 405 { 409 _timespec->tv_sec = *_timestamp / 1000000000L;410 _timespec->tv_nsec = *_timestamp % 1000000000L;406 _timespec->tv_sec = (time_t) (*_timestamp / 1000000000L); 407 _timespec->tv_nsec = (long) (*_timestamp % 1000000000L); 411 408 } 412 409 -
cpukit/score/include/rtems/score/tod.h
rfe7cc1ea r8d7aea0d 164 164 165 165 /** 166 * @brief _TOD_Set 167 * 168 * This routine sets the current time of day to @a time and 169 * the equivalent SECONDS_SINCE_EPOCH. 170 */ 171 void _TOD_Set( 172 const struct timespec *time 173 ); 174 175 /** 176 * @brief _TOD_Get 177 * 178 * This routine returns the current time of day with potential accuracy 179 * to the nanosecond. 180 * 181 * @param[in] time is a pointer to the time to be returned 182 */ 183 void _TOD_Get( 184 struct timespec *time 185 ); 166 * @brief Sets the time of day according to @a tod_as_timestamp. 167 * 168 * The @a tod_as_timestamp timestamp represents the time since UNIX epoch. The watchdog 169 * seconds chain will be adjusted. 170 */ 171 void _TOD_Set_with_timestamp( 172 const Timestamp_Control *tod_as_timestamp 173 ); 174 175 static inline void _TOD_Set( 176 const struct timespec *tod_as_timespec 177 ) 178 { 179 Timestamp_Control tod_as_timestamp; 180 181 _Timestamp_Set( 182 &tod_as_timestamp, 183 tod_as_timespec->tv_sec, 184 tod_as_timespec->tv_nsec 185 ); 186 _TOD_Set_with_timestamp( &tod_as_timestamp ); 187 } 188 189 /** 190 * @brief Returns the time of day in @a tod_as_timestamp. 191 * 192 * The @a tod_as_timestamp timestamp represents the time since UNIX epoch. 193 */ 194 void _TOD_Get_as_timestamp( 195 Timestamp_Control *tod_as_timestamp 196 ); 197 198 static inline void _TOD_Get( 199 struct timespec *tod_as_timespec 200 ) 201 { 202 Timestamp_Control tod_as_timestamp; 203 204 _TOD_Get_as_timestamp( &tod_as_timestamp ); 205 _Timestamp_To_timespec( &tod_as_timestamp, tod_as_timespec ); 206 } 186 207 187 208 /** -
cpukit/score/src/coretodget.c
rfe7cc1ea r8d7aea0d 23 23 #include <rtems/score/watchdog.h> 24 24 25 /* 26 * _TOD_Get 27 * 28 * This routine is used to obtain the current date and time. 29 * 30 * Input parameters: 31 * time - pointer to the time and date structure 32 * 33 * Output parameters: NONE 34 */ 35 36 void _TOD_Get( 37 struct timespec *time 25 void _TOD_Get_as_timestamp( 26 Timestamp_Control *tod 38 27 ) 39 28 { … … 53 42 _Timestamp_Set( &offset, 0, nanoseconds ); 54 43 _Timestamp_Add_to( &now, &offset ); 55 _Timestamp_To_timespec( &now, time ); 44 45 *tod = now; 56 46 } -
cpukit/score/src/coretodset.c
rfe7cc1ea r8d7aea0d 24 24 #include <rtems/score/watchdog.h> 25 25 26 /* 27 * _TOD_Set 28 * 29 * This rountine sets the current date and time with the specified 30 * new date and time structure. 31 * 32 * Input parameters: 33 * time - pointer to the time and date structure 34 * 35 * Output parameters: NONE 36 */ 37 38 void _TOD_Set( 39 const struct timespec *time 26 void _TOD_Set_with_timestamp( 27 const Timestamp_Control *tod 40 28 ) 41 29 { 42 long seconds; 30 Watchdog_Interval seconds_next = _Timestamp_Get_seconds( tod ); 31 Watchdog_Interval seconds_now; 43 32 44 33 _Thread_Disable_dispatch(); 45 34 _TOD_Deactivate(); 46 35 47 seconds = _TOD_Seconds_since_epoch();36 seconds_now = _TOD_Seconds_since_epoch(); 48 37 49 if ( time->tv_sec < seconds)50 _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds - time->tv_sec);38 if ( seconds_next < seconds_now ) 39 _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds_now - seconds_next ); 51 40 else 52 _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, time->tv_sec - seconds);41 _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, seconds_next - seconds_now ); 53 42 54 /* POSIX format TOD (timespec) */ 55 _Timestamp_Set( &_TOD_Now, time->tv_sec, time->tv_nsec ); 43 _TOD_Now = *tod; 56 44 _TOD_Is_set = true; 57 45 58 46 _TOD_Activate(); 59 60 47 _Thread_Enable_dispatch(); 61 48 } -
cpukit/score/src/ts64set.c
rfe7cc1ea r8d7aea0d 23 23 void _Timestamp64_Set( 24 24 Timestamp64_Control *_time, 25 long_seconds,26 long_nanoseconds25 Timestamp64_Control _seconds, 26 Timestamp64_Control _nanoseconds 27 27 ) 28 28 {
Note: See TracChangeset
for help on using the changeset viewer.