[PATCH 1/2] RISC-V: Fixed return code in _times syscall.

Kito Cheng <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CA+yXCZDwAcDDh_5_SvJHAW+xhR68vqjxbE+L8nw27PW2Ff9YTw@mail.gmail.com>
This patch fixed wrong return code for _times in RISC-V libgloss
0001-RISC-V-Fixed-return-code-in-_times-syscall.patch (text/x-patch, 1.1 KB)
From 307f84513342d87e0dba268e4040a85b31e6227f Mon Sep 17 00:00:00 2001
From: Denis Ivanov <[email protected]>
Date: Fri, 6 Jul 2018 12:03:15 +0300
Subject: [PATCH 1/2] RISC-V: Fixed return code in _times syscall.

Upon successful completion, times() shall return the elapsed real time,
in clock ticks, since an arbitrary point in the past (for example,
system start-up time).

Signed-off-by: Kito Cheng <[email protected]>
---
 libgloss/riscv/sys_times.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgloss/riscv/sys_times.c b/libgloss/riscv/sys_times.c
index eb0ef9d1f..fc8133ade 100644
--- a/libgloss/riscv/sys_times.c
+++ b/libgloss/riscv/sys_times.c
@@ -23,7 +23,7 @@ _times(struct tms *buf)
 {
   // when called for the first time, initialize t0
   static struct timeval t0;
-  if (t0.tv_sec == 0)
+  if (t0.tv_sec == 0 && t0.tv_usec == 0)
     _gettimeofday (&t0, 0);
 
   struct timeval t;
@@ -33,5 +33,5 @@ _times(struct tms *buf)
   buf->tms_utime = utime * CLOCKS_PER_SEC / 1000000;
   buf->tms_stime = buf->tms_cstime = buf->tms_cutime = 0;
 
-  return -1;
+  return buf->tms_utime;
 }
-- 
2.17.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.