diff mbox

[01/11] linux/time64.h:Introduce the 'struct itimerspec64' for 64bit

Message ID 1429509459-17068-2-git-send-email-baolin.wang@linaro.org
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Baolin Wang April 20, 2015, 5:57 a.m. UTC
This patch introduces the 'struct itimerspec64' for 64bit to replace itimerspec,
and also introduces the conversion methods: itimerspec64_to_itimerspec() and
itimerspec_to_itimerspec64(), that makes itimerspec to ready for 2038 year.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 include/linux/time64.h |   13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Sergei Shtylyov April 20, 2015, 9:49 a.m. UTC | #1
Hello.

On 4/20/2015 8:57 AM, Baolin Wang wrote:

> This patch introduces the 'struct itimerspec64' for 64bit to replace itimerspec,
> and also introduces the conversion methods: itimerspec64_to_itimerspec() and
> itimerspec_to_itimerspec64(), that makes itimerspec to ready for 2038 year.

    "To" not needed here.

> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>

[...]

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thomas Gleixner April 20, 2015, 7:14 p.m. UTC | #2
On Mon, 20 Apr 2015, Baolin Wang wrote:
> This patch introduces the 'struct itimerspec64' for 64bit to replace itimerspec,
> and also introduces the conversion methods: itimerspec64_to_itimerspec() and
> itimerspec_to_itimerspec64(), that makes itimerspec to ready for 2038 year.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> ---
>  include/linux/time64.h |   13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/linux/time64.h b/include/linux/time64.h
> index a383147..3647bdd 100644
> --- a/include/linux/time64.h
> +++ b/include/linux/time64.h
> @@ -18,6 +18,11 @@ struct timespec64 {
>  };
>  #endif
>  
> +struct itimerspec64 {
> +	struct timespec64 it_interval;  /* timer period */
> +	struct timespec64 it_value;     /* timer expiration */
> +};
> +
>  /* Parameters used to convert the timespec values: */
>  #define MSEC_PER_SEC	1000L
>  #define USEC_PER_MSEC	1000L
> @@ -187,4 +192,12 @@ static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns)
>  
>  #endif
>  
> +#define itimerspec64_to_itimerspec(its64) \

> +#define itimerspec_to_itimerspec64(its) \

1.) Make these static inlines please. These macros are not typesafe.

2.) Use pointers to the input value.

Thanks.

	tglx
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thomas Gleixner April 20, 2015, 7:59 p.m. UTC | #3
On Mon, 20 Apr 2015, Thomas Gleixner wrote:
> On Mon, 20 Apr 2015, Baolin Wang wrote:
> > This patch introduces the 'struct itimerspec64' for 64bit to replace itimerspec,
> > and also introduces the conversion methods: itimerspec64_to_itimerspec() and
> > itimerspec_to_itimerspec64(), that makes itimerspec to ready for 2038 year.
> > 
> > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
> > ---
> >  include/linux/time64.h |   13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/include/linux/time64.h b/include/linux/time64.h
> > index a383147..3647bdd 100644
> > --- a/include/linux/time64.h
> > +++ b/include/linux/time64.h
> > @@ -18,6 +18,11 @@ struct timespec64 {
> >  };
> >  #endif
> >  
> > +struct itimerspec64 {
> > +	struct timespec64 it_interval;  /* timer period */
> > +	struct timespec64 it_value;     /* timer expiration */
> > +};

Aside of the macro mess. This really wants to be conditional on 64/32
but in the same way as we have the different implementations for
timespec64.

Your patch enforces a useless conversion from and to itimerspec64 even
on 64 bit because the compiler cannot map the types.

Sigh. timespec64 is a proper guidance here.

Thanks,

	tglx
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/time64.h b/include/linux/time64.h
index a383147..3647bdd 100644
--- a/include/linux/time64.h
+++ b/include/linux/time64.h
@@ -18,6 +18,11 @@  struct timespec64 {
 };
 #endif
 
+struct itimerspec64 {
+	struct timespec64 it_interval;  /* timer period */
+	struct timespec64 it_value;     /* timer expiration */
+};
+
 /* Parameters used to convert the timespec values: */
 #define MSEC_PER_SEC	1000L
 #define USEC_PER_MSEC	1000L
@@ -187,4 +192,12 @@  static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns)
 
 #endif
 
+#define itimerspec64_to_itimerspec(its64) \
+	({ (struct itimerspec){ .it_interval = timespec64_to_timespec((its64).it_interval), \
+				.it_value = timespec64_to_timespec((its64).it_value) }; })
+
+#define itimerspec_to_itimerspec64(its) \
+	({ (struct itimerspec64){ .it_interval = timespec_to_timespec64((its).it_interval), \
+				  .it_value = timespec_to_timespec64((its).it_value) }; })
+
 #endif /* _LINUX_TIME64_H */