diff options
| author | Bernard Xiong <[email protected]> | 2016-06-01 14:43:17 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2016-06-01 14:43:17 +0800 |
| commit | ceb3aa965715bf4dbec0620edb54977b082ad7a6 (patch) | |
| tree | cba311ed9c5511062580d01d14eeb68b0d2c9536 | |
| parent | c8b546bb783946aa56d39df48b9ed62f082c4286 (diff) | |
| parent | 0af00b9ce5104b66a328b45d27ab23d57ea11251 (diff) | |
Merge pull request #637 from weety/timer_fixed
Fixed time unit error.
| -rw-r--r-- | components/libc/newlib/syscalls.c | 6 | ||||
| -rw-r--r-- | components/libc/pthreads/clock_time.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/components/libc/newlib/syscalls.c b/components/libc/newlib/syscalls.c index 55c19ccee9..ff09a4fe80 100644 --- a/components/libc/newlib/syscalls.c +++ b/components/libc/newlib/syscalls.c @@ -293,7 +293,7 @@ int libc_get_time(struct timespec *time) tick = rt_tick_get(); time->tv_sec = _timevalue.tv_sec + tick / RT_TICK_PER_SECOND; - time->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * NANOSECOND_PER_TICK) * 1000; + time->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK) * 1000; return 0; } @@ -308,7 +308,7 @@ _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp) if (__tp != RT_NULL) { __tp->tv_sec = tp.tv_sec; - __tp->tv_usec = tp.tv_nsec * 1000UL; + __tp->tv_usec = tp.tv_nsec / 1000UL; } return tp.tv_sec; @@ -331,7 +331,7 @@ _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp) if (__tp != RT_NULL) { __tp->tv_sec = tp.tv_sec; - __tp->tv_usec = tp.tv_nsec * 1000UL; + __tp->tv_usec = tp.tv_nsec / 1000UL; } return tp.tv_sec; diff --git a/components/libc/pthreads/clock_time.c b/components/libc/pthreads/clock_time.c index 06227e17e7..072ab84f10 100644 --- a/components/libc/pthreads/clock_time.c +++ b/components/libc/pthreads/clock_time.c @@ -112,7 +112,7 @@ int clock_gettime(clockid_t clockid, struct timespec *tp) tick = rt_tick_get(); tp->tv_sec = _timevalue.tv_sec + tick / RT_TICK_PER_SECOND; - tp->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * NANOSECOND_PER_TICK) * 1000; + tp->tv_nsec = (_timevalue.tv_usec + (tick % RT_TICK_PER_SECOND) * MICROSECOND_PER_TICK) * 1000; return 0; } |
