diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/System/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/System/System.cpp | 21 |
3 files changed, 24 insertions, 0 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 34c0fd8..903454d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory(Core) add_subdirectory(Numerical) add_subdirectory(Strings) add_subdirectory(IO) +add_subdirectory(System) diff --git a/lib/System/CMakeLists.txt b/lib/System/CMakeLists.txt new file mode 100644 index 0000000..513a048 --- /dev/null +++ b/lib/System/CMakeLists.txt @@ -0,0 +1,2 @@ +add_libflang_library(libflangSystem + System.cpp) 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; +} |