Skip to content

Commit 7fdd7f8

Browse files
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>
1 parent 70a08cc commit 7fdd7f8

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

‎kernel/posix-timers.c‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static int posix_ktime_get_ts(clockid_t which_clock, struct timespec *tp)
187187
}
188188

189189
/*
190-
* Get monotonic time for posix timers
190+
* Get monotonic-raw time for posix timers
191191
*/
192192
static int posix_get_monotonic_raw(clockid_t which_clock, struct timespec *tp)
193193
{
@@ -214,6 +214,14 @@ static int posix_get_coarse_res(const clockid_t which_clock, struct timespec *tp
214214
*tp = ktime_to_timespec(KTIME_LOW_RES);
215215
return 0;
216216
}
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+
217225
/*
218226
* Initialize everything, well, just everything in Posix clocks/timers ;)
219227
*/
@@ -253,12 +261,23 @@ static __init int init_posix_timers(void)
253261
.clock_getres = posix_get_coarse_res,
254262
.clock_get = posix_get_monotonic_coarse,
255263
};
264+
struct k_clock clock_boottime = {
265+
.clock_getres = hrtimer_get_res,
266+
.clock_get = posix_get_boottime,
267+
.nsleep = common_nsleep,
268+
.nsleep_restart = hrtimer_nanosleep_restart,
269+
.timer_create = common_timer_create,
270+
.timer_set = common_timer_set,
271+
.timer_get = common_timer_get,
272+
.timer_del = common_timer_del,
273+
};
256274

257275
posix_timers_register_clock(CLOCK_REALTIME, &clock_realtime);
258276
posix_timers_register_clock(CLOCK_MONOTONIC, &clock_monotonic);
259277
posix_timers_register_clock(CLOCK_MONOTONIC_RAW, &clock_monotonic_raw);
260278
posix_timers_register_clock(CLOCK_REALTIME_COARSE, &clock_realtime_coarse);
261279
posix_timers_register_clock(CLOCK_MONOTONIC_COARSE, &clock_monotonic_coarse);
280+
posix_timers_register_clock(CLOCK_BOOTTIME, &clock_boottime);
262281

263282
posix_timers_cache = kmem_cache_create("posix_timers_cache",
264283
sizeof (struct k_itimer), 0, SLAB_PANIC,

0 commit comments

Comments
 (0)