[PATCH v7 02/14] kernel_rusage.h: Add a internal rusage struct

Alistair Francis alistair.francis at wdc.com
Fri Apr 17 16:47:12 UTC 2020


Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
---
 Makefile.am     |  1 +
 kernel_rusage.h | 32 ++++++++++++++++++++++++++++++++
 printrusage.c   | 24 +++---------------------
 3 files changed, 36 insertions(+), 21 deletions(-)
 create mode 100644 kernel_rusage.h

diff --git a/Makefile.am b/Makefile.am
index 6d472569..fa4cfbb9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -158,6 +158,7 @@ libstrace_a_SOURCES =	\
 	kernel_timeval.h \
 	kernel_timex.h	\
 	kernel_types.h	\
+	kernel_rusage.h	\
 	kexec.c		\
 	keyctl.c	\
 	keyctl_kdf_params.h \
diff --git a/kernel_rusage.h b/kernel_rusage.h
new file mode 100644
index 00000000..8c545dfe
--- /dev/null
+++ b/kernel_rusage.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 1999-2020 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef STRACE_KERNEL_RUSAGE_H
+# define STRACE_KERNEL_RUSAGE_H
+
+# include "kernel_timeval.h"
+
+typedef struct {
+       kernel_old_timeval_t ru_utime;
+       kernel_old_timeval_t ru_stime;
+       kernel_long_t   ru_maxrss;
+       kernel_long_t   ru_ixrss;
+       kernel_long_t   ru_idrss;
+       kernel_long_t   ru_isrss;
+       kernel_long_t   ru_minflt;
+       kernel_long_t   ru_majflt;
+       kernel_long_t   ru_nswap;
+       kernel_long_t   ru_inblock;
+       kernel_long_t   ru_oublock;
+       kernel_long_t   ru_msgsnd;
+       kernel_long_t   ru_msgrcv;
+       kernel_long_t   ru_nsignals;
+       kernel_long_t   ru_nvcsw;
+       kernel_long_t   ru_nivcsw;
+} kernel_rusage_t;
+
+#endif /* !STRACE_KERNEL_RUSAGE_H */
diff --git a/printrusage.c b/printrusage.c
index 2d134b9d..f3252875 100644
--- a/printrusage.c
+++ b/printrusage.c
@@ -11,28 +11,10 @@
 
 #include "defs.h"
 
-#include DEF_MPERS_TYPE(rusage_t)
+#include DEF_MPERS_TYPE(kernel_rusage_t)
 
 #include "kernel_timeval.h"
-
-typedef struct {
-	kernel_old_timeval_t ru_utime;
-	kernel_old_timeval_t ru_stime;
-	kernel_long_t	ru_maxrss;
-	kernel_long_t	ru_ixrss;
-	kernel_long_t	ru_idrss;
-	kernel_long_t	ru_isrss;
-	kernel_long_t	ru_minflt;
-	kernel_long_t	ru_majflt;
-	kernel_long_t	ru_nswap;
-	kernel_long_t	ru_inblock;
-	kernel_long_t	ru_oublock;
-	kernel_long_t	ru_msgsnd;
-	kernel_long_t	ru_msgrcv;
-	kernel_long_t	ru_nsignals;
-	kernel_long_t	ru_nvcsw;
-	kernel_long_t	ru_nivcsw;
-} rusage_t;
+#include "kernel_rusage.h"
 
 #include MPERS_DEFS
 
@@ -42,7 +24,7 @@ typedef struct {
 MPERS_PRINTER_DECL(void, printrusage,
 		   struct tcb *const tcp, const kernel_ulong_t addr)
 {
-	rusage_t ru;
+	kernel_rusage_t ru;
 
 	if (umove_or_printaddr(tcp, addr, &ru))
 		return;
-- 
2.26.0



More information about the Strace-devel mailing list