]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
Use clock_gettime instead of gettimeofday
authorRay Strode <rstrode@redhat.com>
Thu, 25 Sep 2008 19:54:47 +0000 (15:54 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 29 Sep 2008 03:40:28 +0000 (23:40 -0400)
The latter gets all screwy during boot up.

configure.ac
src/libply/ply-utils.c

index cb41822ebe9454f415e8864a0578ec481bd8744b..f1f8a64bbb87de96fea3ee9b5378b463a4b24efa 100644 (file)
@@ -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)
index e55d8901af79c3572284d939c67e91c7985d4076..3ef8c718b06f5fc24e98f04a884230e3ef9f94a8 100644 (file)
@@ -39,6 +39,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/un.h>
+#include <time.h>
 #include <linux/fs.h>
 
 #include <dlfcn.h>
@@ -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;
 }