RISC-V: Fix timeval conversion in _gettimeofday()

Message ID 20231128223739.463754-1-visitorckw@gmail.com
State New
Headers
Series RISC-V: Fix timeval conversion in _gettimeofday() |

Commit Message

Kuan-Wei Chiu Nov. 28, 2023, 10:37 p.m. UTC
  Replace multiplication with division for microseconds calculation from
nanoseconds in _gettimeofday function.
---
 libgloss/riscv/sys_gettimeofday.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/libgloss/riscv/sys_gettimeofday.c b/libgloss/riscv/sys_gettimeofday.c
index 81bea8e55..5379a8963 100644
--- a/libgloss/riscv/sys_gettimeofday.c
+++ b/libgloss/riscv/sys_gettimeofday.c
@@ -23,7 +23,7 @@  _gettimeofday(struct timeval *tp, void *tzp)
   int rv;
   rv = syscall_errno (SYS_clock_gettime64, 2, 0, (long)&ts64, 0, 0, 0, 0);
   tp->tv_sec = ts64.tv_sec;
-  tp->tv_usec = ts64.tv_nsec * 1000;
+  tp->tv_usec = ts64.tv_nsec / 1000;
   return rv;
 #else
   return syscall_errno (SYS_gettimeofday, 1, tp, 0, 0, 0, 0, 0);