source: rtems/cpukit/posix/src/clocksettime.c @ be1b8a7

4.115
Last change on this file since be1b8a7 was 5cb175bb, checked in by Joel Sherrill <joel.sherrill@…>, on 01/10/13 at 19:22:31

cpukit/posix: Doxygen group is POSIXAPI

  • 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <time.h>
22#include <errno.h>
23
24#include <rtems/system.h>
25#include <rtems/score/isr.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/tod.h>
28
29#include <rtems/seterr.h>
30
31/*
32 *  14.2.1 Clocks, P1003.1b-1993, p. 263
33 */
34
35int clock_settime(
36  clockid_t              clock_id,
37  const struct timespec *tp
38)
39{
40  if ( !tp )
41    rtems_set_errno_and_return_minus_one( EINVAL );
42
43  if ( clock_id == CLOCK_REALTIME ) {
44    if ( tp->tv_sec < TOD_SECONDS_1970_THROUGH_1988 )
45      rtems_set_errno_and_return_minus_one( EINVAL );
46
47    _Thread_Disable_dispatch();
48      _TOD_Set( tp );
49    _Thread_Enable_dispatch();
50  }
51#ifdef _POSIX_CPUTIME
52  else if ( clock_id == CLOCK_PROCESS_CPUTIME_ID )
53    rtems_set_errno_and_return_minus_one( ENOSYS );
54#endif
55#ifdef _POSIX_THREAD_CPUTIME
56  else if ( clock_id == CLOCK_THREAD_CPUTIME_ID )
57    rtems_set_errno_and_return_minus_one( ENOSYS );
58#endif
59  else
60    rtems_set_errno_and_return_minus_one( EINVAL );
61
62  return 0;
63}
Note: See TracBrowser for help on using the repository browser.