From patchwork Mon Feb 3 18:31:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 37658 Received: (qmail 25107 invoked by alias); 3 Feb 2020 18:38:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 24925 invoked by uid 89); 3 Feb 2020 18:38:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=2116, prototypes, HContent-Transfer-Encoding:8bit X-HELO: esa3.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1580755125; x=1612291125; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c/KSDG/e5Kjt+osp3ohFRwp9wvIXWn0NGSrEPS/vNdE=; b=GKfpvzcnPNcBK1OB0g9aafGDLerCNIf8Vrd/vkXjNzer9tlF0emcZPCQ FrzzoPIeM0mioFMl6httBxO21ZkLT9/GTdMnE+MN7oEsyXYG+K8PFYtDR MgXcqx8SqvqncwqdSSfBhdHl/EluC+phjkRebxIaitibup/viWYCXOiph Pc5qQL+PJbix/vsv9Yfo8SQQbn83ofHDa4CktOF8Q1Bt5FvQF61H37M6W pYM4cAJRZ/E2l4t4mg/2qR2gEMlnUK2EnK9KOo5HaVe/u6XoSPYBjkTUa 8i5wolcwMAjoDP6ypgZX65euQan68fZR9cr7x6HuUhIg/ohP96hU5wOFm A==; IronPort-SDR: ovss5pJTTzpTE0ejnI3w0LUlakcfK1+0OqMudw8gmxZungdIaApeOxg4cAVci3Skmv/pOgBaXk 1g7IpBJJThQM1EgGgKwzUDxAUBtM0Nx+EDR+pCU7IEZmKLozzFeOV1zSL5nzix1WqiqAJ/qmQa QRd6qBp4GpNZ8LC9NvGAJnkpWdkWAm+GTypdTWx0hozQumhtboxIeQDqEk173cXraRWvp8glir jeJ9/ElUw/mht4OdkPZeDsDOVqDzB91cdAuDkOl+B0N4MJUI8tfhitFEmPs7ppodtF9/TWG91D dkU= IronPort-SDR: L+GxvhE/w1C7kw8w/GAPTMTpvkuJi/9db2r2ydEWFgXCXJv61V0K91BQfzY8xzAYUIJsgaErYg 6hq3Eegvp4YU4GwfK1Gs/m8nNiY4OWCoaCmfGTSO4T25/F2ijQLLGYPJUxrKBDWQs6iHRS4M4p VGDvu7kOXtkyBcSPyTIdxw5hzDORTWnFJuBkY3Sywbp/AOrLH5UTzUfzlcmlbZkghK0J51vuzk /rKpnjhoXsLnXmmn6ke1R8xTkFq5vYLJ8esNNDtssZ5kCzzP8cPhVhrTc8yhHQ2CvzfEnUB6GP GmsaPnTaPY3tAPiYl4VOZAGK IronPort-SDR: UYydQ0yYsXkhNBBOGXCV4gXw4xfd846/U08+RYZt9IgKXqYRiIsajJC4zTTByTpA4KwSoeMeMt DZBYm2MQEa/dXIcT899ivtQW6UcqkmAnu1aeVwCMadB5maeznYCTWMIE3wVlgkaUPcZT9RNMmh 2uc3Dox/wQvFkCnvOW+JlOj76PDy/cVUwefQhrXoKEsHYreYuOSnw/t9xCLLmwFliTiPEfQ69R Y3B+9X6iHh4h1Sf/lS7Nzzz2jjqwK2n1df+kO3WAjhrJ1qdf/iGd5bzh6tUmfBUcG+6RWUP31f Ylw= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, lukma@denx.de, Alistair Francis Subject: [PATCH 5/6] resource: Add a __rusage64 struct Date: Mon, 3 Feb 2020 10:31:52 -0800 Message-Id: <20200203183153.11635-6-alistair.francis@wdc.com> In-Reply-To: <20200203183153.11635-1-alistair.francis@wdc.com> References: <20200203183153.11635-1-alistair.francis@wdc.com> MIME-Version: 1.0 Add a __rusage64 struct which always uses a 64-bit time_t. Reviewed-by: Lukasz Majewski --- 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 #ifndef _ISOMAC +# include +# include + +/* 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++. */