From: Ray Strode Date: Thu, 25 Sep 2008 19:54:47 +0000 (-0400) Subject: Use clock_gettime instead of gettimeofday X-Git-Tag: 0.6.0~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39196333524bfc460a81ca1aa5ad78daf0772bd7;p=thirdparty%2Fplymouth.git Use clock_gettime instead of gettimeofday The latter gets all screwy during boot up. --- diff --git a/configure.ac b/configure.ac index cb41822e..f1f8a64b 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ AC_SUBST(IMAGE_CFLAGS) AC_SUBST(IMAGE_LIBS) PLYMOUTH_CFLAGS="$IMAGE_CFLAGS" -PLYMOUTH_LIBS="-lm -ldl $IMAGE_LIBS" +PLYMOUTH_LIBS="-lm -lrt -ldl $IMAGE_LIBS" AC_SUBST(PLYMOUTH_CFLAGS) AC_SUBST(PLYMOUTH_LIBS) diff --git a/src/libply/ply-utils.c b/src/libply/ply-utils.c index e55d8901..3ef8c718 100644 --- a/src/libply/ply-utils.c +++ b/src/libply/ply-utils.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -566,13 +567,13 @@ ply_close_all_fds (void) double ply_get_timestamp (void) { - const double microseconds_per_second = 1000000.0; + const double nanoseconds_per_second = 1000000000.0; double timestamp; - struct timeval now = { 0L, /* zero-filled */ }; + struct timespec now = { 0L, /* zero-filled */ }; - gettimeofday (&now, NULL); - timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) / - microseconds_per_second; + clock_gettime (CLOCK_MONOTONIC, &now); + timestamp = ((nanoseconds_per_second * now.tv_sec) + now.tv_nsec) / + nanoseconds_per_second; return timestamp; }