diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-09-28 23:56:20 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-09-28 23:56:20 +0000 |
commit | 10366a4ad9a8954ffb5934a4c94266291231277f (patch) | |
tree | 30218d1b4cb0684e8d72fe596b486e99d8437bef /lib/System/Win32 | |
parent | d722bf5c28c4ca88ee78fe93ea106037a63014e7 (diff) | |
download | external_llvm-10366a4ad9a8954ffb5934a4c94266291231277f.zip external_llvm-10366a4ad9a8954ffb5934a4c94266291231277f.tar.gz external_llvm-10366a4ad9a8954ffb5934a4c94266291231277f.tar.bz2 |
Win32 implementation of TimeValue::now().
Patch contributed by Jeff Cohen. Thanks Jeff!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32')
-rw-r--r-- | lib/System/Win32/TimeValue.cpp | 18 | ||||
-rw-r--r-- | lib/System/Win32/TimeValue.inc | 18 |
2 files changed, 24 insertions, 12 deletions
diff --git a/lib/System/Win32/TimeValue.cpp b/lib/System/Win32/TimeValue.cpp index c9c3220..7ec2b39 100644 --- a/lib/System/Win32/TimeValue.cpp +++ b/lib/System/Win32/TimeValue.cpp @@ -2,7 +2,7 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Jeff Cohen and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// @@ -11,18 +11,24 @@ // //===----------------------------------------------------------------------===// -// Include the generic Unix implementation -#include "../Unix/Unix.h" +#include "Win32.h" namespace llvm { using namespace sys; //===----------------------------------------------------------------------===// -//=== WARNING: Implementation here must contain only Win32 specific code -//=== and must not be generic UNIX code (see ../Unix/TimeValue.cpp) +//=== WARNING: Implementation here must contain only Win32 specific code. //===----------------------------------------------------------------------===// -// FIXME: Need TimeValue::now() +TimeValue TimeValue::now() { + __int64 ft; + GetSystemTimeAsFileTime(reinterpret_cast<FILETIME *>(&ft)); + + return TimeValue( + static_cast<TimeValue::SecondsType>( ft / 10000000 + + Win32ZeroTime.seconds_ ), + static_cast<TimeValue::NanoSecondsType>( (ft % 10000000) * 100) ); +} // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab diff --git a/lib/System/Win32/TimeValue.inc b/lib/System/Win32/TimeValue.inc index c9c3220..7ec2b39 100644 --- a/lib/System/Win32/TimeValue.inc +++ b/lib/System/Win32/TimeValue.inc @@ -2,7 +2,7 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Jeff Cohen and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// @@ -11,18 +11,24 @@ // //===----------------------------------------------------------------------===// -// Include the generic Unix implementation -#include "../Unix/Unix.h" +#include "Win32.h" namespace llvm { using namespace sys; //===----------------------------------------------------------------------===// -//=== WARNING: Implementation here must contain only Win32 specific code -//=== and must not be generic UNIX code (see ../Unix/TimeValue.cpp) +//=== WARNING: Implementation here must contain only Win32 specific code. //===----------------------------------------------------------------------===// -// FIXME: Need TimeValue::now() +TimeValue TimeValue::now() { + __int64 ft; + GetSystemTimeAsFileTime(reinterpret_cast<FILETIME *>(&ft)); + + return TimeValue( + static_cast<TimeValue::SecondsType>( ft / 10000000 + + Win32ZeroTime.seconds_ ), + static_cast<TimeValue::NanoSecondsType>( (ft % 10000000) * 100) ); +} // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab |