public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fix timeval conversion in _gettimeofday()
@ 2023-11-28 22:37 Kuan-Wei Chiu
  2023-11-29  3:57 ` [PATCH v2] " Kuan-Wei Chiu
  0 siblings, 1 reply; 4+ messages in thread
From: Kuan-Wei Chiu @ 2023-11-28 22:37 UTC (permalink / raw)
  To: newlib; +Cc: kito.cheng, Kuan-Wei Chiu

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(-)

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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] RISC-V: Fix timeval conversion in _gettimeofday()
  2023-11-28 22:37 [PATCH] RISC-V: Fix timeval conversion in _gettimeofday() Kuan-Wei Chiu
@ 2023-11-29  3:57 ` Kuan-Wei Chiu
  2023-11-29  6:41   ` Kito Cheng
  2023-11-29  9:15   ` Corinna Vinschen
  0 siblings, 2 replies; 4+ messages in thread
From: Kuan-Wei Chiu @ 2023-11-29  3:57 UTC (permalink / raw)
  To: newlib; +Cc: kito.cheng, Kuan-Wei Chiu

Replace multiplication with division for microseconds calculation from
nanoseconds in _gettimeofday function.

Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
---
v1 -> v2:
   - Add missing Signed-off-by tag.

 libgloss/riscv/sys_gettimeofday.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] RISC-V: Fix timeval conversion in _gettimeofday()
  2023-11-29  3:57 ` [PATCH v2] " Kuan-Wei Chiu
@ 2023-11-29  6:41   ` Kito Cheng
  2023-11-29  9:15   ` Corinna Vinschen
  1 sibling, 0 replies; 4+ messages in thread
From: Kito Cheng @ 2023-11-29  6:41 UTC (permalink / raw)
  To: Kuan-Wei Chiu; +Cc: newlib

LGTM, thanks for the fix, I am suppressing that we mis-scale that for
such a long time!

On Wed, Nov 29, 2023 at 11:57 AM Kuan-Wei Chiu <visitorckw@gmail.com> wrote:
>
> Replace multiplication with division for microseconds calculation from
> nanoseconds in _gettimeofday function.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> ---
> v1 -> v2:
>    - Add missing Signed-off-by tag.
>
>  libgloss/riscv/sys_gettimeofday.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> 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);
> --
> 2.25.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] RISC-V: Fix timeval conversion in _gettimeofday()
  2023-11-29  3:57 ` [PATCH v2] " Kuan-Wei Chiu
  2023-11-29  6:41   ` Kito Cheng
@ 2023-11-29  9:15   ` Corinna Vinschen
  1 sibling, 0 replies; 4+ messages in thread
From: Corinna Vinschen @ 2023-11-29  9:15 UTC (permalink / raw)
  To: Kuan-Wei Chiu; +Cc: newlib, kito.cheng

On Nov 29 11:57, Kuan-Wei Chiu wrote:
> Replace multiplication with division for microseconds calculation from
> nanoseconds in _gettimeofday function.
> 
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> ---
> v1 -> v2:
>    - Add missing Signed-off-by tag.
> 
>  libgloss/riscv/sys_gettimeofday.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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);
> -- 
> 2.25.1

Pushed.


Thanks,
Corinna


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-29  9:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-28 22:37 [PATCH] RISC-V: Fix timeval conversion in _gettimeofday() Kuan-Wei Chiu
2023-11-29  3:57 ` [PATCH v2] " Kuan-Wei Chiu
2023-11-29  6:41   ` Kito Cheng
2023-11-29  9:15   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).