Backports Archive on lore.kernel.org
 help / Atom feed
* [PATCH] backport: add ktime_get_raw_ts64() backport for < 3.19
@ 2018-09-20 16:26 Luca Coelho
  2018-09-23 13:52 ` Hauke Mehrtens
  0 siblings, 1 reply; 4+ messages in thread
From: Luca Coelho @ 2018-09-20 16:26 UTC (permalink / raw)
  To: backports; +Cc: Luca Coelho

From: Luca Coelho <luciano.coelho@intel.com>

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 <luciano.coelho@intel.com>
---
 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
 
-- 
2.18.0

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] backport: add ktime_get_raw_ts64() backport for < 3.19
  2018-09-20 16:26 [PATCH] backport: add ktime_get_raw_ts64() backport for < 3.19 Luca Coelho
@ 2018-09-23 13:52 ` Hauke Mehrtens
  2018-09-24  8:44   ` Luca Coelho
  0 siblings, 1 reply; 4+ messages in thread
From: Hauke Mehrtens @ 2018-09-23 13:52 UTC (permalink / raw)
  To: Luca Coelho, backports; +Cc: Luca Coelho

[-- Attachment #1.1: Type: text/plain, Size: 1739 bytes --]

On 09/20/2018 06:26 PM, Luca Coelho wrote:
> From: Luca Coelho <luciano.coelho@intel.com>
> 
> 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 <luciano.coelho@intel.com>
> ---
>  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.

timespec_to_timespec64() was already added in 3.17, see
https://elixir.bootlin.com/linux/v3.17.8/ident/timespec_to_timespec64

> + */
> +#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 */
> +


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] backport: add ktime_get_raw_ts64() backport for < 3.19
  2018-09-23 13:52 ` Hauke Mehrtens
@ 2018-09-24  8:44   ` Luca Coelho
  2018-09-24  8:57     ` [PATCH v2] " Luca Coelho
  0 siblings, 1 reply; 4+ messages in thread
From: Luca Coelho @ 2018-09-24  8:44 UTC (permalink / raw)
  To: Hauke Mehrtens, backports

On Sun, 2018-09-23 at 15:52 +0200, Hauke Mehrtens wrote:
> On 09/20/2018 06:26 PM, Luca Coelho wrote:
> > From: Luca Coelho <luciano.coelho@intel.com>
> > 
> > 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 <luciano.coelho@intel.com>
> > ---
> >  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.
> 
> timespec_to_timespec64() was already added in 3.17, see
> https://elixir.bootlin.com/linux/v3.17.8/ident/timespec_to_timespec64

Oh, you're right.  I somehow got confused here.  I'm running some tests
and will resend a fixed version.

Thanks!

--
Luca.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] backport: add ktime_get_raw_ts64() backport for < 3.19
  2018-09-24  8:44   ` Luca Coelho
@ 2018-09-24  8:57     ` " Luca Coelho
  0 siblings, 0 replies; 4+ messages in thread
From: Luca Coelho @ 2018-09-24  8:57 UTC (permalink / raw)
  To: backports; +Cc: hauke, Luca Coelho

From: Luca Coelho <luciano.coelho@intel.com>

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 3.17).

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 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..718715316a1d 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,17,0)
+/* This was introduced in 4.15, but we only need it in the
+ * ktime_get_raw_ts64 backport() for < 3.17.
+ */
+#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.17 */
+
 #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
 
-- 
2.19.0

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-20 16:26 [PATCH] backport: add ktime_get_raw_ts64() backport for < 3.19 Luca Coelho
2018-09-23 13:52 ` Hauke Mehrtens
2018-09-24  8:44   ` Luca Coelho
2018-09-24  8:57     ` [PATCH v2] " Luca Coelho

Backports Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/backports/0 backports/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 backports backports/ https://lore.kernel.org/backports \
		backports@vger.kernel.org backports@archiver.kernel.org
	public-inbox-index backports


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.backports


AGPL code for this site: git clone https://public-inbox.org/ public-inbox