LLVM API Documentation

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TimeValue.cpp

Go to the documentation of this file.
00001 //===-- TimeValue.cpp - Implement OS TimeValue Concept ----------*- C++ -*-===//
00002 // 
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file was developed by Reid Spencer and is distributed under the 
00006 // University of Illinois Open Source License. See LICENSE.TXT for details.
00007 // 
00008 //===----------------------------------------------------------------------===//
00009 //
00010 //  This file implements the operating system TimeValue concept.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include <llvm/System/TimeValue.h>
00015 
00016 namespace llvm {
00017 using namespace sys;
00018 
00019 const TimeValue TimeValue::MinTime       = TimeValue ( INT64_MIN,0 );
00020 const TimeValue TimeValue::MaxTime       = TimeValue ( INT64_MAX,0 );
00021 const TimeValue TimeValue::ZeroTime      = TimeValue ( 0,0 );
00022 const TimeValue TimeValue::PosixZeroTime = TimeValue ( -946684800,0 );
00023 const TimeValue TimeValue::Win32ZeroTime = TimeValue ( -12591158400ULL,0 );
00024 
00025 void
00026 TimeValue::normalize( void ) {
00027   if ( nanos_ >= NANOSECONDS_PER_SECOND ) {
00028     do {
00029       seconds_++;
00030       nanos_ -= NANOSECONDS_PER_SECOND;
00031     } while ( nanos_ >= NANOSECONDS_PER_SECOND );
00032   } else if (nanos_ <= -NANOSECONDS_PER_SECOND ) {
00033     do {
00034       seconds_--;
00035       nanos_ += NANOSECONDS_PER_SECOND;
00036     } while (nanos_ <= -NANOSECONDS_PER_SECOND);
00037   }
00038 
00039   if (seconds_ >= 1 && nanos_ < 0) {
00040     seconds_--;
00041     nanos_ += NANOSECONDS_PER_SECOND;
00042   } else if (seconds_ < 0 && nanos_ > 0) {
00043     seconds_++;
00044     nanos_ -= NANOSECONDS_PER_SECOND;
00045   }
00046 }
00047 
00048 }
00049 
00050 /// Include the platform specific portion of TimeValue class
00051 #include "platform/TimeValue.cpp"
00052 
00053 // vim: sw=2 smartindent smarttab tw=80 autoindent expandtab