1 | /* time.c |
---|
2 | * |
---|
3 | * $Id$ |
---|
4 | */ |
---|
5 | |
---|
6 | #include <time.h> |
---|
7 | #include <rtems/score/tod.h> |
---|
8 | |
---|
9 | /* |
---|
10 | * Seconds from January 1, 1970 to January 1, 1988. Used to account for |
---|
11 | * differences between POSIX API and RTEMS core. |
---|
12 | */ |
---|
13 | |
---|
14 | #define POSIX_TIME_SECONDS_1970_THROUGH_1988 \ |
---|
15 | (((1987 - 1970 + 1) * TOD_SECONDS_PER_NON_LEAP_YEAR) + \ |
---|
16 | (4 * TOD_SECONDS_PER_DAY)) |
---|
17 | |
---|
18 | /* |
---|
19 | * 4.5.1 Get System Time, P1003.1b-1993, p. 91 |
---|
20 | */ |
---|
21 | |
---|
22 | time_t time( |
---|
23 | time_t *tloc |
---|
24 | ) |
---|
25 | { |
---|
26 | time_t seconds_since_epoch; |
---|
27 | |
---|
28 | if ( !_TOD_Is_set() ) { |
---|
29 | /* XXX set errno */ |
---|
30 | return -1; |
---|
31 | } |
---|
32 | |
---|
33 | /* |
---|
34 | * Internally the RTEMS epoch is 1988. This must be taken into account. |
---|
35 | */ |
---|
36 | |
---|
37 | seconds_since_epoch = _TOD_Seconds_since_epoch; |
---|
38 | |
---|
39 | seconds_since_epoch += POSIX_TIME_SECONDS_1970_THROUGH_1988; |
---|
40 | |
---|
41 | if ( tloc ) |
---|
42 | *tloc = seconds_since_epoch; |
---|
43 | |
---|
44 | return seconds_since_epoch; |
---|
45 | } |
---|
46 | |
---|
47 | #ifdef NOT_IMPLEMENTED_YET |
---|
48 | /* |
---|
49 | * 14.2.1 Clocks, P1003.1b-1993, p. 263 |
---|
50 | */ |
---|
51 | |
---|
52 | int clock_settime( |
---|
53 | clockid_t clock_id, |
---|
54 | const struct timespec *tp |
---|
55 | ) |
---|
56 | { |
---|
57 | return POSIX_NOT_IMPLEMENTED(); |
---|
58 | } |
---|
59 | |
---|
60 | /* |
---|
61 | * 14.2.1 Clocks, P1003.1b-1993, p. 263 |
---|
62 | */ |
---|
63 | |
---|
64 | int clock_gettime( |
---|
65 | clockid_t clock_id, |
---|
66 | struct timespec *tp |
---|
67 | ) |
---|
68 | { |
---|
69 | return POSIX_NOT_IMPLEMENTED(); |
---|
70 | } |
---|
71 | |
---|
72 | /* |
---|
73 | * 14.2.1 Clocks, P1003.1b-1993, p. 263 |
---|
74 | */ |
---|
75 | |
---|
76 | int clock_getres( |
---|
77 | clockid_t clock_id, |
---|
78 | struct timespec *res |
---|
79 | ) |
---|
80 | { |
---|
81 | return POSIX_NOT_IMPLEMENTED(); |
---|
82 | } |
---|
83 | |
---|
84 | /* |
---|
85 | * 14.2.2 Create a Per-Process Timer, P1003.1b-1993, p. 264 |
---|
86 | */ |
---|
87 | |
---|
88 | int timer_create( |
---|
89 | clockid_t clock_id, |
---|
90 | struct sigevent *evp, |
---|
91 | timer_t *timerid |
---|
92 | ) |
---|
93 | { |
---|
94 | return POSIX_NOT_IMPLEMENTED(); |
---|
95 | } |
---|
96 | |
---|
97 | /* |
---|
98 | * 14.2.3 Delete a Per_process Timer, P1003.1b-1993, p. 266 |
---|
99 | */ |
---|
100 | |
---|
101 | int timer_delete( |
---|
102 | timer_t timerid |
---|
103 | ) |
---|
104 | { |
---|
105 | return POSIX_NOT_IMPLEMENTED(); |
---|
106 | } |
---|
107 | |
---|
108 | /* |
---|
109 | * 14.2.4 Per-Process Timers, P1003.1b-1993, p. 267 |
---|
110 | */ |
---|
111 | |
---|
112 | int timer_settime( |
---|
113 | timer_t timerid, |
---|
114 | int flags, |
---|
115 | const struct itimerspec *value, |
---|
116 | struct itimerspec *ovalue |
---|
117 | ) |
---|
118 | { |
---|
119 | return POSIX_NOT_IMPLEMENTED(); |
---|
120 | } |
---|
121 | |
---|
122 | /* |
---|
123 | * 14.2.4 Per-Process Timers, P1003.1b-1993, p. 267 |
---|
124 | */ |
---|
125 | |
---|
126 | int timer_gettime( |
---|
127 | timer_t timerid, |
---|
128 | struct itimerspec *value |
---|
129 | ) |
---|
130 | { |
---|
131 | return POSIX_NOT_IMPLEMENTED(); |
---|
132 | } |
---|
133 | |
---|
134 | /* |
---|
135 | * 14.2.4 Per-Process Timers, P1003.1b-1993, p. 267 |
---|
136 | */ |
---|
137 | |
---|
138 | int timer_getoverrun( |
---|
139 | timer_t timerid |
---|
140 | ) |
---|
141 | { |
---|
142 | return POSIX_NOT_IMPLEMENTED(); |
---|
143 | } |
---|
144 | |
---|
145 | /* |
---|
146 | * 14.2.5 High Resolution Sleep, P1003.1b-1993, p. 269 |
---|
147 | */ |
---|
148 | |
---|
149 | int nanosleep( |
---|
150 | const struct timespec *rqtp, |
---|
151 | struct timespec *rmtp |
---|
152 | ) |
---|
153 | { |
---|
154 | return POSIX_NOT_IMPLEMENTED(); |
---|
155 | } |
---|
156 | |
---|
157 | /* |
---|
158 | * 20.1.3 Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 |
---|
159 | */ |
---|
160 | |
---|
161 | int clock_getcpuclockid( |
---|
162 | pid_t pid, |
---|
163 | clockid_t *clock_id |
---|
164 | ) |
---|
165 | { |
---|
166 | return POSIX_NOT_IMPLEMENTED(); |
---|
167 | } |
---|
168 | |
---|
169 | /* |
---|
170 | * 20.1.5 CPU-time Clock Attribute Access, P1003.4b/D8, p. 58 |
---|
171 | */ |
---|
172 | |
---|
173 | int clock_setenable_attr( |
---|
174 | clockid_t clock_id, |
---|
175 | int attr |
---|
176 | ) |
---|
177 | { |
---|
178 | return POSIX_NOT_IMPLEMENTED(); |
---|
179 | } |
---|
180 | |
---|
181 | /* |
---|
182 | * 20.1.5 CPU-time Clock Attribute Access, P1003.4b/D8, p. 58 |
---|
183 | */ |
---|
184 | |
---|
185 | int clock_getenable_attr( |
---|
186 | clockid_t clock_id, |
---|
187 | int *attr |
---|
188 | ) |
---|
189 | { |
---|
190 | return POSIX_NOT_IMPLEMENTED(); |
---|
191 | } |
---|
192 | |
---|
193 | #endif |
---|