source: rtems/cpukit/rtems/src/clockset.c @ 2256946

Last change on this file since 2256946 was 2256946, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 6, 2017 at 1:30:47 PM

score: Use struct timespec for TOD

Use the timestamps only for uptime based values. Use struct timespec
for the absolute time values (TOD).

Update #2740.

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Set the Current TOD
5 *  @ingroup ClassicClock
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/clock.h>
22#include <rtems/score/todimpl.h>
23#include <rtems/config.h>
24
25rtems_status_code rtems_clock_set(
26  const rtems_time_of_day *tod
27)
28{
29  if ( !tod )
30    return RTEMS_INVALID_ADDRESS;
31
32  if ( _TOD_Validate( tod ) ) {
33    struct timespec  tod_as_timespec;
34    ISR_lock_Context lock_context;
35
36    tod_as_timespec.tv_sec = _TOD_To_seconds( tod );
37    tod_as_timespec.tv_nsec = tod->ticks
38      * rtems_configuration_get_nanoseconds_per_tick();
39
40    _TOD_Lock();
41    _TOD_Acquire( &lock_context );
42    _TOD_Set( &tod_as_timespec, &lock_context );
43    _TOD_Unlock();
44
45    return RTEMS_SUCCESSFUL;
46  }
47
48  return RTEMS_INVALID_CLOCK;
49}
Note: See TracBrowser for help on using the repository browser.