diff --git a/devicemodel/core/timer.c b/devicemodel/core/timer.c index 32edd1ca8..bb9c5fb9b 100644 --- a/devicemodel/core/timer.c +++ b/devicemodel/core/timer.c @@ -102,7 +102,7 @@ acrn_timer_deinit(struct acrn_timer *timer) } int32_t -acrn_timer_settime(struct acrn_timer *timer, struct itimerspec *new_value) +acrn_timer_settime(struct acrn_timer *timer, const struct itimerspec *new_value) { if (timer == NULL) { return -1; @@ -111,6 +111,17 @@ acrn_timer_settime(struct acrn_timer *timer, struct itimerspec *new_value) return timerfd_settime(timer->fd, 0, new_value, NULL); } +int32_t +acrn_timer_settime_abs(struct acrn_timer *timer, + const struct itimerspec *new_value) +{ + if (timer == NULL) { + return -1; + } + + return timerfd_settime(timer->fd, TFD_TIMER_ABSTIME, new_value, NULL); +} + int32_t acrn_timer_gettime(struct acrn_timer *timer, struct itimerspec *cur_value) { diff --git a/devicemodel/include/timer.h b/devicemodel/include/timer.h index ab6a07d02..937976b3d 100644 --- a/devicemodel/include/timer.h +++ b/devicemodel/include/timer.h @@ -19,7 +19,10 @@ acrn_timer_init(struct acrn_timer *timer, void (*cb)(void *), void *param); void acrn_timer_deinit(struct acrn_timer *timer); int32_t -acrn_timer_settime(struct acrn_timer *timer, struct itimerspec *new_value); +acrn_timer_settime(struct acrn_timer *timer, const struct itimerspec *new_value); +int32_t +acrn_timer_settime_abs(struct acrn_timer *timer, + const struct itimerspec *new_value); int32_t acrn_timer_gettime(struct acrn_timer *timer, struct itimerspec *cur_value);