Allow clock_gettime() monotonic clock to be utilized on more OS's

Allow the clock_gettime() code using monotonic clock to be utilized on
more POSIX compliannt OS's. This started as a fix for OpenBSD which was
listed in one function as part of the previous hard coded list of OS's
for the functions to support but not in the other.

Signed-off-by: Brad Smith <brad@comstyle.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20130405003748.GH884@rox.home.comstyle.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Brad Smith 2013-04-04 20:37:53 -04:00 committed by Anthony Liguori
parent c5a98cf333
commit d05ef16045
2 changed files with 2 additions and 5 deletions

View File

@ -117,8 +117,7 @@ extern int use_rt_clock;
static inline int64_t get_clock(void) static inline int64_t get_clock(void)
{ {
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ #ifdef CLOCK_MONOTONIC
|| defined(__DragonFly__) || defined(__FreeBSD_kernel__)
if (use_rt_clock) { if (use_rt_clock) {
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);

View File

@ -49,9 +49,7 @@ int use_rt_clock;
static void __attribute__((constructor)) init_get_clock(void) static void __attribute__((constructor)) init_get_clock(void)
{ {
use_rt_clock = 0; use_rt_clock = 0;
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ #ifdef CLOCK_MONOTONIC
|| defined(__DragonFly__) || defined(__FreeBSD_kernel__) \
|| defined(__OpenBSD__)
{ {
struct timespec ts; struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {