diff options
author | arphaman <arphaman@gmail.com> | 2013-08-24 16:36:25 +0100 |
---|---|---|
committer | arphaman <arphaman@gmail.com> | 2013-08-24 16:36:25 +0100 |
commit | c3f0235696b59d22cf4c90ed18406d7b636af2f0 (patch) | |
tree | b7fa6e0d32f7df1c98f7ae79715730ca686cdbc1 /lib | |
parent | bd373b2b818e69f877c8eb5b39c126ce063b5abb (diff) | |
download | libflangrt-c3f0235696b59d22cf4c90ed18406d7b636af2f0.tar.gz |
added support for ETIME intrinsic
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; +} |