dm: add absolute timer mode

Allow specifying the initial expiration in absolute time.

Tracked-On: #2319
Signed-off-by: Peter Fang <peter.fang@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Peter Fang 2019-01-10 18:58:38 -08:00 committed by wenlingz
parent d1e1aa3077
commit 0f7535fdbe
2 changed files with 16 additions and 2 deletions

View File

@ -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)
{

View File

@ -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);