LLVM API Documentation
00001 //===-- TimeValue.cpp - Implement OS TimeValue Concept ----------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements the operating system TimeValue concept. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "llvm/Support/TimeValue.h" 00015 #include "llvm/Config/config.h" 00016 00017 namespace llvm { 00018 using namespace sys; 00019 00020 const TimeValue::SecondsType 00021 TimeValue::PosixZeroTimeSeconds = -946684800; 00022 const TimeValue::SecondsType 00023 TimeValue::Win32ZeroTimeSeconds = -12591158400ULL; 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 #ifdef LLVM_ON_UNIX 00052 #include "Unix/TimeValue.inc" 00053 #endif 00054 #ifdef LLVM_ON_WIN32 00055 #include "Windows/TimeValue.inc" 00056 #endif