This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v2 5/6] resource: Add a __rusage64 struct
- From: Alistair Francis <alistair dot francis at wdc dot com>
- To: libc-alpha at sourceware dot org
- Cc: alistair23 at gmail dot com, Alistair Francis <alistair dot francis at wdc dot com>, Lukasz Majewski <lukma at denx dot de>
- Date: Mon, 10 Feb 2020 09:43:24 -0800
- Subject: [PATCH v2 5/6] resource: Add a __rusage64 struct
- Ironport-sdr: pkLh0aV9ilgLBkPCy10LbyXjHhOqAtmD1RZPm/4aPiB68ZLHp0wSw1F5RfV3bmoZcAZjfmYr/w NIU3hHzyXE2nSDIEDC7qn4ch4Nr+n9a5mGnaDFrLKYwxELOYiqCiI46bQVb/Qm9yQ4+hfCNeir WSjZ7y/5D3h5wWgjvkg2OsrkGKuNPAbom2y5/bv8wj20fB4Yc6NaQ/m2AZ5ybJ8wGx2O821da9 hB7hAysruD6eXH7qVSjvPtARaQHLMLt0N96Mq4ktB4Z76ROJ3p6hP4DRYY90h1EuRZ0a/HJLsO oZk=
- Ironport-sdr: 0BP+jCaqWEKJrEdoh2myefK5HQ5b9nrTHOZb+h1bVGYZIitCU90SKg2VPJSU1u95zogDSAurFb oEa5r6YTwVTNQP1mduUylVbnzSF1TOYgXLniemD4PiksVv5mqgswIiCnWUwTKYXrefYTWdPZNC 6DqmlL56ZaF8r4OlDavupfCz1Y1FEBsmVl/yjV/O/W1GnPD+cdO/6XwODyvNjGwu8uqS1bnid1 POS4kjSwMSNRsj2oZRJwzsb24Ima7JE3baG8yGKS1VEqtGJq6VWjFACYxL/NF5jQ0lKhNUHZbv k1u2BKQ05l71HCm/yKCDTGD+
- Ironport-sdr: Z2WYOAnenwU4aRvu/WWwWquumNOV+NgPpV4Mi+eCmrFL9sR9f/MURw+DKEywGauXAzVzx3C7PQ 6npmMjsDvzstWDDkRYYL24oF3kCUe4Tu1jm1Sr5E3HL6Db37gBlgguwJhNs34zLcn5tjUc4AUA SCCcHOAARo/sHngU4hOrfMjlTYymYOaCxWAYxRMvMOuCkFdfpcw0P9cQ0hRzgPxcSLwUgesqrm WP/kaC434xgYwcR6yqtJx0whub2TrGlyi8szn9StGkPZ4/KEB6gVQd3vGXEAsKDOybe2oTg7zR y8U=
- References: <20200210174325.6566-1-alistair.francis@wdc.com>
- Wdcironportexception: Internal
Add a __rusage64 struct which always uses a 64-bit time_t.
Reviewed-by: Lukasz Majewski <lukma@denx.de>
---
include/sys/resource.h | 110 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/include/sys/resource.h b/include/sys/resource.h
index c55d4e63bd..9d604dfe3e 100644
--- a/include/sys/resource.h
+++ b/include/sys/resource.h
@@ -2,6 +2,116 @@
#include <resource/sys/resource.h>
#ifndef _ISOMAC
+# include <time.h>
+# include <string.h>
+
+/* Internal version of rusage with a 64-bit time_t. */
+#if __TIMESIZE == 64
+# define __rusage64 rusage
+#else
+struct __rusage64
+ {
+ struct __timeval64 ru_utime;
+ struct __timeval64 ru_stime;
+ __extension__ union
+ {
+ long int ru_maxrss;
+ __syscall_slong_t __ru_maxrss_word;
+ };
+ __extension__ union
+ {
+ long int ru_ixrss;
+ __syscall_slong_t __ru_ixrss_word;
+ };
+ __extension__ union
+ {
+ long int ru_idrss;
+ __syscall_slong_t __ru_idrss_word;
+ };
+ __extension__ union
+ {
+ long int ru_isrss;
+ __syscall_slong_t __ru_isrss_word;
+ };
+ __extension__ union
+ {
+ long int ru_minflt;
+ __syscall_slong_t __ru_minflt_word;
+ };
+ __extension__ union
+ {
+ long int ru_majflt;
+ __syscall_slong_t __ru_majflt_word;
+ };
+ __extension__ union
+ {
+ long int ru_nswap;
+ __syscall_slong_t __ru_nswap_word;
+ };
+ __extension__ union
+ {
+ long int ru_inblock;
+ __syscall_slong_t __ru_inblock_word;
+ };
+ __extension__ union
+ {
+ long int ru_oublock;
+ __syscall_slong_t __ru_oublock_word;
+ };
+ __extension__ union
+ {
+ long int ru_msgsnd;
+ __syscall_slong_t __ru_msgsnd_word;
+ };
+ __extension__ union
+ {
+ long int ru_msgrcv;
+ __syscall_slong_t __ru_msgrcv_word;
+ };
+ __extension__ union
+ {
+ long int ru_nsignals;
+ __syscall_slong_t __ru_nsignals_word;
+ };
+ __extension__ union
+ {
+ long int ru_nvcsw;
+ __syscall_slong_t __ru_nvcsw_word;
+ };
+ __extension__ union
+ {
+ long int ru_nivcsw;
+ __syscall_slong_t __ru_nivcsw_word;
+ };
+ };
+#endif
+
+static inline void
+rusage64_to_rusage (const struct __rusage64 *restrict r64,
+ struct rusage *restrict r)
+{
+ /* Make sure the entire output structure is cleared, including
+ padding and reserved fields. */
+ memset (r, 0, sizeof *r);
+
+ r->ru_utime = valid_timeval64_to_timeval (r64->ru_utime);
+ r->ru_stime = valid_timeval64_to_timeval (r64->ru_stime);
+ r->ru_maxrss = r64->ru_maxrss;
+ r->ru_ixrss = r64->ru_ixrss;
+ r->ru_idrss = r64->ru_idrss;
+ r->ru_isrss = r64->ru_isrss;
+ r->ru_minflt = r64->ru_minflt;
+ r->ru_majflt = r64->ru_majflt;
+ r->ru_nswap = r64->ru_nswap;
+ r->ru_inblock = r64->ru_inblock;
+ r->ru_oublock = r64->ru_oublock;
+ r->ru_msgsnd = r64->ru_msgsnd;
+ r->ru_msgrcv = r64->ru_msgrcv;
+ r->ru_nsignals = r64->ru_nsignals;
+ r->ru_nvcsw = r64->ru_nvcsw;
+ r->ru_nivcsw = r64->ru_nivcsw;
+}
+
/* Prototypes repeated instead of using __typeof because
sys/resource.h is included in C++ tests, and declaring functions
with __typeof and __THROW doesn't work for C++. */
--
2.25.0