[PATCH v5 02/12] tests/getrusage: Correctly use the long types from the rusage struct

Alistair Francis alistair.francis at wdc.com
Thu Mar 12 17:55:13 UTC 2020


The kernel's rusage struct uses the kernel's __kernel_old_timeval which
means that even for 32-bit archs with 64-bit time_t (like RV32) the time
values are 32-bit.

We can fix this by making sure we don't use libc's rusage struct and
instead use our own with the kernel's old timeval.

Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
---
 tests/getrusage.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/getrusage.c b/tests/getrusage.c
index b046fde2..e8e04275 100644
--- a/tests/getrusage.c
+++ b/tests/getrusage.c
@@ -20,9 +20,10 @@
 
 # include "xlat.h"
 # include "xlat/usagewho.h"
+# include "kernel_rusage.h"
 
 int
-invoke_print(int who, const char *who_str, struct rusage *usage)
+invoke_print(int who, const char *who_str, rusage_t *usage)
 {
 	int rc = syscall(__NR_getrusage, who, usage);
 	int saved_errno = errno;
@@ -49,7 +50,7 @@ invoke_print(int who, const char *who_str, struct rusage *usage)
 int
 main(void)
 {
-	TAIL_ALLOC_OBJECT_CONST_PTR(struct rusage, usage);
+	TAIL_ALLOC_OBJECT_CONST_PTR(rusage_t, usage);
 	if (invoke_print(ARG_STR(RUSAGE_SELF), usage)) {
 		perror_msg_and_fail("RUSAGE_SELF");
 	}
-- 
2.25.1



More information about the Strace-devel mailing list