Changeset 2b3dd78 in mainline for uspace/lib/posix/src/time.c
- Timestamp:
- 2018-01-31T12:02:00Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5595841
- Parents:
- a0a9cc2 (diff), 14d789c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/src/time.c
ra0a9cc2 r2b3dd78 34 34 */ 35 35 36 #define LIBPOSIX_INTERNAL37 #define __POSIX_DEF__(x) posix_##x38 39 36 #include "internal/common.h" 40 37 #include "posix/time.h" … … 70 67 * Set timezone conversion information. 71 68 */ 72 void posix_tzset(void)69 void tzset(void) 73 70 { 74 71 // TODO: read environment … … 80 77 81 78 /** 82 * Get the time in seconds83 *84 * @param t If t is non-NULL, the return value is also stored in the memory85 * pointed to by t.86 * @return On success, the value of time in seconds since the Epoch87 * is returned. On error, (time_t)-1 is returned.88 */89 time_t posix_time(time_t *t)90 {91 return time(t);92 }93 94 /**95 79 * Converts a time value to a broken-down UTC time. 96 80 * … … 99 83 * @return Value of result on success, NULL on overflow. 100 84 */ 101 struct tm * posix_gmtime_r(const time_t *restrict timer,85 struct tm *gmtime_r(const time_t *restrict timer, 102 86 struct tm *restrict result) 103 87 { … … 117 101 * the result, NULL in case of error. 118 102 */ 119 struct tm * posix_gmtime(const time_t *restrict timep)103 struct tm *gmtime(const time_t *restrict timep) 120 104 { 121 105 static struct tm result; 122 106 123 return posix_gmtime_r(timep, &result);107 return gmtime_r(timep, &result); 124 108 } 125 109 … … 131 115 * @return Value of result on success, NULL on overflow. 132 116 */ 133 struct tm * posix_localtime_r(const time_t *restrict timer,117 struct tm *localtime_r(const time_t *restrict timer, 134 118 struct tm *restrict result) 135 119 { 136 120 // TODO: deal with timezone 137 121 // currently assumes system and all times are in GMT 138 return posix_gmtime_r(timer, result);122 return gmtime_r(timer, result); 139 123 } 140 124 … … 147 131 * the result, NULL in case of error. 148 132 */ 149 struct tm * posix_localtime(const time_t *restrict timep)133 struct tm *localtime(const time_t *restrict timep) 150 134 { 151 135 static struct tm result; 152 136 153 return posix_localtime_r(timep, &result);137 return localtime_r(timep, &result); 154 138 } 155 139 … … 163 147 * @return Value of buf. 164 148 */ 165 char * posix_asctime_r(const struct tm *restrict timeptr,149 char *asctime_r(const struct tm *restrict timeptr, 166 150 char *restrict buf) 167 151 { … … 179 163 * the result, NULL in case of error. 180 164 */ 181 char * posix_asctime(const struct tm *restrict timeptr)165 char *asctime(const struct tm *restrict timeptr) 182 166 { 183 167 static char buf[ASCTIME_BUF_LEN]; 184 168 185 return posix_asctime_r(timeptr, buf);169 return asctime_r(timeptr, buf); 186 170 } 187 171 … … 195 179 * @return Pointer to buf on success, NULL on failure. 196 180 */ 197 char * posix_ctime_r(const time_t *timer, char *buf)181 char *ctime_r(const time_t *timer, char *buf) 198 182 { 199 183 if (failed(time_local2str(*timer, buf))) { … … 213 197 * the result, NULL in case of error. 214 198 */ 215 char * posix_ctime(const time_t *timep)199 char *ctime(const time_t *timep) 216 200 { 217 201 static char buf[ASCTIME_BUF_LEN]; 218 202 219 return posix_ctime_r(timep, buf);203 return ctime_r(timep, buf); 220 204 } 221 205 … … 227 211 * @return 0 on success, -1 with errno set on failure. 228 212 */ 229 int posix_clock_getres(posix_clockid_t clock_id, struct posix_timespec *res)213 int clock_getres(clockid_t clock_id, struct timespec *res) 230 214 { 231 215 assert(res != NULL); … … 249 233 * @return 0 on success, -1 with errno on failure. 250 234 */ 251 int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp)235 int clock_gettime(clockid_t clock_id, struct timespec *tp) 252 236 { 253 237 assert(tp != NULL); … … 275 259 * @return 0 on success, -1 with errno on failure. 276 260 */ 277 int posix_clock_settime(posix_clockid_t clock_id,278 const struct posix_timespec *tp)261 int clock_settime(clockid_t clock_id, 262 const struct timespec *tp) 279 263 { 280 264 assert(tp != NULL); … … 302 286 * @return 0 on success, -1 with errno set on failure. 303 287 */ 304 int posix_clock_nanosleep(posix_clockid_t clock_id, int flags,305 const struct posix_timespec *rqtp, struct posix_timespec *rmtp)288 int clock_nanosleep(clockid_t clock_id, int flags, 289 const struct timespec *rqtp, struct timespec *rmtp) 306 290 { 307 291 assert(rqtp != NULL); … … 329 313 * @return Consumed CPU cycles by this process or -1 if not available. 330 314 */ 331 posix_clock_t posix_clock(void)332 { 333 posix_clock_t total_cycles = -1;315 clock_t clock(void) 316 { 317 clock_t total_cycles = -1; 334 318 stats_task_t *task_stats = stats_get_task(task_get_id()); 335 319 if (task_stats) { 336 total_cycles = ( posix_clock_t) (task_stats->kcycles +320 total_cycles = (clock_t) (task_stats->kcycles + 337 321 task_stats->ucycles); 338 322 free(task_stats);
Note:
See TracChangeset
for help on using the changeset viewer.