mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
Define struct rusage in sys/wait.h when required (bug 21575).
Some older standards (XPG4.2 through POSIX.1:2001, XSI only) require sys/wait.h to include the definition of struct rusage. This is missing in glibc. This patch adds the required definition. struct rusage is moved to a new header bits/types/struct_rusage.h to avoid bringing in the whole of sys/resource.h (although the standards in question do allow the whole of sys/resource.h to be brought in). In the five bits/resource.h headers, the only variation between the definitions of struct rusage is that the sysdeps/unix/sysv/linux version is prepared for x32 (by having anonymous unions with __syscall_slong_t fields) and the others are not. Thus, this version is suitable for use generically (everything other than x32 simply has __syscall_slong_t the same as long int, so there are no API or ABI changes involved, and anonymous unions are already a required language feature for glibc headers elsewhere), and this patch uses it as a base for the single implementation of bits/types/struct_rusage.h. Tested for x86_64, and with build-many-glibcs.py. [BZ #21575] * resource/bits/types/struct_rusage.h: New file. * include/bits/types/struct_rusage.h: Likewise. * bits/resource.h (struct rusage): Include <bits/types/struct_rusage.h> instead of defining here. * sysdeps/unix/sysv/linux/bits/resource.h (struct rusage): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/resource.h (struct rusage): Likewise. * sysdeps/unix/sysv/linux/mips/bits/resource.h (struct rusage): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/resource.h (struct rusage): Likewise. * resource/Makefile (headers): Add bits/types/struct_rusage.h. * posix/sys/wait.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K8]: Include <bits/types/struct_rusage.h>
This commit is contained in:
parent
5b83faf6a7
commit
a66bc30d6b
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
2017-06-19 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
[BZ #21575]
|
||||
* resource/bits/types/struct_rusage.h: New file.
|
||||
* include/bits/types/struct_rusage.h: Likewise.
|
||||
* bits/resource.h (struct rusage): Include
|
||||
<bits/types/struct_rusage.h> instead of defining here.
|
||||
* sysdeps/unix/sysv/linux/bits/resource.h (struct rusage):
|
||||
Likewise.
|
||||
* sysdeps/unix/sysv/linux/alpha/bits/resource.h (struct rusage):
|
||||
Likewise.
|
||||
* sysdeps/unix/sysv/linux/mips/bits/resource.h (struct rusage):
|
||||
Likewise.
|
||||
* sysdeps/unix/sysv/linux/sparc/bits/resource.h (struct rusage):
|
||||
Likewise.
|
||||
* resource/Makefile (headers): Add bits/types/struct_rusage.h.
|
||||
* posix/sys/wait.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K8]:
|
||||
Include <bits/types/struct_rusage.h>
|
||||
|
||||
2017-06-19 Florian Weimer <fweimer@redhat.com>
|
||||
|
||||
* malloc/dynarray.h: Use libc_hidden_proto only for !_ISOMAC.
|
||||
|
@ -130,49 +130,7 @@ enum __rusage_who
|
||||
};
|
||||
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
||||
/* Structure which says how much of each resource has been used. */
|
||||
struct rusage
|
||||
{
|
||||
/* Total amount of user time used. */
|
||||
struct timeval ru_utime;
|
||||
/* Total amount of system time used. */
|
||||
struct timeval ru_stime;
|
||||
/* Maximum resident set size (in kilobytes). */
|
||||
long int ru_maxrss;
|
||||
/* Amount of sharing of text segment memory
|
||||
with other processes (kilobyte-seconds). */
|
||||
long int ru_ixrss;
|
||||
/* Amount of data segment memory used (kilobyte-seconds). */
|
||||
long int ru_idrss;
|
||||
/* Amount of stack memory used (kilobyte-seconds). */
|
||||
long int ru_isrss;
|
||||
/* Number of soft page faults (i.e. those serviced by reclaiming
|
||||
a page from the list of pages awaiting reallocation. */
|
||||
long int ru_minflt;
|
||||
/* Number of hard page faults (i.e. those that required I/O). */
|
||||
long int ru_majflt;
|
||||
/* Number of times a process was swapped out of physical memory. */
|
||||
long int ru_nswap;
|
||||
/* Number of input operations via the file system. Note: This
|
||||
and `ru_oublock' do not include operations with the cache. */
|
||||
long int ru_inblock;
|
||||
/* Number of output operations via the file system. */
|
||||
long int ru_oublock;
|
||||
/* Number of IPC messages sent. */
|
||||
long int ru_msgsnd;
|
||||
/* Number of IPC messages received. */
|
||||
long int ru_msgrcv;
|
||||
/* Number of signals delivered. */
|
||||
long int 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). */
|
||||
long int ru_nvcsw;
|
||||
/* Number of involuntary context switches, i.e. a higher priority process
|
||||
became runnable or the current process used up its time slice. */
|
||||
long int ru_nivcsw;
|
||||
};
|
||||
#include <bits/types/struct_rusage.h>
|
||||
|
||||
/* Priority limits. */
|
||||
#define PRIO_MIN -20 /* Minimum priority a process can have. */
|
||||
|
1
include/bits/types/struct_rusage.h
Normal file
1
include/bits/types/struct_rusage.h
Normal file
@ -0,0 +1 @@
|
||||
#include <resource/bits/types/struct_rusage.h>
|
@ -36,6 +36,12 @@ typedef __pid_t pid_t;
|
||||
# include <signal.h>
|
||||
#endif
|
||||
|
||||
#if defined __USE_XOPEN_EXTENDED && !defined __USE_XOPEN2K8
|
||||
/* Some older standards require the contents of struct rusage to be
|
||||
defined here. */
|
||||
# include <bits/types/struct_rusage.h>
|
||||
#endif
|
||||
|
||||
/* These macros could also be defined in <stdlib.h>. */
|
||||
#if !defined _STDLIB_H || (!defined __USE_XOPEN && !defined __USE_XOPEN2K8)
|
||||
/* This will define the `W*' macros for the flag
|
||||
|
@ -20,7 +20,7 @@ subdir := resource
|
||||
include ../Makeconfig
|
||||
|
||||
headers := sys/resource.h bits/resource.h sys/vlimit.h sys/vtimes.h \
|
||||
ulimit.h
|
||||
ulimit.h bits/types/struct_rusage.h
|
||||
|
||||
routines := getrlimit setrlimit getrlimit64 setrlimit64 getrusage ulimit \
|
||||
vlimit vtimes getpriority setpriority nice
|
||||
|
130
resource/bits/types/struct_rusage.h
Normal file
130
resource/bits/types/struct_rusage.h
Normal file
@ -0,0 +1,130 @@
|
||||
/* Define struct rusage.
|
||||
Copyright (C) 1994-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/>. */
|
||||
|
||||
#ifndef __rusage_defined
|
||||
#define __rusage_defined 1
|
||||
|
||||
#include <bits/types.h>
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
||||
/* Structure which says how much of each resource has been used. */
|
||||
|
||||
/* 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
|
||||
{
|
||||
/* Total amount of user time used. */
|
||||
struct timeval ru_utime;
|
||||
/* 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;
|
||||
};
|
||||
/* 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;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
@ -176,49 +176,7 @@ enum __rusage_who
|
||||
};
|
||||
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
||||
/* Structure which says how much of each resource has been used. */
|
||||
struct rusage
|
||||
{
|
||||
/* Total amount of user time used. */
|
||||
struct timeval ru_utime;
|
||||
/* Total amount of system time used. */
|
||||
struct timeval ru_stime;
|
||||
/* Maximum resident set size (in kilobytes). */
|
||||
long int ru_maxrss;
|
||||
/* Amount of sharing of text segment memory
|
||||
with other processes (kilobyte-seconds). */
|
||||
long int ru_ixrss;
|
||||
/* Amount of data segment memory used (kilobyte-seconds). */
|
||||
long int ru_idrss;
|
||||
/* Amount of stack memory used (kilobyte-seconds). */
|
||||
long int ru_isrss;
|
||||
/* Number of soft page faults (i.e. those serviced by reclaiming
|
||||
a page from the list of pages awaiting reallocation. */
|
||||
long int ru_minflt;
|
||||
/* Number of hard page faults (i.e. those that required I/O). */
|
||||
long int ru_majflt;
|
||||
/* Number of times a process was swapped out of physical memory. */
|
||||
long int ru_nswap;
|
||||
/* Number of input operations via the file system. Note: This
|
||||
and `ru_oublock' do not include operations with the cache. */
|
||||
long int ru_inblock;
|
||||
/* Number of output operations via the file system. */
|
||||
long int ru_oublock;
|
||||
/* Number of IPC messages sent. */
|
||||
long int ru_msgsnd;
|
||||
/* Number of IPC messages received. */
|
||||
long int ru_msgrcv;
|
||||
/* Number of signals delivered. */
|
||||
long int 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). */
|
||||
long int ru_nvcsw;
|
||||
/* Number of involuntary context switches, i.e. a higher priority process
|
||||
became runnable or the current process used up its time slice. */
|
||||
long int ru_nivcsw;
|
||||
};
|
||||
#include <bits/types/struct_rusage.h>
|
||||
|
||||
/* Priority limits. */
|
||||
#define PRIO_MIN -20 /* Minimum priority a process can have. */
|
||||
|
@ -176,111 +176,7 @@ enum __rusage_who
|
||||
};
|
||||
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
||||
/* Structure which says how much of each resource has been used. */
|
||||
|
||||
/* 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
|
||||
{
|
||||
/* Total amount of user time used. */
|
||||
struct timeval ru_utime;
|
||||
/* 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;
|
||||
};
|
||||
/* 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;
|
||||
};
|
||||
};
|
||||
#include <bits/types/struct_rusage.h>
|
||||
|
||||
/* Priority limits. */
|
||||
#define PRIO_MIN -20 /* Minimum priority a process can have. */
|
||||
|
@ -184,49 +184,7 @@ enum __rusage_who
|
||||
};
|
||||
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
||||
/* Structure which says how much of each resource has been used. */
|
||||
struct rusage
|
||||
{
|
||||
/* Total amount of user time used. */
|
||||
struct timeval ru_utime;
|
||||
/* Total amount of system time used. */
|
||||
struct timeval ru_stime;
|
||||
/* Maximum resident set size (in kilobytes). */
|
||||
long int ru_maxrss;
|
||||
/* Amount of sharing of text segment memory
|
||||
with other processes (kilobyte-seconds). */
|
||||
long int ru_ixrss;
|
||||
/* Amount of data segment memory used (kilobyte-seconds). */
|
||||
long int ru_idrss;
|
||||
/* Amount of stack memory used (kilobyte-seconds). */
|
||||
long int ru_isrss;
|
||||
/* Number of soft page faults (i.e. those serviced by reclaiming
|
||||
a page from the list of pages awaiting reallocation. */
|
||||
long int ru_minflt;
|
||||
/* Number of hard page faults (i.e. those that required I/O). */
|
||||
long int ru_majflt;
|
||||
/* Number of times a process was swapped out of physical memory. */
|
||||
long int ru_nswap;
|
||||
/* Number of input operations via the file system. Note: This
|
||||
and `ru_oublock' do not include operations with the cache. */
|
||||
long int ru_inblock;
|
||||
/* Number of output operations via the file system. */
|
||||
long int ru_oublock;
|
||||
/* Number of IPC messages sent. */
|
||||
long int ru_msgsnd;
|
||||
/* Number of IPC messages received. */
|
||||
long int ru_msgrcv;
|
||||
/* Number of signals delivered. */
|
||||
long int 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). */
|
||||
long int ru_nvcsw;
|
||||
/* Number of involuntary context switches, i.e. a higher priority process
|
||||
became runnable or the current process used up its time slice. */
|
||||
long int ru_nivcsw;
|
||||
};
|
||||
#include <bits/types/struct_rusage.h>
|
||||
|
||||
/* Priority limits. */
|
||||
#define PRIO_MIN -20 /* Minimum priority a process can have. */
|
||||
|
@ -192,49 +192,7 @@ enum __rusage_who
|
||||
};
|
||||
|
||||
#include <bits/types/struct_timeval.h>
|
||||
|
||||
/* Structure which says how much of each resource has been used. */
|
||||
struct rusage
|
||||
{
|
||||
/* Total amount of user time used. */
|
||||
struct timeval ru_utime;
|
||||
/* Total amount of system time used. */
|
||||
struct timeval ru_stime;
|
||||
/* Maximum resident set size (in kilobytes). */
|
||||
long int ru_maxrss;
|
||||
/* Amount of sharing of text segment memory
|
||||
with other processes (kilobyte-seconds). */
|
||||
long int ru_ixrss;
|
||||
/* Amount of data segment memory used (kilobyte-seconds). */
|
||||
long int ru_idrss;
|
||||
/* Amount of stack memory used (kilobyte-seconds). */
|
||||
long int ru_isrss;
|
||||
/* Number of soft page faults (i.e. those serviced by reclaiming
|
||||
a page from the list of pages awaiting reallocation. */
|
||||
long int ru_minflt;
|
||||
/* Number of hard page faults (i.e. those that required I/O). */
|
||||
long int ru_majflt;
|
||||
/* Number of times a process was swapped out of physical memory. */
|
||||
long int ru_nswap;
|
||||
/* Number of input operations via the file system. Note: This
|
||||
and `ru_oublock' do not include operations with the cache. */
|
||||
long int ru_inblock;
|
||||
/* Number of output operations via the file system. */
|
||||
long int ru_oublock;
|
||||
/* Number of IPC messages sent. */
|
||||
long int ru_msgsnd;
|
||||
/* Number of IPC messages received. */
|
||||
long int ru_msgrcv;
|
||||
/* Number of signals delivered. */
|
||||
long int 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). */
|
||||
long int ru_nvcsw;
|
||||
/* Number of involuntary context switches, i.e. a higher priority process
|
||||
became runnable or the current process used up its time slice. */
|
||||
long int ru_nivcsw;
|
||||
};
|
||||
#include <bits/types/struct_rusage.h>
|
||||
|
||||
/* Priority limits. */
|
||||
#define PRIO_MIN -20 /* Minimum priority a process can have. */
|
||||
|
Loading…
Reference in New Issue
Block a user