Replaces clock_gettime() with ast_tsnow()

clock_gettime() is, unfortunately, not portable. But I did like that
over our usual `ts.tv_nsec = tv.tv_usec * 1000` copy/paste code we
usually do when we want a timespec and all we have is ast_tvnow().

This patch adds ast_tsnow(), which mimics ast_tvnow(), but returns a
timespec. If clock_gettime() is available, it will use that. Otherwise
ast_tsnow() falls back to using ast_tvnow().

Change-Id: Ibb1ee67ccf4826b9b76d5a5eb62e90b29b6c456e
This commit is contained in:
David M. Lee
2015-07-24 17:04:35 -05:00
parent 309dd2a409
commit 40caf0ad9b
9 changed files with 179 additions and 13 deletions

View File

@@ -245,7 +245,7 @@ static enum ast_test_result_state query_set_test(struct ast_test *test, int reso
}
}
clock_gettime(CLOCK_REALTIME, &timeout);
timeout = ast_tsnow();
timeout.tv_sec += 10;
ast_mutex_lock(&qsdata->lock);