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

4.104.114.9
Last change on this file since e889a857 was e889a857, checked in by Joel Sherrill <joel.sherrill@…>, on Feb 1, 2008 at 12:44:15 AM

2008-01-31 Joel Sherrill <joel.sherrill@…>

  • posix/src/clockgettime.c, posix/src/clocksettime.c, Minor modifications to improve testability.
  • posix/src/pthreadcreate.c: Add NULL check for thread entry.
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2007.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <time.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/score/isr.h>
21#include <rtems/score/thread.h>
22#include <rtems/score/tod.h>
23
24#include <rtems/seterr.h>
25
26/*PAGE
27 *
28 *  14.2.1 Clocks, P1003.1b-1993, p. 263
29 */
30
31int clock_settime(
32  clockid_t              clock_id,
33  const struct timespec *tp
34)
35{
36  if ( !tp )
37    rtems_set_errno_and_return_minus_one( EINVAL );
38
39  if ( clock_id == CLOCK_REALTIME ) {
40    if ( tp->tv_sec < TOD_SECONDS_1970_THROUGH_1988 )
41      rtems_set_errno_and_return_minus_one( EINVAL );
42
43    _Thread_Disable_dispatch();
44      _TOD_Set( tp );
45    _Thread_Enable_dispatch();
46  }
47#ifdef _POSIX_CPUTIME
48  else if ( clock_id == CLOCK_PROCESS_CPUTIME )
49    rtems_set_errno_and_return_minus_one( ENOSYS );
50#endif
51#ifdef _POSIX_THREAD_CPUTIME
52  else if ( clock_id == CLOCK_THREAD_CPUTIME )
53    rtems_set_errno_and_return_minus_one( ENOSYS );
54#endif
55  else
56    rtems_set_errno_and_return_minus_one( EINVAL );
57
58  return 0;
59}
Note: See TracBrowser for help on using the repository browser.