Skip to contentSkip to conversation

posix-timers:Convert to the 64bit methods for the timer_settime syscall function

PATCH In review Baolin Wang 2 participants 2 messages May 12, 2015 Posix clocks and timers

lore
Share & tools
lore
#0 lore raw

PATCH v3 8/23 posix-timers:Convert to the 64bit methods for the timer_settime syscall function

This patch introduces the timer_set64 method with itimerspec64 type for k_clock structure, that makes it ready for the 2038 year.

Convert to the 64bit method with itimerspec64 type for the timer_settime syscall function, and change the timer_settime syscall implementation according to the CONFIG_64BIT macro.

Also add a default 64bit method for the timer_set64 pointer of k_clock structure, and it will be removed after all the drivers are converted to 64bit methods.

---
 include/linux/posix-timers.h |    3 +++
 kernel/time/posix-timers.c   |   46 +++++++++++++++++++++++++++++++++++++-----
 2 files changed, 44 insertions(+), 5 deletions(-)
include/linux/posix-timers.h +3 -0
index e84436b..16c3364 100644
@@ -109,6 +109,9 @@ struct k_clock {
 	int (*timer_set) (struct k_itimer * timr, int flags,
 			  struct itimerspec * new_setting,
 			  struct itimerspec * old_setting);
+	int (*timer_set64) (struct k_itimer *timr, int flags,
+			    struct itimerspec64 *new_setting,
+			    struct itimerspec64 *old_setting);
 	int (*timer_del) (struct k_itimer * timr);
 #define TIMER_RETRY 1
 	void (*timer_get) (struct k_itimer * timr,
kernel/time/posix-timers.c +41 -5

87 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 7 lines · On Tuesday 12 May 2015 22:10:14 Baolin Wang wrote:
kernel/time/posix-timers.c +6 -0
+static int default_timer_set64(struct k_itimer *timr, int flags,
+                              struct itimerspec64 *new_setting64,
+                              struct itimerspec64 *old_setting64)
+{
+       struct k_clock *kc = clockid_to_kclock(timr->it_clock);
+       struct itimerspec new_setting, old_setting;

kernel/time/posix-timers.c static void default_timer_get64(struct k_itimer *timr, · line 542

Quoted 10 lines
kernel/time/posix-timers.c +10 -0
+       int ret;
+
+       new_setting = itimerspec64_to_itimerspec(new_setting64);
+       old_setting = itimerspec64_to_itimerspec(old_setting64);
+       ret = kc->timer_set(timr, flags, &new_setting, &old_setting);
+       if (!ret && old_setting64)
+               *old_setting64 = itimerspec_to_itimerspec64(&old_setting);
+
+       return ret;
+}

You check old_setting64 for a NULL pointer in the second access, but not in the first one, which is a bug. Please also check whether the variable is used as input, output or both.

Arnd