summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-08-02 12:56:01 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-08-02 12:56:01 +0200
commit1830c222ea62a5344ffa1740050b597e530c654a (patch)
treeb54b186b3dfd4004c1d9089a37bbf349d0d21db3
parente2a6c2109e8aeeae596735c9e52a2edb225cf2da (diff)
downloadglibc-aaribaud/y2038-2.25.tar.gz
Y2038: add Y2038-ready getrusageaaribaud/y2038-2.25
-rw-r--r--resource/Makefile2
-rw-r--r--resource/Versions7
-rw-r--r--resource/getrusage64.c179
-rw-r--r--resource/sys/resource.h9
4 files changed, 196 insertions, 1 deletions
diff --git a/resource/Makefile b/resource/Makefile
index 8235770737..9606ccbf44 100644
--- a/resource/Makefile
+++ b/resource/Makefile
@@ -23,7 +23,7 @@ headers := sys/resource.h bits/resource.h sys/vlimit.h sys/vtimes.h \
ulimit.h
routines := getrlimit setrlimit getrlimit64 setrlimit64 getrusage ulimit \
- vlimit vtimes getpriority setpriority nice
+ vlimit vtimes getpriority setpriority nice getrusage64
tests = tst-getrlimit bug-ulimit1
diff --git a/resource/Versions b/resource/Versions
index d6c2ccee1b..84f3a79769 100644
--- a/resource/Versions
+++ b/resource/Versions
@@ -25,4 +25,11 @@ libc {
GLIBC_PRIVATE {
__getrlimit;
}
+
+ # Y2038 symbols are given their own version until they can be put in
+ # the right place
+
+ GLIBC_Y2038 {
+ __getrusage_t64;
+ }
}
diff --git a/resource/getrusage64.c b/resource/getrusage64.c
new file mode 100644
index 0000000000..0e76f150cf
--- /dev/null
+++ b/resource/getrusage64.c
@@ -0,0 +1,179 @@
+/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sys/resource.h>
+#include <include/time.h>
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+/* Structure which says how much of each resource has been used. */
+/* 64-bit time version */
+/* 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. */
+struct __rusage_t64
+ {
+ /* Total amount of user time used. */
+ struct __timeval64 ru_utime;
+ /* Total amount of system time used. */
+ struct __timeval64 ru_stime;
+ /* Maximum resident set size (in kilobytes). */
+ __extension__ union
+ {
+ long int ru_maxrss;
+ __syscall_slong_t __ru_maxrss_word;
+ };
+ /* 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;
+ };
+ /* Amount of data segment memory used (kilobyte-seconds). */
+ __extension__ union
+ {
+ long int ru_idrss;
+ __syscall_slong_t __ru_idrss_word;
+ };
+ /* Amount of stack memory used (kilobyte-seconds). */
+ __extension__ union
+ {
+ long int ru_isrss;
+ __syscall_slong_t __ru_isrss_word;
+ };
+ /* 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;
+ };
+ /* Number of hard page faults (i.e. those that required I/O). */
+ __extension__ union
+ {
+ long int ru_majflt;
+ __syscall_slong_t __ru_majflt_word;
+ };
+ /* Number of times a process was swapped out of physical memory. */
+ __extension__ union
+ {
+ long int ru_nswap;
+ __syscall_slong_t __ru_nswap_word;
+ };
+ /* 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;
+ };
+ /* Number of output operations via the file system. */
+ __extension__ union
+ {
+ long int ru_oublock;
+ __syscall_slong_t __ru_oublock_word;
+ };
+ /* Number of IPC messages sent. */
+ __extension__ union
+ {
+ long int ru_msgsnd;
+ __syscall_slong_t __ru_msgsnd_word;
+ };
+ /* Number of IPC messages received. */
+ __extension__ union
+ {
+ long int ru_msgrcv;
+ __syscall_slong_t __ru_msgrcv_word;
+ };
+ /* Number of signals delivered. */
+ __extension__ union
+ {
+ long int ru_nsignals;
+ __syscall_slong_t __ru_nsignals_word;
+ };
+ /* 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;
+ };
+ /* 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;
+ };
+ };
+
+
+int __getrusage64 (__rusage_who_t __who, struct __rusage_t64 *__usage)
+{
+ int result;
+ struct rusage usage32;
+
+ result = INLINE_SYSCALL(getrusage, 2, __who, &usage32);
+ /* Copy fields from 32-bit into 64-bit rusage structure */
+ /* Total amount of user time used. */
+ __usage->ru_utime.tv_sec = usage32.ru_utime.tv_sec;
+ __usage->ru_utime.tv_usec = usage32.ru_utime.tv_usec;
+ /* Total amount of system time used. */
+ __usage->ru_stime.tv_sec = usage32.ru_stime.tv_sec;
+ __usage->ru_stime.tv_usec = usage32.ru_stime.tv_usec;
+ /* Maximum resident set size (in kilobytes). */
+ __usage->ru_maxrss = usage32.ru_maxrss;
+ /* Amount of sharing of text segment memory
+ with other processes (kilobyte-seconds). */
+ /* Maximum resident set size (in kilobytes). */
+ __usage->ru_ixrss = usage32.ru_ixrss;
+ /* Amount of data segment memory used (kilobyte-seconds). */
+ __usage->ru_idrss = usage32.ru_idrss;
+ /* Amount of stack memory used (kilobyte-seconds). */
+ __usage->ru_isrss = usage32.ru_isrss;
+ /* Number of soft page faults (i.e. those serviced by reclaiming
+ a page from the list of pages awaiting reallocation. */
+ __usage->ru_minflt = usage32.ru_minflt;
+ /* Number of hard page faults (i.e. those that required I/O). */
+ __usage->ru_majflt = usage32.ru_majflt;
+ /* Number of times a process was swapped out of physical memory. */
+ __usage->ru_nswap = usage32.ru_nswap;
+ /* Number of input operations via the file system. Note: This
+ and `ru_oublock' do not include operations with the cache. */
+ __usage->ru_inblock = usage32.ru_inblock;
+ /* Number of output operations via the file system. */
+ __usage->ru_oublock = usage32.ru_oublock;
+ /* Number of IPC messages sent. */
+ __usage->ru_msgsnd = usage32.ru_msgsnd;
+ /* Number of IPC messages received. */
+ __usage->ru_msgrcv = usage32.ru_msgrcv;
+ /* Number of signals delivered. */
+ __usage->ru_nsignals = usage32.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). */
+ __usage->ru_nvcsw = usage32.ru_nvcsw;
+ /* Number of involuntary context switches, i.e. a higher priority process
+ became runnable or the current process used up its time slice. */
+ __usage->ru_nivcsw = usage32.ru_nivcsw;
+
+ return result;
+}
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 423ac62a34..642fe791c5 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -84,6 +84,15 @@ extern int setrlimit64 (__rlimit_resource_t __resource,
/* Return resource usage information on process indicated by WHO
and put it in *USAGE. Returns 0 for success, -1 for failure. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern double __REDIRECT (getrusage, (__rusage_who_t __who,
+ struct rusage *__usage),
+ __getrusage_t64) __THROW;
+# else
+# define getrusage __getrusage_t64
+# endif
+#endif
extern int getrusage (__rusage_who_t __who, struct rusage *__usage) __THROW;
/* Return the highest priority of any process specified by WHICH and WHO