From 4da2597af5cda0752c7526fe97398a5dafc15cbf Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Mon, 20 Jan 2020 23:54:35 -0800 Subject: sysv/linux: Rename alpha functions to be alpha specific These functions are alpha specifc, rename them to be clear. Let's also rename the header file from tv32-compat.h to alpha-tv32-compat.h. This is to avoid conflicts with the one we will introduce later. Reviewed-by: Lukasz Majewski Reviewed-by: Adhemerval Zanella --- sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h | 124 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/alpha/osf_adjtime.c | 10 +- sysdeps/unix/sysv/linux/alpha/osf_getitimer.c | 6 +- sysdeps/unix/sysv/linux/alpha/osf_getrusage.c | 4 +- sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c | 4 +- sysdeps/unix/sysv/linux/alpha/osf_setitimer.c | 10 +- sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c | 4 +- sysdeps/unix/sysv/linux/alpha/osf_utimes.c | 6 +- sysdeps/unix/sysv/linux/alpha/osf_wait4.c | 4 +- sysdeps/unix/sysv/linux/alpha/tv32-compat.h | 124 ---------------------- 10 files changed, 148 insertions(+), 148 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h delete mode 100644 sysdeps/unix/sysv/linux/alpha/tv32-compat.h (limited to 'sysdeps/unix/sysv') diff --git a/sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h new file mode 100644 index 0000000..3f80946 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h @@ -0,0 +1,124 @@ +/* Compatibility definitions for `struct timeval' with 32-bit time_t. + Copyright (C) 2019-2020 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 + . */ + +#ifndef _TV32_COMPAT_H +#define _TV32_COMPAT_H 1 + +#include + +#include +#include +#include +#include +#include + +#include // for INT32_MAX +#include // for memset + +#define TV_USEC_MAX 999999 // 10**6 - 1 + +/* A version of 'struct timeval' with 32-bit time_t. */ +struct timeval32 +{ + int32_t tv_sec; + int32_t tv_usec; +}; + +/* Structures containing 'struct timeval' with 32-bit time_t. */ +struct itimerval32 +{ + struct timeval32 it_interval; + struct timeval32 it_value; +}; + +struct rusage32 +{ + struct timeval32 ru_utime; /* user time used */ + struct timeval32 ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +/* Conversion functions. If the seconds field of a timeval32 would + overflow, they write { INT32_MAX, TV_USEC_MAX } to the output. */ + +static inline struct timeval +alpha_valid_timeval32_to_timeval (const struct timeval32 tv) +{ + return (struct timeval) { tv.tv_sec, tv.tv_usec }; +} + +static inline struct timeval32 +alpha_valid_timeval_to_timeval32 (const struct timeval tv64) +{ + if (__glibc_unlikely (tv64.tv_sec > (time_t) INT32_MAX)) + return (struct timeval32) { INT32_MAX, TV_USEC_MAX}; + return (struct timeval32) { tv64.tv_sec, tv64.tv_usec }; +} + +static inline struct timespec +alpha_valid_timeval32_to_timespec (const struct timeval32 tv) +{ + return (struct timespec) { tv.tv_sec, tv.tv_usec * 1000 }; +} + +static inline struct timeval32 +alpha_valid_timespec_to_timeval32 (const struct timespec ts) +{ + return (struct timeval32) { (time_t) ts.tv_sec, ts.tv_nsec / 1000 }; +} + +static inline void +alpha_rusage64_to_rusage32 (struct rusage32 *restrict r32, + const struct rusage *restrict r64) +{ + /* Make sure the entire output structure is cleared, including + padding and reserved fields. */ + memset (r32, 0, sizeof *r32); + + r32->ru_utime = alpha_valid_timeval_to_timeval32 (r64->ru_utime); + r32->ru_stime = alpha_valid_timeval_to_timeval32 (r64->ru_stime); + r32->ru_maxrss = r64->ru_maxrss; + r32->ru_ixrss = r64->ru_ixrss; + r32->ru_idrss = r64->ru_idrss; + r32->ru_isrss = r64->ru_isrss; + r32->ru_minflt = r64->ru_minflt; + r32->ru_majflt = r64->ru_majflt; + r32->ru_nswap = r64->ru_nswap; + r32->ru_inblock = r64->ru_inblock; + r32->ru_oublock = r64->ru_oublock; + r32->ru_msgsnd = r64->ru_msgsnd; + r32->ru_msgrcv = r64->ru_msgrcv; + r32->ru_nsignals = r64->ru_nsignals; + r32->ru_nvcsw = r64->ru_nvcsw; + r32->ru_nivcsw = r64->ru_nivcsw; +} + +#endif /* alpha-tv32-compat.h */ diff --git a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c index 9825a47..f0a1123 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c @@ -22,7 +22,7 @@ #include #include -#include +#include struct timex32 { unsigned int modes; /* mode selector */ @@ -57,13 +57,13 @@ int attribute_compat_text_section __adjtime_tv32 (const struct timeval32 *itv, struct timeval32 *otv) { - struct timeval itv64 = valid_timeval32_to_timeval (*itv); + struct timeval itv64 = alpha_valid_timeval32_to_timeval (*itv); struct timeval otv64; if (__adjtime (&itv64, &otv64) == -1) return -1; - *otv = valid_timeval_to_timeval32 (otv64); + *otv = alpha_valid_timeval_to_timeval32 (otv64); return 0; } @@ -91,7 +91,7 @@ __adjtimex_tv32 (struct timex32 *tx) tx64.calcnt = tx->calcnt; tx64.errcnt = tx->errcnt; tx64.stbcnt = tx->stbcnt; - tx64.time = valid_timeval32_to_timeval (tx->time); + tx64.time = alpha_valid_timeval32_to_timeval (tx->time); int status = __adjtimex (&tx64); if (status < 0) @@ -116,7 +116,7 @@ __adjtimex_tv32 (struct timex32 *tx) tx->calcnt = tx64.calcnt; tx->errcnt = tx64.errcnt; tx->stbcnt = tx64.stbcnt; - tx->time = valid_timeval_to_timeval32 (tx64.time); + tx->time = alpha_valid_timeval_to_timeval32 (tx64.time); return status; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c index e9de2b2..204d4ba 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c @@ -21,7 +21,7 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) #include -#include +#include int attribute_compat_text_section @@ -33,9 +33,9 @@ __getitimer_tv32 (int which, struct itimerval32 *curr_value) /* Write all fields of 'curr_value' regardless of overflow. */ curr_value->it_interval - = valid_timeval_to_timeval32 (curr_value_64.it_interval); + = alpha_valid_timeval_to_timeval32 (curr_value_64.it_interval); curr_value->it_value - = valid_timeval_to_timeval32 (curr_value_64.it_value); + = alpha_valid_timeval_to_timeval32 (curr_value_64.it_value); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c b/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c index 74c6fb4..be81994 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c @@ -22,7 +22,7 @@ #include #include -#include +#include int __getrusage_tv32 (int who, struct rusage32 *usage32) @@ -31,7 +31,7 @@ __getrusage_tv32 (int who, struct rusage32 *usage32) if (__getrusage (who, &usage64) == -1) return -1; - rusage64_to_rusage32 (usage32, &usage64); + alpha_rusage64_to_rusage32 (usage32, &usage64); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c index df7f067..9ffda2f 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include /* Get the current time of day and timezone information putting it into *TV and *TZ. */ @@ -38,7 +38,7 @@ __gettimeofday_tv32 (struct timeval32 *restrict tv32, void *restrict tz) struct timespec ts; __clock_gettime (CLOCK_REALTIME, &ts); - *tv32 = valid_timespec_to_timeval32 (ts); + *tv32 = alpha_valid_timespec_to_timeval32 (ts); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c index 7df2d1b..726dfc8 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c @@ -21,7 +21,7 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) #include -#include +#include int attribute_compat_text_section @@ -30,9 +30,9 @@ __setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, { struct itimerval new_value_64; new_value_64.it_interval - = valid_timeval32_to_timeval (new_value->it_interval); + = alpha_valid_timeval32_to_timeval (new_value->it_interval); new_value_64.it_value - = valid_timeval32_to_timeval (new_value->it_value); + = alpha_valid_timeval32_to_timeval (new_value->it_value); if (old_value == NULL) return __setitimer (which, &new_value_64, NULL); @@ -43,9 +43,9 @@ __setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, /* Write all fields of 'old_value' regardless of overflow. */ old_value->it_interval - = valid_timeval_to_timeval32 (old_value_64.it_interval); + = alpha_valid_timeval_to_timeval32 (old_value_64.it_interval); old_value->it_value - = valid_timeval_to_timeval32 (old_value_64.it_value); + = alpha_valid_timeval_to_timeval32 (old_value_64.it_value); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c index 6e17a95..044363e 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include /* Set the current time of day and timezone information. This call is restricted to the super-user. */ @@ -42,7 +42,7 @@ __settimeofday_tv32 (const struct timeval32 *tv32, return __settimezone (tz); } - struct timespec ts = valid_timeval32_to_timespec (*tv32); + struct timespec ts = alpha_valid_timeval32_to_timespec (*tv32); return __clock_settime (CLOCK_REALTIME, &ts); } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_utimes.c b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c index 6c3fad0..8ad9fb5 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_utimes.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c @@ -21,15 +21,15 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) #include -#include +#include int attribute_compat_text_section __utimes_tv32 (const char *filename, const struct timeval32 times32[2]) { struct timeval times[2]; - times[0] = valid_timeval32_to_timeval (times32[0]); - times[1] = valid_timeval32_to_timeval (times32[1]); + times[0] = alpha_valid_timeval32_to_timeval (times32[0]); + times[1] = alpha_valid_timeval32_to_timeval (times32[1]); return __utimes (filename, times); } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_wait4.c b/sysdeps/unix/sysv/linux/alpha/osf_wait4.c index 6af8347..c664e8e 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_wait4.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_wait4.c @@ -23,7 +23,7 @@ #include #include #include -#include +#include pid_t attribute_compat_text_section @@ -33,7 +33,7 @@ __wait4_tv32 (pid_t pid, int *status, int options, struct rusage32 *usage32) pid_t child = __wait4 (pid, status, options, &usage64); if (child >= 0 && usage32 != NULL) - rusage64_to_rusage32 (usage32, &usage64); + alpha_rusage64_to_rusage32 (usage32, &usage64); return child; } diff --git a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/tv32-compat.h deleted file mode 100644 index 8e34ed1..0000000 --- a/sysdeps/unix/sysv/linux/alpha/tv32-compat.h +++ /dev/null @@ -1,124 +0,0 @@ -/* Compatibility definitions for `struct timeval' with 32-bit time_t. - Copyright (C) 2019-2020 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 - . */ - -#ifndef _TV32_COMPAT_H -#define _TV32_COMPAT_H 1 - -#include - -#include -#include -#include -#include -#include - -#include // for INT32_MAX -#include // for memset - -#define TV_USEC_MAX 999999 // 10**6 - 1 - -/* A version of 'struct timeval' with 32-bit time_t. */ -struct timeval32 -{ - int32_t tv_sec; - int32_t tv_usec; -}; - -/* Structures containing 'struct timeval' with 32-bit time_t. */ -struct itimerval32 -{ - struct timeval32 it_interval; - struct timeval32 it_value; -}; - -struct rusage32 -{ - struct timeval32 ru_utime; /* user time used */ - struct timeval32 ru_stime; /* system time used */ - long ru_maxrss; /* maximum resident set size */ - long ru_ixrss; /* integral shared memory size */ - long ru_idrss; /* integral unshared data size */ - long ru_isrss; /* integral unshared stack size */ - long ru_minflt; /* page reclaims */ - long ru_majflt; /* page faults */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary " */ -}; - -/* Conversion functions. If the seconds field of a timeval32 would - overflow, they write { INT32_MAX, TV_USEC_MAX } to the output. */ - -static inline struct timeval -valid_timeval32_to_timeval (const struct timeval32 tv) -{ - return (struct timeval) { tv.tv_sec, tv.tv_usec }; -} - -static inline struct timeval32 -valid_timeval_to_timeval32 (const struct timeval tv64) -{ - if (__glibc_unlikely (tv64.tv_sec > (time_t) INT32_MAX)) - return (struct timeval32) { INT32_MAX, TV_USEC_MAX}; - return (struct timeval32) { tv64.tv_sec, tv64.tv_usec }; -} - -static inline struct timespec -valid_timeval32_to_timespec (const struct timeval32 tv) -{ - return (struct timespec) { tv.tv_sec, tv.tv_usec * 1000 }; -} - -static inline struct timeval32 -valid_timespec_to_timeval32 (const struct timespec ts) -{ - return (struct timeval32) { (time_t) ts.tv_sec, ts.tv_nsec / 1000 }; -} - -static inline void -rusage64_to_rusage32 (struct rusage32 *restrict r32, - const struct rusage *restrict r64) -{ - /* Make sure the entire output structure is cleared, including - padding and reserved fields. */ - memset (r32, 0, sizeof *r32); - - r32->ru_utime = valid_timeval_to_timeval32 (r64->ru_utime); - r32->ru_stime = valid_timeval_to_timeval32 (r64->ru_stime); - r32->ru_maxrss = r64->ru_maxrss; - r32->ru_ixrss = r64->ru_ixrss; - r32->ru_idrss = r64->ru_idrss; - r32->ru_isrss = r64->ru_isrss; - r32->ru_minflt = r64->ru_minflt; - r32->ru_majflt = r64->ru_majflt; - r32->ru_nswap = r64->ru_nswap; - r32->ru_inblock = r64->ru_inblock; - r32->ru_oublock = r64->ru_oublock; - r32->ru_msgsnd = r64->ru_msgsnd; - r32->ru_msgrcv = r64->ru_msgrcv; - r32->ru_nsignals = r64->ru_nsignals; - r32->ru_nvcsw = r64->ru_nvcsw; - r32->ru_nivcsw = r64->ru_nivcsw; -} - -#endif /* tv32-compat.h */ -- cgit v1.1