From patchwork Tue Mar 31 15:46:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 38693 Return-Path: X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by sourceware.org (Postfix) with ESMTPS id 32795385DC02 for ; Tue, 31 Mar 2020 15:54:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 32795385DC02 IronPort-SDR: KaghAsExMUByredyBBBz76+6P5xESvBlg80IPevU1I3UwTuWdKx1IfECbc28fk9ne9XMe7j+lK 065OLYy3MnWYQ6+a9bYLkQFF/F8gdqesbQ2QKBWHOMLqCn4wko5Hg2KywTEsA499TW0c2SfZCP +ZPOntgEfB1hLUUpr70fIOhhAg7EMXSslvuQ+7RwkHJouTFgmObGMe4unnisUfTSZyqfxHuzoD JfAq5buYxZwofCndAFM9oFrn4VdWWrVZXNAQqs27erJOJ/69552rAXse/RzNgeA8RpIbr4ViFN +zs= X-IronPort-AV: E=Sophos;i="5.72,328,1580745600"; d="scan'208";a="134068951" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 31 Mar 2020 23:54:41 +0800 IronPort-SDR: rCbEkypnWrGO/ZMa0y9mBAqloA5fuJOjRfplly7FydWjKfTCR1QJJ86JyqDNRSLNX8ys9oqEfm UgVyfgg4GdPrn84VQFlgk/b2kJpoVmxfjNb+cbLEFWfUhwSrM4oVKfQUYgfqVMGJVjnxlHP1OT Q3l7ojqWXMyezt6tR8rEYwMSfIO7OuhS7uAf+s1lo99cOik/dLQEgKB4CF3Lxp9EQiwQeJ2PlE OV3EYt6wE+b8D1IiOvM5f4s5LZAEVABx5FAHtHdrzejetUUS1mO6pN/vXmQmRZTl1u95ABwjFG A5HxhlcWPJiof6DS9wCbUvC6 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Mar 2020 08:45:35 -0700 IronPort-SDR: gN2WZubg2Bb8d9W7PS/4zU+CEBwvV6ASbIngXZtCoSXxemHNUDtSe+HhTXGp637J6xJk1zENjs c2a/1XmC0sBrIhy1L9JoyMFfWLxRqaFXWGs8JWoiO695yRReZa+Y3rt0AduE8CWmikSGZtsoNq f4i148oGDYa/K40NvJ46lviSwuOVDLdMaN8k09LxQee/E492bmrb7YXcf3UxDuLpoKi+yZIWCe 0U+9QbA7UWRClHFOkrvmFggc4H12o0ODuMssIPkm6sBAInyFIBWagMt6QLa7tDTQENRnZB95Ba aLc= WDCIronportException: Internal Received: from usa001473.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.55.8]) by uls-op-cesaip01.wdc.com with ESMTP; 31 Mar 2020 08:54:41 -0700 From: Alistair Francis To: libc-alpha@sourceware.org Cc: Vineet.Gupta1@synopsys.com, alistair23@gmail.com, Alistair Francis , Lukasz Majewski Subject: [PATCH v7 5/5] sysv/alpha: Use generic __timeval32 and helpers Date: Tue, 31 Mar 2020 08:46:56 -0700 Message-Id: <20200331154656.687841-6-alistair.francis@wdc.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331154656.687841-1-alistair.francis@wdc.com> References: <20200331154656.687841-1-alistair.francis@wdc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-26.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 15:54:47 -0000 Now there is a generic __timeval32 and helpers we can use them for Alpha instead of the Alpha specific ones. Reviewed-by: Lukasz Majewski --- .../unix/sysv/linux/alpha/alpha-tv32-compat.h | 124 ------------------ sysdeps/unix/sysv/linux/alpha/osf_adjtime.c | 15 ++- sysdeps/unix/sysv/linux/alpha/osf_getitimer.c | 9 +- sysdeps/unix/sysv/linux/alpha/osf_getrusage.c | 10 +- .../unix/sysv/linux/alpha/osf_gettimeofday.c | 6 +- sysdeps/unix/sysv/linux/alpha/osf_setitimer.c | 15 ++- .../unix/sysv/linux/alpha/osf_settimeofday.c | 6 +- sysdeps/unix/sysv/linux/alpha/osf_utimes.c | 8 +- sysdeps/unix/sysv/linux/alpha/osf_wait4.c | 10 +- sysdeps/unix/sysv/linux/tv32-compat.h | 26 ++++ 10 files changed, 67 insertions(+), 162 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h diff --git a/sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h b/sysdeps/unix/sysv/linux/alpha/alpha-tv32-compat.h deleted file mode 100644 index 3f80946a02..0000000000 --- a/sysdeps/unix/sysv/linux/alpha/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 -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 f0a1123639..95d646452e 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_adjtime.c @@ -20,9 +20,10 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +#include #include #include -#include +#include struct timex32 { unsigned int modes; /* mode selector */ @@ -36,7 +37,7 @@ struct timex32 { long tolerance; /* clock frequency tolerance (ppm) * (read only) */ - struct timeval32 time; /* (read only) */ + struct __timeval32 time; /* (read only) */ long tick; /* (modified) usecs between clock ticks */ long ppsfreq; /* pps frequency (scaled ppm) (ro) */ @@ -55,15 +56,15 @@ struct timex32 { int attribute_compat_text_section -__adjtime_tv32 (const struct timeval32 *itv, struct timeval32 *otv) +__adjtime_tv32 (const struct __timeval32 *itv, struct __timeval32 *otv) { - struct timeval itv64 = alpha_valid_timeval32_to_timeval (*itv); + struct timeval itv64 = valid_timeval32_to_timeval (*itv); struct timeval otv64; if (__adjtime (&itv64, &otv64) == -1) return -1; - *otv = alpha_valid_timeval_to_timeval32 (otv64); + *otv = valid_timeval_to_timeval32 (otv64); return 0; } @@ -91,7 +92,7 @@ __adjtimex_tv32 (struct timex32 *tx) tx64.calcnt = tx->calcnt; tx64.errcnt = tx->errcnt; tx64.stbcnt = tx->stbcnt; - tx64.time = alpha_valid_timeval32_to_timeval (tx->time); + tx64.time = valid_timeval32_to_timeval (tx->time); int status = __adjtimex (&tx64); if (status < 0) @@ -116,7 +117,7 @@ __adjtimex_tv32 (struct timex32 *tx) tx->calcnt = tx64.calcnt; tx->errcnt = tx64.errcnt; tx->stbcnt = tx64.stbcnt; - tx->time = alpha_valid_timeval_to_timeval32 (tx64.time); + tx->time = 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 204d4ba796..4d25060e96 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_getitimer.c @@ -20,12 +20,13 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +#include #include -#include +#include int attribute_compat_text_section -__getitimer_tv32 (int which, struct itimerval32 *curr_value) +__getitimer_tv32 (int which, struct __itimerval32 *curr_value) { struct itimerval curr_value_64; if (__getitimer (which, &curr_value_64) == -1) @@ -33,9 +34,9 @@ __getitimer_tv32 (int which, struct itimerval32 *curr_value) /* Write all fields of 'curr_value' regardless of overflow. */ curr_value->it_interval - = alpha_valid_timeval_to_timeval32 (curr_value_64.it_interval); + = valid_timeval_to_timeval32 (curr_value_64.it_interval); curr_value->it_value - = alpha_valid_timeval_to_timeval32 (curr_value_64.it_value); + = 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 be81994654..95cedb0cf6 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_getrusage.c @@ -22,16 +22,16 @@ #include #include -#include +#include int -__getrusage_tv32 (int who, struct rusage32 *usage32) +__getrusage_tv32 (int who, struct __rusage32 *usage32) { - struct rusage usage64; - if (__getrusage (who, &usage64) == -1) + struct rusage usage; + if (__getrusage (who, &usage) == -1) return -1; - alpha_rusage64_to_rusage32 (usage32, &usage64); + rusage64_to_rusage32 (&usage, usage32); return 0; } diff --git a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c index 9ffda2fde3..8cf5d303f9 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c @@ -20,17 +20,17 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +#include #include #include #include -#include /* Get the current time of day and timezone information putting it into *TV and *TZ. */ int attribute_compat_text_section -__gettimeofday_tv32 (struct timeval32 *restrict tv32, void *restrict tz) +__gettimeofday_tv32 (struct __timeval32 *restrict tv32, void *restrict tz) { if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof (struct timezone)); @@ -38,7 +38,7 @@ __gettimeofday_tv32 (struct timeval32 *restrict tv32, void *restrict tz) struct timespec ts; __clock_gettime (CLOCK_REALTIME, &ts); - *tv32 = alpha_valid_timespec_to_timeval32 (ts); + *tv32 = 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 726dfc8b0e..842ab5f64e 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_setitimer.c @@ -20,19 +20,20 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +#include #include -#include +#include int attribute_compat_text_section -__setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, - struct itimerval32 *restrict old_value) +__setitimer_tv32 (int which, const struct __itimerval32 *restrict new_value, + struct __itimerval32 *restrict old_value) { struct itimerval new_value_64; new_value_64.it_interval - = alpha_valid_timeval32_to_timeval (new_value->it_interval); + = valid_timeval32_to_timeval (new_value->it_interval); new_value_64.it_value - = alpha_valid_timeval32_to_timeval (new_value->it_value); + = valid_timeval32_to_timeval (new_value->it_value); if (old_value == NULL) return __setitimer (which, &new_value_64, NULL); @@ -43,9 +44,9 @@ __setitimer_tv32 (int which, const struct itimerval32 *restrict new_value, /* Write all fields of 'old_value' regardless of overflow. */ old_value->it_interval - = alpha_valid_timeval_to_timeval32 (old_value_64.it_interval); + = valid_timeval_to_timeval32 (old_value_64.it_interval); old_value->it_value - = alpha_valid_timeval_to_timeval32 (old_value_64.it_value); + = 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 044363e079..5ea0a5afb7 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_settimeofday.c @@ -20,16 +20,16 @@ #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) +#include #include #include #include -#include /* Set the current time of day and timezone information. This call is restricted to the super-user. */ int attribute_compat_text_section -__settimeofday_tv32 (const struct timeval32 *tv32, +__settimeofday_tv32 (const struct __timeval32 *tv32, const struct timezone *tz) { if (__glibc_unlikely (tz != 0)) @@ -42,7 +42,7 @@ __settimeofday_tv32 (const struct timeval32 *tv32, return __settimezone (tz); } - struct timespec ts = alpha_valid_timeval32_to_timespec (*tv32); + struct timespec ts = 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 8ad9fb567c..8afbf12185 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_utimes.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_utimes.c @@ -20,16 +20,16 @@ #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]) +__utimes_tv32 (const char *filename, const struct __timeval32 times32[2]) { struct timeval times[2]; - times[0] = alpha_valid_timeval32_to_timeval (times32[0]); - times[1] = alpha_valid_timeval32_to_timeval (times32[1]); + times[0] = valid_timeval32_to_timeval (times32[0]); + times[1] = 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 c664e8e93f..4242d5227f 100644 --- a/sysdeps/unix/sysv/linux/alpha/osf_wait4.c +++ b/sysdeps/unix/sysv/linux/alpha/osf_wait4.c @@ -23,17 +23,17 @@ #include #include #include -#include +#include pid_t attribute_compat_text_section -__wait4_tv32 (pid_t pid, int *status, int options, struct rusage32 *usage32) +__wait4_tv32 (pid_t pid, int *status, int options, struct __rusage32 *usage32) { - struct rusage usage64; - pid_t child = __wait4 (pid, status, options, &usage64); + struct rusage usage; + pid_t child = __wait4 (pid, status, options, &usage); if (child >= 0 && usage32 != NULL) - alpha_rusage64_to_rusage32 (usage32, &usage64); + rusage64_to_rusage32 (&usage, usage32); return child; } diff --git a/sysdeps/unix/sysv/linux/tv32-compat.h b/sysdeps/unix/sysv/linux/tv32-compat.h index 574284fc8e..d19b3b378d 100644 --- a/sysdeps/unix/sysv/linux/tv32-compat.h +++ b/sysdeps/unix/sysv/linux/tv32-compat.h @@ -75,4 +75,30 @@ rusage32_to_rusage64 (const struct __rusage32 *restrict r32, r64->ru_nivcsw = r32->ru_nivcsw; } +static inline void +rusage64_to_rusage32 (const struct __rusage64 *restrict r64, + struct __rusage32 *restrict r32) +{ + /* Make sure the entire output structure is cleared, including + padding and reserved fields. */ + memset (r32, 0, sizeof *r32); + + r32->ru_utime = valid_timeval64_to_timeval32 (r64->ru_utime); + r32->ru_stime = valid_timeval64_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 */