From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752846AbdJSLPm (ORCPT ); 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 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 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(-) 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 -- 2.9.0