From patchwork Thu Oct 19 11:14:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 116364 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp366160qgn; Thu, 19 Oct 2017 04:15:44 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TNNixiQMHc08gJj0DZLuekBO077pT2cEWTTcARajRDfmGss2piqLY4JlNoewqBtgNHN6Gd X-Received: by 10.159.195.11 with SMTP id bd11mr1264681plb.58.1508411744366; Thu, 19 Oct 2017 04:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508411744; cv=none; d=google.com; s=arc-20160816; b=HBMda8EQEiy1GexDc19W3nw/OigrZDbV2XEAYnS8/h6JWb5wxSymy23qUZEoevfVVM wvUkYOmdG5OTwvRT7BzBAUb2L4xjv8FaawK3tTrHLpxDVQtTkHtRpvO1/cLKO12SL3WD UJVD7H2WETUiMcpQKmJzhc92NEaTKKLwXZZHG1Rcde9HmVC7EVBPvtt1E7rtJ96F8lPx KvEEb0uhNUPqsIP3EzqHR++N1T+9Nbmd7qf3DqLhM2YBn/uj4O8MOQm7Rh6YjbQ4BZ9W Gz7D1vYDPvYWZA8tbfIJWP4Q+9hh/cdEq/FvIpf5XeTCHkTj6FKBN94hZC9ofTIZsWt+ 5G/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=7UlgRd3zPDwAxwTxFTXAe1vI+DoXYEtLVcq12ztxzgQ=; b=PuLEEun1M+dJ0I3sVmPQ6ctSq7V03lyJxCsmcg0VS5bD2J27nmY6jUZndRWiCRwUTd dQVq1Q4b2/4KZus+bpgoJG4c2SqJAa90lhpQnRvYgrtNblwVS/4vfFtxh5B8EIrKfT32 kupJCzOkq2xzMewK5GhavLDvisJPpX01RHMSzL6IpnGRm4nAIdnk2x6S0eFVzkELM1ru 2JOD2gxqWUrJi6e/pq84WftLDzFksUaafmlvHuZmYRdDT8BGKMbjd/WhcwXnTs/mUF6S UsTtlxOWEO8Tc7o+CD4RoNQMwstxZTdFLTOxm4CbPzLGWy22ZnOSLjEn7SW6v224XVXM 7q3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si9149400pfe.34.2017.10.19.04.15.44; Thu, 19 Oct 2017 04:15:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752847AbdJSLPm (ORCPT + 27 others); Thu, 19 Oct 2017 07:15:42 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:54641 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752667AbdJSLPQ (ORCPT ); Thu, 19 Oct 2017 07:15:16 -0400 Received: from wuerfel.lan ([46.223.139.202]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0MV56z-1diQrM1ezV-00YVbk; Thu, 19 Oct 2017 13:15:05 +0200 From: Arnd Bergmann To: Thomas Gleixner , y2038@lists.linaro.org Cc: Deepa Dinamani , John Stultz , Stephen Boyd , linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH 5/7] time: move time_t conversion helpers to time32.h Date: Thu, 19 Oct 2017 13:14:48 +0200 Message-Id: <20171019111450.3702205-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171019111450.3702205-1-arnd@arndb.de> References: <20171019111450.3702205-1-arnd@arndb.de> X-Provags-ID: V03:K0:kT1rwXjXXeXb5KgWjih/Tv41wDvemSaLa6fTOhKmzF4CR7+BegY mDJ4SPHNSVdCTtGa+cgfIuVLQXbqEoMsE5jkADBdwiOAhaz0QRRlgz0+/ulXmgJP3JfFm1s n9gtNlpOFAsNRar2QBFWXlGKLWH7VuDuIdKzxGvtcfm3zkp61FevZreT2vWp6I7aLI2E1Qv AlExqPBcyNAbttWdiWk2Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:+T3tjKJ/whE=:nK9eCGWZxPrStqKjm3BKV2 ku6xlzPPShwyn2Rd8Dlen5HWInFy6FZEc7uISxiFrZzmwozse+d7r/zcu/5ZglziAteJHgY5w g8IZBXM27A6wBB9ffU1bCSUOLFa/+d2OOH63euabx+oB5KDBrZEBgZNJSwzcInTCVp/aIKR1N qzxy1mmG0NddPpddFEjIsk0B6iFP8whnuAC2FDUnM8n+InxPCQ288l9vszBnYHpzcNEupOxh4 VylQBFPOKP4Ovog70ViHEusrhmfaoZEQnFtqQQcRGApN+IGG5+gjJzl2T9ZpxImLai/0F0OU4 i63M9apUak89itJ9Cty/O38X0aJUQYrDKfWWgYG9oq8w8YJsvePu3Fj0axKbbM+mCUpBFR8/q DaTC/MT1rDKbk0CTiUbpHeJHA1zAAJC4x3AvnXUCorx8N5Qix6V00rO0r/g7qDkAquv5S3rGv UXwGWJdzpw8hk15LekQLONW426coh22go2jAvPqER2cXrO6qbKeiHkd7S7i9Q6KtyKk9YvGel Z2KAlwo0Cq4AhVWEQuLaDJGy5Bn4rUGjlhrnmbdgSoTsAM9Aq3nwFa2XxrIS1DN3C7X6DlTg/ EGewSSLbq9Rx2278Y4Bh+ShDThvAYj49nNmbr0AlVHROp8dSVBWlBclzV9lXgP2nFHgyrMsKa zfvv6md7jiBTsydJ5WYeglNk6LXKMUSF8AGndV/k+sIIU56spEce/ApasdRRq+Vx7GuLtL5MO +sh3of+wALgVYBzv01Ev4lLorRinveX/Pyr8lQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 64-bit architectures, the timespec64 based helpers in linux/time.h are defined as macros pointing to their timespec based counterparts. This made sense when they were first introduced, but as we are migrating away from timespec in general, it's much less intuitive now. This changes the macros to work in the exact opposite way: we always provide the timespec64 based helpers and define the old interfaces as macros for them. Now we can move those macros into linux/time32.h, which already contains the respective helpers for 32-bit architectures. Signed-off-by: Arnd Bergmann --- include/linux/time32.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/time64.h | 50 +------------------------------------------------- kernel/time/time.c | 5 +++-- 3 files changed, 49 insertions(+), 51 deletions(-) -- 2.9.0 diff --git a/include/linux/time32.h b/include/linux/time32.h index 6a00a309d095..305f81dd5429 100644 --- a/include/linux/time32.h +++ b/include/linux/time32.h @@ -13,6 +13,49 @@ #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) +#if __BITS_PER_LONG == 64 + +/* timespec64 is defined as timespec here */ +static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) +{ + return ts64; +} + +static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) +{ + return ts; +} + +# define timespec_equal timespec64_equal +# define timespec_compare timespec64_compare +# define set_normalized_timespec set_normalized_timespec64 +# define timespec_add timespec64_add +# define timespec_sub timespec64_sub +# define timespec_valid timespec64_valid +# define timespec_valid_strict timespec64_valid_strict +# define timespec_to_ns timespec64_to_ns +# define ns_to_timespec ns_to_timespec64 +# define timespec_add_ns timespec64_add_ns + +#else +static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) +{ + struct timespec ret; + + ret.tv_sec = (time_t)ts64.tv_sec; + ret.tv_nsec = ts64.tv_nsec; + return ret; +} + +static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) +{ + struct timespec64 ret; + + ret.tv_sec = ts.tv_sec; + ret.tv_nsec = ts.tv_nsec; + return ret; +} + static inline int timespec_equal(const struct timespec *a, const struct timespec *b) { @@ -114,6 +157,8 @@ static __always_inline void timespec_add_ns(struct timespec *a, u64 ns) a->tv_nsec = ns; } +#endif + /** * time_to_tm - converts the calendar time to local broken-down time * diff --git a/include/linux/time64.h b/include/linux/time64.h index 402b595c76d2..ec1888cf5378 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -7,11 +7,8 @@ typedef __s64 time64_t; typedef __u64 timeu64_t; -/* - * This wants to go into uapi/linux/time.h once we agreed about the - * userspace interfaces. - */ #if __BITS_PER_LONG == 64 +/* this trick allows us to optimize out timespec64_to_timespec */ # define timespec64 timespec #define itimerspec64 itimerspec #else @@ -41,49 +38,6 @@ struct itimerspec64 { #define KTIME_MAX ((s64)~((u64)1 << 63)) #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) -#if __BITS_PER_LONG == 64 - -static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) -{ - return ts64; -} - -static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) -{ - return ts; -} - -# define timespec64_equal timespec_equal -# define timespec64_compare timespec_compare -# define set_normalized_timespec64 set_normalized_timespec -# define timespec64_add timespec_add -# define timespec64_sub timespec_sub -# define timespec64_valid timespec_valid -# define timespec64_valid_strict timespec_valid_strict -# define timespec64_to_ns timespec_to_ns -# define ns_to_timespec64 ns_to_timespec -# define timespec64_add_ns timespec_add_ns - -#else - -static inline struct timespec timespec64_to_timespec(const struct timespec64 ts64) -{ - struct timespec ret; - - ret.tv_sec = (time_t)ts64.tv_sec; - ret.tv_nsec = ts64.tv_nsec; - return ret; -} - -static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) -{ - struct timespec64 ret; - - ret.tv_sec = ts.tv_sec; - ret.tv_nsec = ts.tv_nsec; - return ret; -} - static inline int timespec64_equal(const struct timespec64 *a, const struct timespec64 *b) { @@ -185,8 +139,6 @@ static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns) a->tv_nsec = ns; } -#endif - /* * timespec64_add_safe assumes both values are positive and checks for * overflow. It will return TIME64_MAX in case of overflow. diff --git a/kernel/time/time.c b/kernel/time/time.c index 947fb614c78f..fe60ebd301cf 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -407,6 +407,7 @@ time64_t mktime64(const unsigned int year0, const unsigned int mon0, } EXPORT_SYMBOL(mktime64); +#if __BITS_PER_LONG == 32 /** * set_normalized_timespec - set timespec sec and nsec parts and normalize * @@ -467,6 +468,7 @@ struct timespec ns_to_timespec(const s64 nsec) return ts; } EXPORT_SYMBOL(ns_to_timespec); +#endif /** * ns_to_timeval - Convert nanoseconds to timeval @@ -486,7 +488,6 @@ struct timeval ns_to_timeval(const s64 nsec) } EXPORT_SYMBOL(ns_to_timeval); -#if BITS_PER_LONG == 32 /** * set_normalized_timespec - set timespec sec and nsec parts and normalize * @@ -547,7 +548,7 @@ struct timespec64 ns_to_timespec64(const s64 nsec) return ts; } EXPORT_SYMBOL(ns_to_timespec64); -#endif + /** * msecs_to_jiffies: - convert milliseconds to jiffies * @m: time in milliseconds