blob: 15337244c563bb11780e356fdffe8ea751e28c02 [file] [log] [blame]
Reid Spencer9926c312004-09-24 23:25:19 +00001//===-- TimeValue.cpp - Implement OS TimeValue Concept ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the operating system TimeValue concept.
11//
12//===----------------------------------------------------------------------===//
13
14#include <llvm/System/TimeValue.h>
15
16namespace llvm {
17using namespace sys;
18
Reid Spencer44cbf362004-11-14 22:06:18 +000019const TimeValue TimeValue::MinTime = TimeValue ( INT64_MIN,0 );
20const TimeValue TimeValue::MaxTime = TimeValue ( INT64_MAX,0 );
21const TimeValue TimeValue::ZeroTime = TimeValue ( 0,0 );
22const TimeValue TimeValue::PosixZeroTime = TimeValue ( -946684800,0 );
23const TimeValue TimeValue::Win32ZeroTime = TimeValue ( -12591158400ULL,0 );
Reid Spencer9926c312004-09-24 23:25:19 +000024
25void
26TimeValue::normalize( void ) {
27 if ( nanos_ >= NANOSECONDS_PER_SECOND ) {
28 do {
29 seconds_++;
30 nanos_ -= NANOSECONDS_PER_SECOND;
31 } while ( nanos_ >= NANOSECONDS_PER_SECOND );
32 } else if (nanos_ <= -NANOSECONDS_PER_SECOND ) {
33 do {
34 seconds_--;
35 nanos_ += NANOSECONDS_PER_SECOND;
36 } while (nanos_ <= -NANOSECONDS_PER_SECOND);
37 }
38
39 if (seconds_ >= 1 && nanos_ < 0) {
40 seconds_--;
41 nanos_ += NANOSECONDS_PER_SECOND;
42 } else if (seconds_ < 0 && nanos_ > 0) {
43 seconds_++;
44 nanos_ -= NANOSECONDS_PER_SECOND;
45 }
46}
47
48}
49
50/// Include the platform specific portion of TimeValue class
51#include "platform/TimeValue.cpp"
52
53// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab