]> git.proxmox.com Git - rustc.git/blame - src/llvm/lib/Support/TimeValue.cpp
Imported Upstream version 1.0.0+dfsg1
[rustc.git] / src / llvm / lib / Support / TimeValue.cpp
CommitLineData
223e47cc
LB
1//===-- TimeValue.cpp - Implement OS TimeValue Concept ----------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the operating system TimeValue concept.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/Support/TimeValue.h"
15#include "llvm/Config/config.h"
16
17namespace llvm {
18using namespace sys;
19
970d7e83
LB
20const TimeValue::SecondsType
21 TimeValue::PosixZeroTimeSeconds = -946684800;
22const TimeValue::SecondsType
23 TimeValue::Win32ZeroTimeSeconds = -12591158400ULL;
24
223e47cc
LB
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
1a4d82fc 50/// Include the platform-specific portion of TimeValue class
223e47cc
LB
51#ifdef LLVM_ON_UNIX
52#include "Unix/TimeValue.inc"
53#endif
54#ifdef LLVM_ON_WIN32
55#include "Windows/TimeValue.inc"
56#endif