diff options
Diffstat (limited to 'lib/System/System.cpp')
-rw-r--r-- | lib/System/System.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/System/System.cpp b/lib/System/System.cpp new file mode 100644 index 0000000..4964921 --- /dev/null +++ b/lib/System/System.cpp @@ -0,0 +1,21 @@ +#include <sys/time.h> +#include <stdint.h> +#include "System/System.h" + +// FIXME: windows support. + +static timeval programStart; + +LIBFLANG_ABI void libflang_sys_init() { + gettimeofday(&programStart, nullptr); +} + +LIBFLANG_ABI float libflang_etime(float *time0, float *time1) { + timeval stop; + gettimeofday(&stop, nullptr); + int64_t diff = stop.tv_usec - programStart.tv_usec; + + *time0 = float(double(diff) / 1000000.0); + *time1 = 0.0f; + return *time0 + *time1; +} |