From patchwork Thu Oct 12 21:00:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 10002901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8850E6028A for ; Thu, 12 Oct 2017 21:00:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A98828ED9 for ; Thu, 12 Oct 2017 21:00:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7915228F10; Thu, 12 Oct 2017 21:00:34 +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=-6.9 required=2.0 tests=BAYES_00,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 BA0FC28ED9 for ; Thu, 12 Oct 2017 21:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751759AbdJLVAc (ORCPT ); Thu, 12 Oct 2017 17:00:32 -0400 Received: from s3.sipsolutions.net ([144.76.63.242]:42238 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751961AbdJLVAb (ORCPT ); Thu, 12 Oct 2017 17:00:31 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1e2kaj-0006Fb-O9; Thu, 12 Oct 2017 23:00:29 +0200 From: Johannes Berg To: backports@vger.kernel.org Cc: Johannes Berg Subject: [PATCH 2/5] backports: add mktime64() Date: Thu, 12 Oct 2017 23:00:22 +0200 Message-Id: <20171012210025.7490-2-johannes@sipsolutions.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171012210025.7490-1-johannes@sipsolutions.net> References: <20171012210025.7490-1-johannes@sipsolutions.net> Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg Signed-off-by: Johannes Berg --- backport/backport-include/linux/time64.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/backport/backport-include/linux/time64.h b/backport/backport-include/linux/time64.h index 609b8904e40d..49805da9dfce 100644 --- a/backport/backport-include/linux/time64.h +++ b/backport/backport-include/linux/time64.h @@ -21,4 +21,26 @@ #define timespec64 timespec #endif /* LINUX_VERSION_IS_LESS(3,17,0) */ +#if LINUX_VERSION_IS_LESS(3,19,0) +static inline time64_t mktime64(const unsigned int year0, const unsigned int mon0, + const unsigned int day, const unsigned int hour, + const unsigned int min, const unsigned int sec) +{ + unsigned int mon = mon0, year = year0; + + /* 1..12 -> 11,12,1..10 */ + if (0 >= (int) (mon -= 2)) { + mon += 12; /* Puts Feb last since it has leap day */ + year -= 1; + } + + return ((((time64_t) + (year/4 - year/100 + year/400 + 367*mon/12 + day) + + year*365 - 719499 + )*24 + hour /* now have hours - midnight tomorrow handled here */ + )*60 + min /* now have minutes */ + )*60 + sec; /* finally seconds */ +} +#endif + #endif /* __BACKPORT_LINUX_TIME64_H */