From patchwork Mon Oct 27 07:59:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 3404 Received: (qmail 15528 invoked by alias); 27 Oct 2014 08:00:03 -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 15287 invoked by uid 89); 27 Oct 2014 08:00:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-ig0-f174.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zjInlKuhGoxMajy5U9AqFh53jxt8J3AxNItycmj6O8Q=; b=E2VXhE4coX+n8u5Hz4LRjqfygUVtzNF5USjcHcovVA4x8CcWOmVsM+Nu/r+13bq4RH errqIvBtp6g5uikASw7o5Hr/f/mvk0Yn2ZickF8h9cifvrKNSWyWHswr3t8rbzyUSxmE /yR/0jsmaLKZlUeUT/TYCbHb7AP0Jvw3V6UIkztT5lSAXzdh3DNMmAPvDTvKoSjc/+jM aJRiLbi5Z+aRneW6ssTYDEIOVqStX6JRFWVSdYYysimDNDvR6fkmhtDYHlOmAI+kueMp rR9pCAvREJK4NDcJEsZeW1FvKyWtZgHd0VrFIcRLlsQfKQ/2nVfCLcvDp0zO5U4YLqOe 0KIA== X-Gm-Message-State: ALoCoQle9+FSwFWWQbTexIZYZnthBXTjVBiTMoYfEiznLMYcZxjhq0VD/omb+CE9pFFsI14bR8JI X-Received: by 10.43.66.193 with SMTP id xr1mr1029359icb.59.1414396796907; Mon, 27 Oct 2014 00:59:56 -0700 (PDT) From: Andrew Pinski To: libc-alpha@sourceware.org Cc: Andrew Pinski Subject: [PATCH 04/29] Allow rusage work on a big-endian 32bit-on-64bit target Date: Mon, 27 Oct 2014 00:59:28 -0700 Message-Id: <1414396793-9005-5-git-send-email-apinski@cavium.com> In-Reply-To: <1414396793-9005-1-git-send-email-apinski@cavium.com> References: <1414396793-9005-1-git-send-email-apinski@cavium.com> Right now rusage works for x32 like ABIs but only for little-endian. Since AARCH64:ILP32 is a big-endian ABI also. We need to invent a new way to handle big-endian ABIs also. This adds __RUSAGE_LONG which is used for this purpose. * sysdeps/unix/sysv/linux/bits/resource.h (__RUSAGE_LONG): New define. (struct rusage): Use __RUSAGE_LONG instead of unions. --- sysdeps/unix/sysv/linux/bits/resource.h | 99 ++++++++---------------------- 1 files changed, 27 insertions(+), 72 deletions(-) diff --git a/sysdeps/unix/sysv/linux/bits/resource.h b/sysdeps/unix/sysv/linux/bits/resource.h index 95c1702..698069d 100644 --- a/sysdeps/unix/sysv/linux/bits/resource.h +++ b/sysdeps/unix/sysv/linux/bits/resource.h @@ -182,8 +182,19 @@ enum __rusage_who /* The purpose of all the unions is to have the kernel-compatible layout while keeping the API type as 'long int', and among machines where - __syscall_slong_t is not 'long int', this only does the right thing - for little-endian ones, like x32. */ + __syscall_slong_t is not 'long int'. */ + +#ifndef __RUSAGE_LONG +/* This definition works where __syscall_slong_t is the same as 'long int' + and on little-endian when __syscall_slong_t is not 'long int' like x32. */ +# define __RUSAGE_LONG(__field) \ + __extension__ union \ + { \ + long int __field; \ + __syscall_slong_t __##__field##_word; \ + } +#endif + struct rusage { /* Total amount of user time used. */ @@ -191,96 +202,40 @@ struct rusage /* Total amount of system time used. */ struct timeval ru_stime; /* Maximum resident set size (in kilobytes). */ - __extension__ union - { - long int ru_maxrss; - __syscall_slong_t __ru_maxrss_word; - }; + __RUSAGE_LONG(ru_maxrss); /* Amount of sharing of text segment memory with other processes (kilobyte-seconds). */ /* Maximum resident set size (in kilobytes). */ - __extension__ union - { - long int ru_ixrss; - __syscall_slong_t __ru_ixrss_word; - }; + __RUSAGE_LONG(ru_ixrss); /* Amount of data segment memory used (kilobyte-seconds). */ - __extension__ union - { - long int ru_idrss; - __syscall_slong_t __ru_idrss_word; - }; + __RUSAGE_LONG(ru_idrss); /* Amount of stack memory used (kilobyte-seconds). */ - __extension__ union - { - long int ru_isrss; - __syscall_slong_t __ru_isrss_word; - }; + __RUSAGE_LONG(ru_isrss); /* Number of soft page faults (i.e. those serviced by reclaiming a page from the list of pages awaiting reallocation. */ - __extension__ union - { - long int ru_minflt; - __syscall_slong_t __ru_minflt_word; - }; + __RUSAGE_LONG(ru_minflt); /* Number of hard page faults (i.e. those that required I/O). */ - __extension__ union - { - long int ru_majflt; - __syscall_slong_t __ru_majflt_word; - }; + __RUSAGE_LONG(ru_majflt); /* Number of times a process was swapped out of physical memory. */ - __extension__ union - { - long int ru_nswap; - __syscall_slong_t __ru_nswap_word; - }; + __RUSAGE_LONG(ru_nswap); /* Number of input operations via the file system. Note: This and `ru_oublock' do not include operations with the cache. */ - __extension__ union - { - long int ru_inblock; - __syscall_slong_t __ru_inblock_word; - }; + __RUSAGE_LONG(ru_inblock); /* Number of output operations via the file system. */ - __extension__ union - { - long int ru_oublock; - __syscall_slong_t __ru_oublock_word; - }; + __RUSAGE_LONG(ru_oublock); /* Number of IPC messages sent. */ - __extension__ union - { - long int ru_msgsnd; - __syscall_slong_t __ru_msgsnd_word; - }; + __RUSAGE_LONG(ru_msgsnd); /* Number of IPC messages received. */ - __extension__ union - { - long int ru_msgrcv; - __syscall_slong_t __ru_msgrcv_word; - }; + __RUSAGE_LONG(ru_msgrcv); /* Number of signals delivered. */ - __extension__ union - { - long int ru_nsignals; - __syscall_slong_t __ru_nsignals_word; - }; + __RUSAGE_LONG(ru_nsignals); /* Number of voluntary context switches, i.e. because the process gave up the process before it had to (usually to wait for some resource to be available). */ - __extension__ union - { - long int ru_nvcsw; - __syscall_slong_t __ru_nvcsw_word; - }; + __RUSAGE_LONG(ru_nvcsw); /* Number of involuntary context switches, i.e. a higher priority process became runnable or the current process used up its time slice. */ - __extension__ union - { - long int ru_nivcsw; - __syscall_slong_t __ru_nivcsw_word; - }; + __RUSAGE_LONG(ru_nivcsw); }; /* Priority limits. */