5
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 | |
---|
30 | int 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 | if ( tp->tv_sec < TOD_SECONDS_1970_THROUGH_1988 ) |
---|
40 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
41 | |
---|
42 | _TOD_Set_with_timespec( tp ); |
---|
43 | } |
---|
44 | #ifdef _POSIX_CPUTIME |
---|
45 | else if ( clock_id == CLOCK_PROCESS_CPUTIME_ID ) |
---|
46 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
47 | #endif |
---|
48 | #ifdef _POSIX_THREAD_CPUTIME |
---|
49 | else if ( clock_id == CLOCK_THREAD_CPUTIME_ID ) |
---|
50 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
51 | #endif |
---|
52 | else |
---|
53 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
54 | |
---|
55 | return 0; |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.