From patchwork Fri Oct 25 12:08:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 177740 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3603607ill; Fri, 25 Oct 2019 05:10:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiplfNaXjEv0vGz+afZUTLv4bLpupgWbU8Q6CGTLY03u83/j/Z5srzroDh9FpFuDc0nP2b X-Received: by 2002:a50:a781:: with SMTP id i1mr3454165edc.17.1572005434785; Fri, 25 Oct 2019 05:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572005434; cv=none; d=google.com; s=arc-20160816; b=PYaDPEBjFyVeG1W+Sz3bYvzjqTZMIB6kxOxn5r0dv2YApeUUqk6CIxfBlYW3a4nwKK YCiHqAxFlPAhGpumSnAJHf5od1pL3/1a7GZunk8dnW1tXRSwOdjgDlU9+8UVf73fQ6xj UL7fxrH2gyuF8h4aVMtqWQR7K1lstlmrvOj26CsE3TO7ArECqmGxim1tvTLaUrA+4aPw xW+SOjK2h6Gw7F4HuYge+X71ku1beNwg5IqKYocpwiVMYtTHpaj12gwo++BvK20J1ET0 9YnapGJg8bLeBNqEub5IHnysy1rJJy1jjfMN4BKLF6PEMWSMEGKw0rTi1DUeloRvNIvX jweg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=jBJO9TSwKv5u/4AtwkaR+JUyj1cL8dZvLmxvWGyjDOM=; b=C/Usc0T6OGppe5LxTmG5cA4qDj5OGriTgl/UaMJCwJvCA2NLzP5RuzlETnLkfIeQA7 Ehhowb1E3tN4LfZ3oFWvdoVDnUmDg0U2eLtzVgXUbSZOIdcYH+b1Ie9LPRAqE91RImka Sk8b9SfU4oBhBCQDFB2u21l8/+L88T52MPo2K/SlOx26lpwfXZucZ+cxKXArabJpe139 6fT1SUWSbbE+T0HOWlsRpLCNyyN3iQdSspYY5mj87VBCNPlvw8u5llgHF6uulNMpvOAS 2eFWo+yHjJUYBePADkrTkztDgnXVQR+mh2/JfebQardTQdaD8DpT0abRODHNK5e2qRZ3 wW+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=A8r7ZNBm; dkim=pass header.i=@linaro.org header.s=google header.b=Rj7qM2Ch; spf=pass (google.com: domain of libc-alpha-return-106290-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106290-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n9si1050330ejk.158.2019.10.25.05.10.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Oct 2019 05:10:34 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-106290-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=A8r7ZNBm; dkim=pass header.i=@linaro.org header.s=google header.b=Rj7qM2Ch; spf=pass (google.com: domain of libc-alpha-return-106290-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-106290-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=mWwQlLjmU47HfhZydcxg4RLJJfQEASS U3vEYORH20RzdFMfAXTlR6KBjzwCoZpDMhOaZ3FRNaUY2TGMHvWBXobk4gbf/jZC JLE6w1G7NdQ4nR9HIE7qupS7HTCH/Egd8Frui+chDaR0mcmDxVgGHcbeYkptrGeu pbqBmtPAoPCc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=Cq+VIw9Pwa7aDh4m4m/L5Zc1CIs=; b=A8r7Z NBmN3SbeqP4zY2+GklvQzsDiBHYam5QIDs+zhkMtSAOlLrDdI6Atmn4zmrhP+Td/ IPZ5vXt1pxm5rrMadZrUN9PLgVLjADc0FdoW2CLeItCRQ/o4iLS4KV8ChLZ7WyJa mlivZLq5lC6VXHpiRTQPpPyc6wkg5FVvePLGnc= Received: (qmail 79036 invoked by alias); 25 Oct 2019 12:09:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78798 invoked by uid 89); 25 Oct 2019 12:09:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=west X-HELO: mail-qk1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jBJO9TSwKv5u/4AtwkaR+JUyj1cL8dZvLmxvWGyjDOM=; b=Rj7qM2ChuMvz/l33su2HDaZ3DWF0AhXkoRZiN4JqFbeleZZ/hDuiL/Q136vW7+hHjl nr7E3DAWeGTHQTDJLOd1+rmr636jehkJgReQPWkHs6yDZPYn9yk/me/yGCAISGKqSccI O6O8hqJfJJM61+z9a80DbPFJ2GDSgyMsO4zpdW4YmXmXTYYj+otlfYfHz1OBoa8Qbxes uQIbbRAJWxCV/FOTAIJ7d1WU+wM7SoKhManD2bte9DliXGnNlAcfVah+lZuipsJRRWxi RLZ2sz2BPbKGFUrTAmbzPsggtNjh3lltcm4Wvqhvi/16s2cVJpq9XCc7lFSc0TORPY0t pF4A== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Lukasz Majewski , Zack Weinberg Subject: [PATCH v2 10/11] Make second argument of gettimeofday as 'void *' Date: Fri, 25 Oct 2019 09:08:31 -0300 Message-Id: <20191025120832.27667-11-adhemerval.zanella@linaro.org> In-Reply-To: <20191025120832.27667-1-adhemerval.zanella@linaro.org> References: <20191025120832.27667-1-adhemerval.zanella@linaro.org> From: Zack Weinberg Changes from previous version: - Remove warning for use of gettimeofday with a non-null __tz argument, the conditionals of making this work without false-positive seems quite specific and fragile (gcc-only, optimized build, workaround for gcc bug). -- Also make the public prototype of gettimeofday declare its second argument with type "void *" unconditionally, consistent with POSIX. It is also consistent with POSIX. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Co-authored-by: Adhemerval Zanella --- include/sys/time.h | 2 +- .../unix/sysv/linux/aarch64/gettimeofday.c | 4 ++-- .../unix/sysv/linux/powerpc/gettimeofday.c | 4 ++-- sysdeps/unix/sysv/linux/x86/gettimeofday.c | 4 ++-- time/gettimeofday.c | 4 ++-- time/sys/time.h | 23 ++++++++++--------- 6 files changed, 21 insertions(+), 20 deletions(-) -- 2.17.1 Reviewed-by: Lukasz Majewski diff --git a/include/sys/time.h b/include/sys/time.h index 2bf4297e76..a461295c6a 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -21,7 +21,7 @@ # ifndef _ISOMAC extern int __gettimeofday (struct timeval *__tv, - struct timezone *__tz); + void *__tz); extern int __settimezone (const struct timezone *__tz) attribute_hidden; extern int __adjtime (const struct timeval *__delta, diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c index 075af3d0d3..7e772e05ce 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -31,7 +31,7 @@ /* Used as a fallback in the ifunc resolver if VDSO is not available and for libc.so internal __gettimeofday calls. */ static int -__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) +__gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz) { if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof *tz); @@ -50,7 +50,7 @@ libc_ifunc (__gettimeofday, #else int -__gettimeofday (struct timeval *tv, struct timezone *tz) +__gettimeofday (struct timeval *restrict tv, void *restrict tz) { return __gettimeofday_vsyscall (tv, tz); } diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 02486dee3a..18d8f7cb7a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -24,7 +24,7 @@ #include static int -__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) +__gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) { if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof *tz); @@ -46,7 +46,7 @@ libc_ifunc (__gettimeofday, : (void *) __gettimeofday_syscall); #else int -__gettimeofday (struct timeval *tv, struct timezone *tz) +__gettimeofday (struct timeval *restrict tv, void *restrict tz) { return __gettimeofday_syscall (tv, tz); } diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c index cb20e358d8..190127d31e 100644 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c @@ -25,7 +25,7 @@ #include static int -__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) +__gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) { if (__glibc_unlikely (tz != 0)) memset (tz, 0, sizeof *tz); @@ -45,7 +45,7 @@ libc_ifunc (__gettimeofday, #else int -__gettimeofday (struct timeval *tv, struct timezone *tz) +__gettimeofday (struct timeval *restrict tv, void *restrict tz) { return __gettimeofday_syscall (tv, tz); } diff --git a/time/gettimeofday.c b/time/gettimeofday.c index e8055b397d..ddaf46f481 100644 --- a/time/gettimeofday.c +++ b/time/gettimeofday.c @@ -23,10 +23,10 @@ If *TZ is not NULL, clear it. Returns 0 on success, -1 on errors. */ int -___gettimeofday (struct timeval *tv, struct timezone *tz) +___gettimeofday (struct timeval *restrict tv, void *restrict tz) { if (__glibc_unlikely (tz != 0)) - memset (tz, 0, sizeof *tz); + memset (tz, 0, sizeof (struct timezone)); struct timespec ts; if (__clock_gettime (CLOCK_REALTIME, &ts)) diff --git a/time/sys/time.h b/time/sys/time.h index f8c946f94e..0473dae339 100644 --- a/time/sys/time.h +++ b/time/sys/time.h @@ -54,23 +54,24 @@ struct timezone int tz_minuteswest; /* Minutes west of GMT. */ int tz_dsttime; /* Nonzero if DST is ever in effect. */ }; - -typedef struct timezone *__restrict __timezone_ptr_t; -#else -typedef void *__restrict __timezone_ptr_t; #endif -/* Get the current time of day and timezone information, - putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. - Returns 0 on success, -1 on errors. - NOTE: This form of timezone information is obsolete. - Use the functions and variables declared in instead. */ +/* Get the current time of day, putting it into *TV. + If TZ is not null, *TZ must be a struct timezone, and both fields + will be set to zero. + Calling this function with a non-null TZ is obsolete; + use localtime etc. instead. + This function itself is semi-obsolete; + most callers should use time or clock_gettime instead. */ extern int gettimeofday (struct timeval *__restrict __tv, - __timezone_ptr_t __tz) __THROW __nonnull ((1)); + void *__restrict __tz) __THROW __nonnull ((1)); #ifdef __USE_MISC /* Set the current time of day and timezone information. - This call is restricted to the super-user. */ + This call is restricted to the super-user. + Setting the timezone in this way is obsolete, but we don't yet + warn about it because it still has some uses for which there is + no alternative. */ extern int settimeofday (const struct timeval *__tv, const struct timezone *__tz) __THROW;