{"id":811246,"url":"http://patchwork.ozlabs.org/api/patches/811246/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/patch/20170907224219.12483-45-albert.aribaud@3adev.fr/","project":{"id":41,"url":"http://patchwork.ozlabs.org/api/projects/41/?format=json","name":"GNU C Library","link_name":"glibc","list_id":"libc-alpha.sourceware.org","list_email":"libc-alpha@sourceware.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170907224219.12483-45-albert.aribaud@3adev.fr>","list_archive_url":null,"date":"2017-09-07T22:42:11","name":"[RFC,44/52] Y2038: add function __getrusage_t64","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ed823ceeced47a42adbda3382fe9602def1cfc09","submitter":{"id":65557,"url":"http://patchwork.ozlabs.org/api/people/65557/?format=json","name":"Albert ARIBAUD (3ADEV)","email":"albert.aribaud@3adev.fr"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/glibc/patch/20170907224219.12483-45-albert.aribaud@3adev.fr/mbox/","series":[{"id":2074,"url":"http://patchwork.ozlabs.org/api/series/2074/?format=json","web_url":"http://patchwork.ozlabs.org/project/glibc/list/?series=2074","date":"2017-09-07T22:41:27","name":"Make GLIBC Y2038-proof","version":1,"mbox":"http://patchwork.ozlabs.org/series/2074/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811246/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811246/checks/","tags":{},"related":[],"headers":{"Return-Path":"<libc-alpha-return-84361-incoming=patchwork.ozlabs.org@sourceware.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list libc-alpha@sourceware.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-84361-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"TPEau738\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xpFzT13dgz9rxl\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  8 Sep 2017 08:50:44 +1000 (AEST)","(qmail 121395 invoked by alias); 7 Sep 2017 22:45:35 -0000","(qmail 121239 invoked by uid 89); 7 Sep 2017 22:45:35 -0000"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=dlKj2l6sHfptS5nPxtxGhMdn2K3kpp5\n\t+sh1Yxppp1PRPuHQXkSXZULGverFcJm8shUv266pKFrHLhcW+t+nKOf+vRAFQ+p0\n\trzH+rg8N4Tl1wkpp0sN+ygX9HMaxB6QR1FWG0h6QPKEheZaqrPAhF0uXpraPfggi\n\t70QmdRkUHN4U=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=iJHyNQNorUDZxKmNg3AIuaYch70=; b=TPEau\n\t7381/IgJG6NF/ELR6kyYrwR4FnSyzOkPr7VXYlnikSLCy/A/ePqxsiKQg4Gu9ULS\n\tQg/0Ah5coXJ4kym1tFTc6toNwT1m0k3zrFVNIZWNb5UmWlrlG1C6lgsYa/8WcwjQ\n\tnqViWH6clXg2U/7uYH5+EytRNW6eGVTu9DIIU4=","Mailing-List":"contact libc-alpha-help@sourceware.org; run by ezmlm","Precedence":"bulk","List-Id":"<libc-alpha.sourceware.org>","List-Unsubscribe":"<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>","List-Subscribe":"<mailto:libc-alpha-subscribe@sourceware.org>","List-Archive":"<http://sourceware.org/ml/libc-alpha/>","List-Post":"<mailto:libc-alpha@sourceware.org>","List-Help":"<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>","Sender":"libc-alpha-owner@sourceware.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY,\n\tRCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=","X-HELO":"smtp6-g21.free.fr","From":"\"Albert ARIBAUD (3ADEV)\" <albert.aribaud@3adev.fr>","To":"libc-alpha@sourceware.org","Cc":"\"Albert ARIBAUD (3ADEV)\" <albert.aribaud@3adev.fr>","Subject":"[RFC PATCH 44/52] Y2038: add function __getrusage_t64","Date":"Fri,  8 Sep 2017 00:42:11 +0200","Message-Id":"<20170907224219.12483-45-albert.aribaud@3adev.fr>","In-Reply-To":"<20170907224219.12483-44-albert.aribaud@3adev.fr>","References":"<20170907224219.12483-1-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-2-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-3-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-4-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-5-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-6-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-7-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-8-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-9-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-10-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-11-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-12-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-13-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-14-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-15-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-16-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-17-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-18-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-19-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-20-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-21-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-22-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-23-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-24-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-25-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-26-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-27-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-28-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-29-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-30-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-31-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-32-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-33-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-34-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-35-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-36-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-37-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-38-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-39-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-40-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-41-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-42-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-43-albert.aribaud@3adev.fr>\n\t<20170907224219.12483-44-albert.aribaud@3adev.fr>"},"content":"Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>\n---\n resource/Makefile      |   2 +-\n resource/Versions      |   7 ++\n resource/getrusage64.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 193 insertions(+), 1 deletion(-)\n create mode 100644 resource/getrusage64.c","diff":"diff --git a/resource/Makefile b/resource/Makefile\nindex 06bc7a2fb2..81a865105b 100644\n--- a/resource/Makefile\n+++ b/resource/Makefile\n@@ -23,7 +23,7 @@ headers\t  := sys/resource.h bits/resource.h sys/vlimit.h sys/vtimes.h\t\\\n \t     ulimit.h bits/types/struct_rusage.h\n \n routines := getrlimit setrlimit getrlimit64 setrlimit64 getrusage ulimit      \\\n-\t    vlimit vtimes getpriority setpriority nice\n+\t    vlimit vtimes getpriority setpriority nice getrusage64\n \n tests = tst-getrlimit bug-ulimit1\n \ndiff --git a/resource/Versions b/resource/Versions\nindex d6c2ccee1b..84f3a79769 100644\n--- a/resource/Versions\n+++ b/resource/Versions\n@@ -25,4 +25,11 @@ libc {\n   GLIBC_PRIVATE {\n     __getrlimit;\n   }\n+\n+  # Y2038 symbols are given their own version until they can be put in\n+  # the right place\n+\n+  GLIBC_Y2038 {\n+    __getrusage_t64;\n+  }\n }\ndiff --git a/resource/getrusage64.c b/resource/getrusage64.c\nnew file mode 100644\nindex 0000000000..6c81137a8b\n--- /dev/null\n+++ b/resource/getrusage64.c\n@@ -0,0 +1,185 @@\n+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.\n+   This file is part of the GNU C Library.\n+\n+   The GNU C Library is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU Lesser General Public\n+   License as published by the Free Software Foundation; either\n+   version 2.1 of the License, or (at your option) any later version.\n+\n+   The GNU C Library is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+   Lesser General Public License for more details.\n+\n+   You should have received a copy of the GNU Lesser General Public\n+   License along with the GNU C Library; if not, see\n+   <http://www.gnu.org/licenses/>.  */\n+\n+#include <sys/resource.h>\n+#include <include/time.h>\n+#include <sysdep.h>\n+#include <sys/syscall.h>\n+\n+/* Structure which says how much of each resource has been used.  */\n+/* 64-bit time version */\n+/* The purpose of all the unions is to have the kernel-compatible layout\n+   while keeping the API type as 'long int', and among machines where\n+   __syscall_slong_t is not 'long int', this only does the right thing\n+   for little-endian ones, like x32.  */\n+struct __rusage_t64\n+  {\n+    /* Total amount of user time used.  */\n+    struct __timeval64 ru_utime;\n+    /* Total amount of system time used.  */\n+    struct __timeval64 ru_stime;\n+    /* Maximum resident set size (in kilobytes).  */\n+    __extension__ union\n+      {\n+\tlong int ru_maxrss;\n+\t__syscall_slong_t __ru_maxrss_word;\n+      };\n+    /* Amount of sharing of text segment memory\n+       with other processes (kilobyte-seconds).  */\n+    /* Maximum resident set size (in kilobytes).  */\n+    __extension__ union\n+      {\n+\tlong int ru_ixrss;\n+\t__syscall_slong_t __ru_ixrss_word;\n+      };\n+    /* Amount of data segment memory used (kilobyte-seconds).  */\n+    __extension__ union\n+      {\n+\tlong int ru_idrss;\n+\t__syscall_slong_t __ru_idrss_word;\n+      };\n+    /* Amount of stack memory used (kilobyte-seconds).  */\n+    __extension__ union\n+      {\n+\tlong int ru_isrss;\n+\t __syscall_slong_t __ru_isrss_word;\n+      };\n+    /* Number of soft page faults (i.e. those serviced by reclaiming\n+       a page from the list of pages awaiting reallocation.  */\n+    __extension__ union\n+      {\n+\tlong int ru_minflt;\n+\t__syscall_slong_t __ru_minflt_word;\n+      };\n+    /* Number of hard page faults (i.e. those that required I/O).  */\n+    __extension__ union\n+      {\n+\tlong int ru_majflt;\n+\t__syscall_slong_t __ru_majflt_word;\n+      };\n+    /* Number of times a process was swapped out of physical memory.  */\n+    __extension__ union\n+      {\n+\tlong int ru_nswap;\n+\t__syscall_slong_t __ru_nswap_word;\n+      };\n+    /* Number of input operations via the file system.  Note: This\n+       and `ru_oublock' do not include operations with the cache.  */\n+    __extension__ union\n+      {\n+\tlong int ru_inblock;\n+\t__syscall_slong_t __ru_inblock_word;\n+      };\n+    /* Number of output operations via the file system.  */\n+    __extension__ union\n+      {\n+\tlong int ru_oublock;\n+\t__syscall_slong_t __ru_oublock_word;\n+      };\n+    /* Number of IPC messages sent.  */\n+    __extension__ union\n+      {\n+\tlong int ru_msgsnd;\n+\t__syscall_slong_t __ru_msgsnd_word;\n+      };\n+    /* Number of IPC messages received.  */\n+    __extension__ union\n+      {\n+\tlong int ru_msgrcv;\n+\t__syscall_slong_t __ru_msgrcv_word;\n+      };\n+    /* Number of signals delivered.  */\n+    __extension__ union\n+      {\n+\tlong int ru_nsignals;\n+\t__syscall_slong_t __ru_nsignals_word;\n+      };\n+    /* Number of voluntary context switches, i.e. because the process\n+       gave up the process before it had to (usually to wait for some\n+       resource to be available).  */\n+    __extension__ union\n+      {\n+\tlong int ru_nvcsw;\n+\t__syscall_slong_t __ru_nvcsw_word;\n+      };\n+    /* Number of involuntary context switches, i.e. a higher priority process\n+       became runnable or the current process used up its time slice.  */\n+    __extension__ union\n+      {\n+\tlong int ru_nivcsw;\n+\t__syscall_slong_t __ru_nivcsw_word;\n+      };\n+  };\n+\n+extern int __y2038_linux_support;\n+\n+int __getrusage_t64 (__rusage_who_t __who, struct __rusage_t64 *__usage)\n+{\n+  int result;\n+  struct rusage usage32;\n+\n+  if (__y2038_linux_support)\n+    {\n+      // TODO: use 64-bit-time syscall if available\n+    }\n+\n+  result = INLINE_SYSCALL(getrusage, 2, __who, &usage32);\n+  /* Copy fields from 32-bit into 64-bit rusage structure */\n+  /* Total amount of user time used.  */\n+  __usage->ru_utime.tv_sec = usage32.ru_utime.tv_sec;\n+  __usage->ru_utime.tv_usec = usage32.ru_utime.tv_usec;\n+  /* Total amount of system time used.  */\n+  __usage->ru_stime.tv_sec = usage32.ru_stime.tv_sec;\n+  __usage->ru_stime.tv_usec = usage32.ru_stime.tv_usec;\n+  /* Maximum resident set size (in kilobytes).  */\n+  __usage->ru_maxrss = usage32.ru_maxrss;\n+  /* Amount of sharing of text segment memory\n+     with other processes (kilobyte-seconds).  */\n+  /* Maximum resident set size (in kilobytes).  */\n+  __usage->ru_ixrss = usage32.ru_ixrss;\n+  /* Amount of data segment memory used (kilobyte-seconds).  */\n+  __usage->ru_idrss = usage32.ru_idrss;\n+  /* Amount of stack memory used (kilobyte-seconds).  */\n+  __usage->ru_isrss = usage32.ru_isrss;\n+  /* Number of soft page faults (i.e. those serviced by reclaiming\n+     a page from the list of pages awaiting reallocation.  */\n+  __usage->ru_minflt = usage32.ru_minflt;\n+  /* Number of hard page faults (i.e. those that required I/O).  */\n+  __usage->ru_majflt = usage32.ru_majflt;\n+  /* Number of times a process was swapped out of physical memory.  */\n+  __usage->ru_nswap = usage32.ru_nswap;\n+  /* Number of input operations via the file system.  Note: This\n+     and `ru_oublock' do not include operations with the cache.  */\n+  __usage->ru_inblock = usage32.ru_inblock;\n+  /* Number of output operations via the file system.  */\n+  __usage->ru_oublock = usage32.ru_oublock;\n+  /* Number of IPC messages sent.  */\n+  __usage->ru_msgsnd = usage32.ru_msgsnd;\n+  /* Number of IPC messages received.  */\n+  __usage->ru_msgrcv = usage32.ru_msgrcv;\n+  /* Number of signals delivered.  */\n+  __usage->ru_nsignals = usage32.ru_nsignals;\n+  /* Number of voluntary context switches, i.e. because the process\n+     gave up the process before it had to (usually to wait for some\n+     resource to be available).  */\n+  __usage->ru_nvcsw = usage32.ru_nvcsw;\n+  /* Number of involuntary context switches, i.e. a higher priority process\n+     became runnable or the current process used up its time slice.  */\n+  __usage->ru_nivcsw = usage32.ru_nivcsw;\n+\n+  return result;\n+}\n","prefixes":["RFC","44/52"]}