Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

timers: Export CLOCK_BOOTTIME via the posix timers interface

This patch exports CLOCK_BOOTTIME through the posix timers interface

CC: Jamie Lokier <jamie@shareable.org>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Alexander Shishkin <virtuoso@slind.org>
CC: Arve Hjønnevåg <arve@android.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>

+20 -1
+20 -1
kernel/posix-timers.c
··· 187 187 } 188 188 189 189 /* 190 - * Get monotonic time for posix timers 190 + * Get monotonic-raw time for posix timers 191 191 */ 192 192 static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec *tp) 193 193 { ··· 214 214 *tp = ktime_to_timespec(KTIME_LOW_RES); 215 215 return 0; 216 216 } 217 + 218 + static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp) 219 + { 220 + get_monotonic_boottime(tp); 221 + return 0; 222 + } 223 + 224 + 217 225 /* 218 226 * Initialize everything, well, just everything in Posix clocks/timers ;) 219 227 */ ··· 261 253 .clock_getres = posix_get_coarse_res, 262 254 .clock_get = posix_get_monotonic_coarse, 263 255 }; 256 + struct k_clock clock_boottime = { 257 + .clock_getres = hrtimer_get_res, 258 + .clock_get = posix_get_boottime, 259 + .nsleep = common_nsleep, 260 + .nsleep_restart = hrtimer_nanosleep_restart, 261 + .timer_create = common_timer_create, 262 + .timer_set = common_timer_set, 263 + .timer_get = common_timer_get, 264 + .timer_del = common_timer_del, 265 + }; 264 266 265 267 posix_timers_register_clock(CLOCK_REALTIME, &clock_realtime); 266 268 posix_timers_register_clock(CLOCK_MONOTONIC, &clock_monotonic); 267 269 posix_timers_register_clock(CLOCK_MONOTONIC_RAW, &clock_monotonic_raw); 268 270 posix_timers_register_clock(CLOCK_REALTIME_COARSE, &clock_realtime_coarse); 269 271 posix_timers_register_clock(CLOCK_MONOTONIC_COARSE, &clock_monotonic_coarse); 272 + posix_timers_register_clock(CLOCK_BOOTTIME, &clock_boottime); 270 273 271 274 posix_timers_cache = kmem_cache_create("posix_timers_cache", 272 275 sizeof (struct k_itimer), 0, SLAB_PANIC,