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 | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
diff --git a/include/linux/time64.h b/include/linux/time64.h index a383147..0193a63 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 @@ -43,6 +48,24 @@ static inline struct timespec64 timespec_to_timespec64(const struct timespec ts) return ts; }
+static inline struct itimerspec itimerspec64_to_itimerspec(const struct itimerspec64 its64) +{ + struct itimerspec ret; + + ret.it_interval = its64.it_interval; + ret.it_value = its64.it_value; + return ret; +} + +static inline struct itimerspec64 itimerspec_to_itimerspec64(const struct itimerspec its) +{ + struct itimerspec64 ret; + + ret.it_interval = its.it_interval; + ret.it_value = its.it_value; + return ret; +} + # define timespec64_equal timespec_equal # define timespec64_compare timespec_compare # define set_normalized_timespec64 set_normalized_timespec @@ -75,6 +98,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; +} + static inline int timespec64_equal(const struct timespec64 *a, const struct timespec64 *b) {