source: rtems/cpukit/rtems/src/clockgettod.c @ eaef4657

4.104.115
Last change on this file since eaef4657 was 3d66dfc1, checked in by Joel Sherrill <joel.sherrill@…>, on 12/16/08 at 17:36:01

2008-12-16 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/times.c, posix/src/adjtime.c, posix/src/clockgetres.c, posix/src/sysconf.c, rtems/src/clockgettickspersecond.c, rtems/src/clockgettod.c, rtems/src/clockset.c, rtems/src/clocktodvalidate.c, score/src/timespecfromticks.c, score/src/timespectoticks.c, score/src/ts64toticks.c: More case converted to use configuration table entry not _TOD_Microseconds_per_tick.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  Clock Manager - rtems_clock_get_tod
3 *
4 *  COPYRIGHT (c) 1989-2007.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <rtems/system.h>
19#include <rtems/config.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/clock.h>
22#include <rtems/score/isr.h>
23#include <rtems/score/thread.h>
24#include <rtems/score/tod.h>
25#include <rtems/score/watchdog.h>
26
27rtems_status_code rtems_clock_get_tod(
28  rtems_time_of_day  *time_buffer
29)
30{
31  rtems_time_of_day *tmbuf = time_buffer;
32  struct tm time;
33  struct timeval now;
34
35  if ( !time_buffer )
36    return RTEMS_INVALID_ADDRESS;
37
38  if ( !_TOD_Is_set )
39    return RTEMS_NOT_DEFINED;
40
41  /* Obtain the current time */
42  _TOD_Get_timeval( &now );
43
44  /* Split it into a closer format */
45  gmtime_r( &now.tv_sec, &time );
46
47  /* Now adjust it to the RTEMS format */
48  tmbuf->year   = time.tm_year + 1900;
49  tmbuf->month  = time.tm_mon + 1;
50  tmbuf->day    = time.tm_mday;
51  tmbuf->hour   = time.tm_hour;
52  tmbuf->minute = time.tm_min;
53  tmbuf->second = time.tm_sec;
54  tmbuf->ticks  = now.tv_usec /
55    rtems_configuration_get_microseconds_per_tick();
56 
57  return RTEMS_SUCCESSFUL;
58}
Note: See TracBrowser for help on using the repository browser.