source: rtems/cpukit/rtems/src/clockset.c @ 7c2f2448

4.115
Last change on this file since 7c2f2448 was 05c1886, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/30/09 at 16:01:51

Whitespace removal.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  Clock Manager
3 *
4 *  COPYRIGHT (c) 1989-1999.
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
27/*PAGE
28 *
29 *  rtems_clock_set
30 *
31 *  This directive sets the date and time for this node.
32 *
33 *  Input parameters:
34 *    time_buffer - pointer to the time and date structure
35 *
36 *  Output parameters:
37 *    RTEMS_SUCCESSFUL - if successful
38 *    error code        - if unsuccessful
39 */
40
41rtems_status_code rtems_clock_set(
42  rtems_time_of_day *time_buffer
43)
44{
45  struct timespec  newtime;
46
47  if ( !time_buffer )
48    return RTEMS_INVALID_ADDRESS;
49
50  if ( _TOD_Validate( time_buffer ) ) {
51    newtime.tv_sec = _TOD_To_seconds( time_buffer );
52    newtime.tv_nsec = time_buffer->ticks *
53      rtems_configuration_get_nanoseconds_per_tick();
54
55    _Thread_Disable_dispatch();
56      _TOD_Set( &newtime );
57    _Thread_Enable_dispatch();
58    return RTEMS_SUCCESSFUL;
59  }
60  return RTEMS_INVALID_CLOCK;
61}
Note: See TracBrowser for help on using the repository browser.