On Wednesday 15 April 2015 19:56:38 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().
Signed-off-by: Baolin Wang baolin.wang@linaro.org
include/linux/time64.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/include/linux/time64.h b/include/linux/time64.h index a383147..a6e2aa8 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
I suspect this might be broken on 64-bit machines, because this trick:
@@ -43,6 +48,16 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) return ts; } +static inline struct itimerspec itimerspec64_to_itimerspec(const struct itimerspec64 its64) +{
- return its64;
+}
+static inline struct itimerspec64 itimerspec_to_itimerspec64(const struct itimerspec its) +{
- return its;
+}
Does not work. Try compiling this for arm64 or x86-64, you probably need a similar trick as for timespec64.
# define timespec64_equal timespec_equal # define timespec64_compare timespec_compare # define set_normalized_timespec64 set_normalized_timespec @@ -75,6 +90,28 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) return ret; } +static inline struct itimerspec itimerspec64_to_itimerspec(const struct itimerspec64 its64) +{
- struct itimerspec ret;
- ret.it_interval.tv_sec = (time_t)its64.it_interval.tv_sec;
- ret.it_interval.tv_nsec = its64.it_interval.tv_nsec;
- ret.it_value.tv_sec = (time_t)its64.it_value.tv_sec;
- ret.it_value.tv_nsec = its64.it_value.tv_nsec;
- return ret;
+}
+static inline struct itimerspec64 itimerspec_to_itimerspec64(const struct itimerspec its) +{
- struct itimerspec64 ret;
- ret.it_interval.tv_sec = its.it_interval.tv_sec;
- ret.it_interval.tv_nsec = its.it_interval.tv_nsec;
- ret.it_value.tv_sec = its.it_value.tv_sec;
- ret.it_value.tv_nsec = its.it_value.tv_nsec;
- return ret;
+}
This looks good.
Arnd