source: rtems/cpukit/posix/src/clocksettime.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.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Set Time of Clock
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
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 <time.h>
22
23#include <rtems/score/todimpl.h>
24#include <rtems/seterr.h>
25
26/*
27 *  14.2.1 Clocks, P1003.1b-1993, p. 263
28 */
29
30int clock_settime(
31  clockid_t              clock_id,
32  const struct timespec *tp
33)
34{
35  if ( !tp )
36    rtems_set_errno_and_return_minus_one( EINVAL );
37
38  if ( clock_id == CLOCK_REALTIME ) {
39    ISR_lock_Context lock_context;
40
41    if ( tp->tv_sec < TOD_SECONDS_1970_THROUGH_1988 )
42      rtems_set_errno_and_return_minus_one( EINVAL );
43
44    _TOD_Lock();
45    _TOD_Acquire( &lock_context );
46    _TOD_Set( tp, &lock_context );
47    _TOD_Unlock();
48  }
49#ifdef _POSIX_CPUTIME
50  else if ( clock_id == CLOCK_PROCESS_CPUTIME_ID )
51    rtems_set_errno_and_return_minus_one( ENOSYS );
52#endif
53#ifdef _POSIX_THREAD_CPUTIME
54  else if ( clock_id == CLOCK_THREAD_CPUTIME_ID )
55    rtems_set_errno_and_return_minus_one( ENOSYS );
56#endif
57  else
58    rtems_set_errno_and_return_minus_one( EINVAL );
59
60  return 0;
61}
Note: See TracBrowser for help on using the repository browser.