All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: backports@vger.kernel.org
Cc: Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH v2 02/11] backports: add mktime64()
Date: Fri, 13 Oct 2017 11:42:17 +0200	[thread overview]
Message-ID: <20171013094226.10021-2-johannes@sipsolutions.net> (raw)
In-Reply-To: <20171013094226.10021-1-johannes@sipsolutions.net>

From: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 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 */
-- 
2.14.2

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  reply	other threads:[~2017-10-13  9:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13  9:42 [PATCH v2 01/11] backports: move headers to be clearer Johannes Berg
2017-10-13  9:42 ` Johannes Berg [this message]
2017-10-13  9:42 ` [PATCH v2 03/11] copy-list: move mpls includes Johannes Berg
2017-10-13  9:42 ` [PATCH v2 04/11] backports: add hex_byte_pack Johannes Berg
2017-10-13  9:42 ` [PATCH v2 05/11] backports: add bin2hex() Johannes Berg
2017-10-13  9:42 ` [PATCH v2 06/11] backports: add signature verification code Johannes Berg
2017-10-13  9:42 ` [PATCH v2 07/11] backports: add netdev_upper_dev_link() extack argument Johannes Berg
2017-10-13  9:42 ` [PATCH v2 08/11] backports: make QTNFMAC_PEARL_PCIE depend on 3.13 Johannes Berg
2017-10-13  9:42 ` [PATCH v2 09/11] backports: RSI_SDIO depends " Johannes Berg
2017-10-13  9:42 ` [PATCH v2 10/11] backports-update-manager: use KPATH variable Johannes Berg
2017-10-13  9:42 ` [PATCH v2 11/11] backports: no longer support kernels < 3.10 Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171013094226.10021-2-johannes@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=backports@vger.kernel.org \
    --cc=johannes.berg@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.