source: rtems/cpukit/score/src/coretodset.c @ 812da54

4.104.114.84.95
Last change on this file since 812da54 was 812da54, checked in by Joel Sherrill <joel.sherrill@…>, on 04/02/07 at 18:23:59

2007-04-02 Joel Sherrill <joel@…>

  • 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.
  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  Time of Day (TOD) Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/score/object.h>
21#include <rtems/score/thread.h>
22#include <rtems/score/tod.h>
23#include <rtems/score/watchdog.h>
24
25/*PAGE
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
38void _TOD_Set(
39  const struct timespec *time
40)
41{
42  _Thread_Disable_dispatch();
43  _TOD_Deactivate();
44
45  if ( time->tv_sec < _TOD_Seconds_since_epoch )
46    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD,
47       _TOD_Seconds_since_epoch - time->tv_sec );
48  else
49    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD,
50       time->tv_sec - _TOD_Seconds_since_epoch );
51
52  _TOD_Seconds_since_epoch = time->tv_sec;
53  _TOD_Is_set              = TRUE;
54
55  /* POSIX format TOD (timespec) */
56  _TOD_Now         = *time;
57  _TOD_Now.tv_sec += TOD_SECONDS_1970_THROUGH_1988;
58
59  _TOD_Activate( 0 );
60
61  _Thread_Enable_dispatch();
62}
Note: See TracBrowser for help on using the repository browser.