source: rtems/cpukit/rtems/src/clockset.c @ 33c0f97

4.115
Last change on this file since 33c0f97 was 33c0f97, checked in by Sebastian Huber <sebastian.huber@…>, on 09/28/11 at 15:46:13

2011-09-28 Sebastian Huber <sebastian.huber@…>

  • rtems/include/rtems/rtems/clock.h, rtems/src/clockset.c: Added const qualifier in rtems_clock_set().
  • 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/*
28 *  rtems_clock_set
29 *
30 *  This directive sets the date and time for this node.
31 *
32 *  Input parameters:
33 *    time_buffer - pointer to the time and date structure
34 *
35 *  Output parameters:
36 *    RTEMS_SUCCESSFUL - if successful
37 *    error code        - if unsuccessful
38 */
39
40rtems_status_code rtems_clock_set(
41  const rtems_time_of_day *time_buffer
42)
43{
44  struct timespec  newtime;
45
46  if ( !time_buffer )
47    return RTEMS_INVALID_ADDRESS;
48
49  if ( _TOD_Validate( time_buffer ) ) {
50    newtime.tv_sec = _TOD_To_seconds( time_buffer );
51    newtime.tv_nsec = time_buffer->ticks *
52      rtems_configuration_get_nanoseconds_per_tick();
53
54    _Thread_Disable_dispatch();
55      _TOD_Set( &newtime );
56    _Thread_Enable_dispatch();
57    return RTEMS_SUCCESSFUL;
58  }
59  return RTEMS_INVALID_CLOCK;
60}
Note: See TracBrowser for help on using the repository browser.