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 | |
parent | bd373b2b818e69f877c8eb5b39c126ce063b5abb (diff) | |
download | libflangrt-c3f0235696b59d22cf4c90ed18406d7b636af2f0.tar.gz |
added support for ETIME intrinsic
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | include/System/System.h | 18 | ||||
-rw-r--r-- | lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/System/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/System/System.cpp | 21 |
5 files changed, 43 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 468ced3..3f59e89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ add_library(libflang ${libkind} lib/Libflang.cpp lib/Numerical/Complex.cpp lib/Strings/Character.cpp lib/IO/Write.cpp + lib/System/System.cpp ) set(BUG_REPORT_URL "http://llvm.org/bugs/" CACHE STRING diff --git a/include/System/System.h b/include/System/System.h new file mode 100644 index 0000000..aa3da84 --- /dev/null +++ b/include/System/System.h @@ -0,0 +1,18 @@ +//===--- System.h - The system library -------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIBFLANG_CORE_H +#define LLVM_LIBFLANG_CORE_H + +#include "Libflang.h" + +LIBFLANG_ABI void libflang_sys_init(); +LIBFLANG_ABI float libflang_etime(float *time0, float *time1); + +#endif 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; +} |