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: 39569 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 687872118A for ; Mon, 27 Oct 2014 08:01:09 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf2584245wid.4 for ; Mon, 27 Oct 2014 01:01:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:cc:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results; bh=zjInlKuhGoxMajy5U9AqFh53jxt8J3AxNItycmj6O8Q=; b=Qbbgi/FBopn4te4YlkP7GtjTHXl8Y8XbNvaqAvfURGCFzCjIfaLQSrOHwXDyz3TA4L 3tmjhOmAqbd1i6B+p6bD928Z7AYQI48N0QSzdTAFYwV98Eqz4IlKQgdlDT5DjhbsRUtb OIVwlkXtWeGs0zaPT560ZVWlqbwVXdMqd00ZsMCYu8RxmUdMeaBqd0G3+cJnBlb2z8A0 MMuOZcz83u5dvps2Xhui1q7MJW6Gs8DumcpvW/PnUx3oxeRDGFjrRPsYRbkTJAhjjFtr xVISQn3ETe/809R6uNEJ5j63l8F4s4CWUVEsfG+oPE4JrSDzF/9zZV9ySyV6QdMKybp4 +FYw== X-Gm-Message-State: ALoCoQnqEPoJ34sywI9xwFOsrnNeRCujM1uI+4WuIQnwUWPBcWbJSXXBdWqtVDfcF7XT00FhZy/P X-Received: by 10.112.142.36 with SMTP id rt4mr1657767lbb.3.1414396868300; Mon, 27 Oct 2014 01:01:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.66 with SMTP id h2ls533155laa.58.gmail; Mon, 27 Oct 2014 01:01:07 -0700 (PDT) X-Received: by 10.112.156.168 with SMTP id wf8mr21755669lbb.28.1414396867545; Mon, 27 Oct 2014 01:01:07 -0700 (PDT) Received: from mail-la0-x235.google.com (mail-la0-x235.google.com. [2a00:1450:4010:c03::235]) by mx.google.com with ESMTPS id 8si18643991las.83.2014.10.27.01.01.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Oct 2014 01:01:07 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::235 as permitted sender) client-ip=2a00:1450:4010:c03::235; Received: by mail-la0-f53.google.com with SMTP id mc6so977365lab.26 for ; Mon, 27 Oct 2014 01:01:07 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr21844806lbb.46.1414396867282; Mon, 27 Oct 2014 01:01:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp247286lbz; Mon, 27 Oct 2014 01:01:06 -0700 (PDT) X-Received: by 10.68.237.161 with SMTP id vd1mr22999757pbc.26.1414396865210; Mon, 27 Oct 2014 01:01:05 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id an5si9882825pbc.99.2014.10.27.01.01.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Oct 2014 01:01:05 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-53801-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 15528 invoked by alias); 27 Oct 2014 08:00:03 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 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-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> X-Original-Sender: apinski@cavium.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c03::235 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 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. */