summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ply-utils.c14
-rw-r--r--src/ply-utils.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/src/ply-utils.c b/src/ply-utils.c
index 0e55dfb..b395504 100644
--- a/src/ply-utils.c
+++ b/src/ply-utils.c
@@ -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: */
diff --git a/src/ply-utils.h b/src/ply-utils.h
index 1fa8d44..4da3f51 100644
--- a/src/ply-utils.h
+++ b/src/ply-utils.h
@@ -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 */