From patchwork Thu Sep 20 16:26:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Coelho X-Patchwork-Id: 10608101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C507D161F for ; Thu, 20 Sep 2018 16:26:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4EB52E00F for ; Thu, 20 Sep 2018 16:26:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A94042E0E0; Thu, 20 Sep 2018 16:26:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A3272DDB5 for ; Thu, 20 Sep 2018 16:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730856AbeITWKo (ORCPT ); Thu, 20 Sep 2018 18:10:44 -0400 Received: from paleale.coelho.fi ([176.9.41.70]:51184 "EHLO farmhouse.coelho.fi" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728547AbeITWKo (ORCPT ); Thu, 20 Sep 2018 18:10:44 -0400 Received: from 91-156-4-241.elisa-laajakaista.fi ([91.156.4.241] helo=redipa.ger.corp.intel.com) by farmhouse.coelho.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.91) (envelope-from ) id 1g31md-0004hy-2w; Thu, 20 Sep 2018 19:26:27 +0300 From: Luca Coelho To: backports@vger.kernel.org Cc: Luca Coelho Date: Thu, 20 Sep 2018 19:26:22 +0300 Message-Id: <20180920162622.30203-1-luca@coelho.fi> X-Mailer: git-send-email 2.18.0 Subject: [PATCH] backport: add ktime_get_raw_ts64() backport for < 3.19 Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Luca Coelho The getrawmonotonic64() function that is used by the ktime_get_raw_ts64() backport was only introduced in 3.19. To fix compilation with earlier kernels, do the convertion from getrawmonotonic() manually if the kernel is < 3.19. Additionally, add timespec_to_timespec64() that we need for this conversion (and which was only introduced in 4.15). Signed-off-by: Luca Coelho --- backport/backport-include/linux/timekeeping.h | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/backport/backport-include/linux/timekeeping.h b/backport/backport-include/linux/timekeeping.h index aebb00ca366b..56fca5759b8e 100644 --- a/backport/backport-include/linux/timekeeping.h +++ b/backport/backport-include/linux/timekeeping.h @@ -55,11 +55,40 @@ static inline void ktime_get_ts64(struct timespec64 *ts) } #endif +#if LINUX_VERSION_IS_LESS(3,19,0) +/* This was introduced in 4.15, but we only need it in the + * ktime_get_raw_ts64 backport() for < 3.19. + */ +#if __BITS_PER_LONG == 64 +static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) +{ + return *(const struct timespec64 *)&ts; +} + +#else +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; +} +#endif +#endif /* < 3.19 */ + #if LINUX_VERSION_IS_LESS(4,18,0) #define ktime_get_raw_ts64 LINUX_BACKPORT(ktime_get_raw_ts64) static inline void ktime_get_raw_ts64(struct timespec64 *ts) { +#if LINUX_VERSION_IS_LESS(3,19,0) + struct timespec64 ts64; + + getrawmonotonic(&ts64); + *ts = timespec_to_timespec64(ts64); +#else return getrawmonotonic64(ts); +#endif /* < 3.19 */ } #endif