]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
add new ply_get_timestamp() function
authorRay Strode <rstrode@redhat.com>
Mon, 21 May 2007 14:06:58 +0000 (10:06 -0400)
committerRay Strode <rstrode@redhat.com>
Mon, 21 May 2007 14:06:58 +0000 (10:06 -0400)
This commit adds a function, ply_get_timestamp(), that returns
the current time in seconds since the epoch as a double.

src/ply-utils.c
src/ply-utils.h

index 0e55dfb1af8b3f8298142e54b6983109661b2a55..b395504b3dd21fc363b760e9676e40c39d31b1da 100644 (file)
@@ -228,4 +228,18 @@ ply_close_all_fds (void)
     close (fd);
 }
 
+double 
+ply_get_timestamp (void)
+{
+  const double microseconds_per_second = 1000000.0;
+  double timestamp;
+  struct timeval now = { 0L, /* zero-filled */ };
+
+  gettimeofday (&now, NULL);
+  timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) /
+               microseconds_per_second;
+
+  return timestamp;
+}
+
 /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
index 1fa8d44b4e77f906cdfd5a90f20e2750beb25acf..4da3f51b01791550724bb4d7b49211860dfc6925 100644 (file)
@@ -49,6 +49,7 @@ bool ply_fd_can_take_data (int fd);
 char **ply_copy_string_array (const char * const *array);
 void ply_free_string_array (char **array);
 void ply_close_all_fds (void);
+double ply_get_timestamp (void);
 #endif
 
 #endif /* PLY_UTILS_H */