summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/clockget.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2007-04-02 18:23:59 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2007-04-02 18:23:59 +0000
commit812da546889eea0b6dea7eb2954f46a4c43d1314 (patch)
tree22fc95d921c3544de770454a2f9c604d5d0a27a2 /cpukit/rtems/src/clockget.c
parent2007-04-02 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-812da546889eea0b6dea7eb2954f46a4c43d1314.tar.bz2
2007-04-02 Joel Sherrill <joel@OARcorp.com>
* itron/src/itrontime.c, libcsupport/src/__gettod.c, posix/include/rtems/posix/time.h, posix/include/rtems/posix/timer.h, posix/src/clockgettime.c, posix/src/clocksettime.c, posix/src/nanosleep.c, posix/src/posixtimespecsubtract.c, posix/src/posixtimespectointerval.c, posix/src/ptimer1.c, posix/src/sleep.c, rtems/Makefile.am, rtems/include/rtems/rtems/clock.h, rtems/include/rtems/rtems/timer.h, rtems/include/rtems/rtems/types.h, rtems/src/clockget.c, rtems/src/clockset.c, rtems/src/clocktodtoseconds.c, rtems/src/clocktodvalidate.c, rtems/src/taskwakewhen.c, score/Makefile.am, score/include/rtems/score/tod.h, score/inline/rtems/score/tod.inl, score/src/coretod.c, score/src/coretodset.c: Convert from Classic API style TOD_Control as fundamental time structure to POSIX struct timespec. Add clock_get_uptime(). * rtems/src/clockgetuptime.c, score/src/coretodget.c, score/src/coretodgetuptime.c: New files. * score/src/coretodtickle.c, score/src/coretodtoseconds.c, score/src/coretodvalidate.c: Removed.
Diffstat (limited to 'cpukit/rtems/src/clockget.c')
-rw-r--r--cpukit/rtems/src/clockget.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/cpukit/rtems/src/clockget.c b/cpukit/rtems/src/clockget.c
index d8f808ce8e..f5948bcffd 100644
--- a/cpukit/rtems/src/clockget.c
+++ b/cpukit/rtems/src/clockget.c
@@ -46,20 +46,35 @@ rtems_status_code rtems_clock_get(
void *time_buffer
)
{
- ISR_Level level;
- rtems_interval tmp;
-
- if ( !time_buffer )
- return RTEMS_INVALID_ADDRESS;
+ if ( !time_buffer )
+ return RTEMS_INVALID_ADDRESS;
switch ( option ) {
- case RTEMS_CLOCK_GET_TOD:
+ case RTEMS_CLOCK_GET_TOD: {
+ struct tm time;
+ struct timeval now;
+ rtems_time_of_day *tmbuf = (rtems_time_of_day *)time_buffer;
+
if ( !_TOD_Is_set )
return RTEMS_NOT_DEFINED;
- *(rtems_time_of_day *)time_buffer = _TOD_Current;
+ /* Obtain the current time */
+ _TOD_Get_timeval( &now );
+
+ /* Split it into a closer format */
+ gmtime_r( &now.tv_sec, &time );
+
+ /* Now adjust it to the RTEMS format */
+ tmbuf->year = time.tm_year + 1900;
+ tmbuf->month = time.tm_mon + 1;
+ tmbuf->day = time.tm_mday;
+ tmbuf->hour = time.tm_hour;
+ tmbuf->minute = time.tm_min;
+ tmbuf->second = time.tm_sec;
+ tmbuf->ticks = now.tv_usec / _TOD_Microseconds_per_tick;
+
return RTEMS_SUCCESSFUL;
-
+ }
case RTEMS_CLOCK_GET_SECONDS_SINCE_EPOCH:
if ( !_TOD_Is_set )
return RTEMS_NOT_DEFINED;
@@ -75,20 +90,15 @@ rtems_status_code rtems_clock_get(
*(rtems_interval *)time_buffer = _TOD_Ticks_per_second;
return RTEMS_SUCCESSFUL;
- case RTEMS_CLOCK_GET_TIME_VALUE:
+ case RTEMS_CLOCK_GET_TIME_VALUE: {
+ struct timeval *time = (struct timeval *)time_buffer;
if ( !_TOD_Is_set )
return RTEMS_NOT_DEFINED;
- _ISR_Disable( level );
- ((rtems_clock_time_value *)time_buffer)->seconds =
- _TOD_Seconds_since_epoch;
- tmp = _TOD_Current.ticks;
- _ISR_Enable( level );
-
- tmp *= _TOD_Microseconds_per_tick;
- ((rtems_clock_time_value *)time_buffer)->microseconds = tmp;
+ _TOD_Get_timeval( time );
return RTEMS_SUCCESSFUL;
+ }
}
return RTEMS_INTERNAL_ERROR; /* should never get here */