source: rtems/cpukit/score/src/coretodset.c @ d7c3883

4.115
Last change on this file since d7c3883 was aae7f1a1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/22/08 at 05:52:32

Eliminate TRUE/FALSE.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  Time of Day (TOD) Handler -- Set Time
3 */
4
5/*  COPYRIGHT (c) 1989-2007.
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/timestamp.h>
23#include <rtems/score/tod.h>
24#include <rtems/score/watchdog.h>
25
26/*PAGE
27 *
28 *  _TOD_Set
29 *
30 *  This rountine sets the current date and time with the specified
31 *  new date and time structure.
32 *
33 *  Input parameters:
34 *    time                - pointer to the time and date structure
35 *
36 *  Output parameters: NONE
37 */
38
39void _TOD_Set(
40  const struct timespec *time
41)
42{
43  long seconds;
44
45  _Thread_Disable_dispatch();
46  _TOD_Deactivate();
47
48  seconds = _TOD_Seconds_since_epoch();
49
50  if ( time->tv_sec < seconds )
51    _Watchdog_Adjust_seconds( WATCHDOG_BACKWARD, seconds - time->tv_sec );
52  else
53    _Watchdog_Adjust_seconds( WATCHDOG_FORWARD, time->tv_sec - seconds );
54
55  /* POSIX format TOD (timespec) */
56  _Timestamp_Set( &_TOD_Now, time->tv_sec, time->tv_nsec );
57  _TOD_Is_set = true;
58
59  _TOD_Activate();
60
61  _Thread_Enable_dispatch();
62}
Note: See TracBrowser for help on using the repository browser.