On Friday 17 April 2015 14:47:08 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 | 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 */
+};
Ok, you chose to have a definition for itimerspec64 that is the same for 32-bit and 64-bit machines. I think that's ok, but then you don't need to duplicate the other functions for the two cases:
/* 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 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;
+}
Both of these can be expressed using
ret.it_interval = timespec64_to_timespec(its64.it_interval); ret.it_value = timespec64_to_timespec(its64.it_value);
outside of the #ifdef.
The alternative would be to do as I suggested and use "#define itimerspec64_to_itimerspec(its) (its)" in your first version, but add a matching #define for the type, like we have for time_t.
Arnd