From c3f0235696b59d22cf4c90ed18406d7b636af2f0 Mon Sep 17 00:00:00 2001 From: arphaman Date: Sat, 24 Aug 2013 16:36:25 +0100 Subject: added support for ETIME intrinsic --- CMakeLists.txt | 1 + include/System/System.h | 18 ++++++++++++++++++ lib/CMakeLists.txt | 1 + lib/System/CMakeLists.txt | 2 ++ lib/System/System.cpp | 21 +++++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 include/System/System.h create mode 100644 lib/System/CMakeLists.txt create mode 100644 lib/System/System.cpp 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 +#include +#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; +} -- cgit v1.2.1