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