Changes in uspace/lib/posix/src/time.c [cc36562b:5f97ef44] in mainline
- File:
-
- 1 edited
-
uspace/lib/posix/src/time.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/src/time.c
rcc36562b r5f97ef44 35 35 36 36 #include "internal/common.h" 37 #include "posix/sys/types.h"38 #include "posix/sys/time.h"39 37 #include "posix/time.h" 40 38 … … 49 47 #include "libc/malloc.h" 50 48 #include "libc/task.h" 49 #include "libc/stats.h" 51 50 #include "libc/stddef.h" 52 #include "libc/ time.h"51 #include "libc/sys/time.h" 53 52 54 53 // TODO: test everything in this file … … 220 219 case CLOCK_REALTIME: 221 220 res->tv_sec = 0; 222 res->tv_nsec = USEC2NSEC(1); /* Microsecond resolution. */221 res->tv_nsec = 1000; /* Microsecond resolution. */ 223 222 return 0; 224 223 default: … … 245 244 gettimeofday(&tv, NULL); 246 245 tp->tv_sec = tv.tv_sec; 247 tp->tv_nsec = USEC2NSEC(tv.tv_usec);246 tp->tv_nsec = tv.tv_usec * 1000; 248 247 return 0; 249 248 default: … … 301 300 } 302 301 if (rqtp->tv_nsec != 0) { 303 fibril_usleep( NSEC2USEC(rqtp->tv_nsec));302 fibril_usleep(rqtp->tv_nsec / 1000); 304 303 } 305 304 return 0; … … 310 309 } 311 310 312 int gettimeofday(struct timeval *tv, void *tz) 313 { 314 struct timespec ts; 315 316 getrealtime(&ts); 317 tv->tv_sec = ts.tv_sec; 318 tv->tv_usec = NSEC2USEC(ts.tv_nsec); 319 320 return 0; 311 /** 312 * Get CPU time used since the process invocation. 313 * 314 * @return Consumed CPU cycles by this process or -1 if not available. 315 */ 316 clock_t clock(void) 317 { 318 clock_t total_cycles = -1; 319 stats_task_t *task_stats = stats_get_task(task_get_id()); 320 if (task_stats) { 321 total_cycles = (clock_t) (task_stats->kcycles + 322 task_stats->ucycles); 323 free(task_stats); 324 task_stats = 0; 325 } 326 327 return total_cycles; 321 328 } 322 329
Note:
See TracChangeset
for help on using the changeset viewer.
