From 294b585994da4427ac98a8353ff41aed5f301d54 Mon Sep 17 00:00:00 2001 From: pk33 Date: Fri, 1 Nov 2024 23:51:15 +0100 Subject: Import and fix old code --- src/clock.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/clock.c (limited to 'src/clock.c') diff --git a/src/clock.c b/src/clock.c new file mode 100644 index 0000000..7cb5ec3 --- /dev/null +++ b/src/clock.c @@ -0,0 +1,19 @@ +#include "sys/time.h" + +#include "clock.h" + + +Size clock_get_us( void ) +{ + static struct timeval tv; + gettimeofday( &tv, 0 ); + return (tv.tv_sec * 1000000) + tv.tv_usec; +} + +f64 clock_get_s_hires( void ) +{ + static struct timeval tv; + gettimeofday( &tv, 0 ); + return (f64)((f64)tv.tv_sec + ((f64)tv.tv_usec / 1000000)); +} + -- cgit v1.2.3