1/* Compatibility definitions for 'struct timeval' with 32-bit time_t.
2 Copyright (C) 2020-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _TV32_COMPAT_H
20#define _TV32_COMPAT_H 1
21
22#include <bits/types/time_t.h>
23#include <sys/resource.h>
24
25/* Structures containing 'struct timeval' with 32-bit time_t. */
26struct __itimerval32
27{
28 struct __timeval32 it_interval;
29 struct __timeval32 it_value;
30};
31
32struct __rusage32
33{
34 struct __timeval32 ru_utime; /* user time used */
35 struct __timeval32 ru_stime; /* system time used */
36 long ru_maxrss; /* maximum resident set size */
37 long ru_ixrss; /* integral shared memory size */
38 long ru_idrss; /* integral unshared data size */
39 long ru_isrss; /* integral unshared stack size */
40 long ru_minflt; /* page reclaims */
41 long ru_majflt; /* page faults */
42 long ru_nswap; /* swaps */
43 long ru_inblock; /* block input operations */
44 long ru_oublock; /* block output operations */
45 long ru_msgsnd; /* messages sent */
46 long ru_msgrcv; /* messages received */
47 long ru_nsignals; /* signals received */
48 long ru_nvcsw; /* voluntary context switches */
49 long ru_nivcsw; /* involuntary " */
50};
51
52static inline void
53rusage32_to_rusage64 (const struct __rusage32 *restrict r32,
54 struct __rusage64 *restrict r64)
55{
56 /* Make sure the entire output structure is cleared, including
57 padding and reserved fields. */
58 memset (r64, 0, sizeof *r64);
59
60 r64->ru_utime = valid_timeval32_to_timeval64 (tv: r32->ru_utime);
61 r64->ru_stime = valid_timeval32_to_timeval64 (tv: r32->ru_stime);
62 r64->ru_maxrss = r32->ru_maxrss;
63 r64->ru_ixrss = r32->ru_ixrss;
64 r64->ru_idrss = r32->ru_idrss;
65 r64->ru_isrss = r32->ru_isrss;
66 r64->ru_minflt = r32->ru_minflt;
67 r64->ru_majflt = r32->ru_majflt;
68 r64->ru_nswap = r32->ru_nswap;
69 r64->ru_inblock = r32->ru_inblock;
70 r64->ru_oublock = r32->ru_oublock;
71 r64->ru_msgsnd = r32->ru_msgsnd;
72 r64->ru_msgrcv = r32->ru_msgrcv;
73 r64->ru_nsignals = r32->ru_nsignals;
74 r64->ru_nvcsw = r32->ru_nvcsw;
75 r64->ru_nivcsw = r32->ru_nivcsw;
76}
77
78static inline void
79rusage64_to_rusage32 (const struct __rusage64 *restrict r64,
80 struct __rusage32 *restrict r32)
81{
82 /* Make sure the entire output structure is cleared, including
83 padding and reserved fields. */
84 memset (r32, 0, sizeof *r32);
85
86 r32->ru_utime = valid_timeval64_to_timeval32 (tv64: r64->ru_utime);
87 r32->ru_stime = valid_timeval64_to_timeval32 (tv64: r64->ru_stime);
88 r32->ru_maxrss = r64->ru_maxrss;
89 r32->ru_ixrss = r64->ru_ixrss;
90 r32->ru_idrss = r64->ru_idrss;
91 r32->ru_isrss = r64->ru_isrss;
92 r32->ru_minflt = r64->ru_minflt;
93 r32->ru_majflt = r64->ru_majflt;
94 r32->ru_nswap = r64->ru_nswap;
95 r32->ru_inblock = r64->ru_inblock;
96 r32->ru_oublock = r64->ru_oublock;
97 r32->ru_msgsnd = r64->ru_msgsnd;
98 r32->ru_msgrcv = r64->ru_msgrcv;
99 r32->ru_nsignals = r64->ru_nsignals;
100 r32->ru_nvcsw = r64->ru_nvcsw;
101 r32->ru_nivcsw = r64->ru_nivcsw;
102}
103
104#endif /* tv32-compat.h */
105

source code of glibc/sysdeps/unix/sysv/linux/tv32-compat.h