TimeValue.h revision 621a802cc8a6d9e4f2ed26cc67e25adf0b23c185
1//===-- TimeValue.h ---------------------------------------------*- 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#ifndef liblldb_TimeValue_h_ 11#define liblldb_TimeValue_h_ 12 13// C Includes 14#include <stdint.h> 15#include <sys/time.h> 16 17// BEGIN: MinGW work around 18#if !defined(_STRUCT_TIMESPEC) && !defined(HAVE_STRUCT_TIMESPEC) 19#include <pthread.h> 20#endif 21// END: MinGW work around 22 23// C++ Includes 24// Other libraries and framework includes 25// Project includes 26#include "lldb/lldb-private.h" 27 28namespace lldb_private { 29 30class TimeValue 31{ 32public: 33 static const uint64_t MicroSecPerSec = 1000000UL; 34 static const uint64_t NanoSecPerSec = 1000000000UL; 35 static const uint64_t NanoSecPerMicroSec = 1000U; 36 37 //------------------------------------------------------------------ 38 // Constructors and Destructors 39 //------------------------------------------------------------------ 40 TimeValue(); 41 TimeValue(const TimeValue& rhs); 42 TimeValue(const struct timespec& ts); 43 TimeValue(const struct timeval& tv); 44 ~TimeValue(); 45 46 //------------------------------------------------------------------ 47 // Operators 48 //------------------------------------------------------------------ 49 const TimeValue& 50 operator=(const TimeValue& rhs); 51 52 void 53 Clear (); 54 55 uint64_t 56 GetAsNanoSecondsSinceJan1_1970() const; 57 58 uint64_t 59 GetAsMicroSecondsSinceJan1_1970() const; 60 61 uint64_t 62 GetAsSecondsSinceJan1_1970() const; 63 64 struct timespec 65 GetAsTimeSpec () const; 66 67 struct timeval 68 GetAsTimeVal () const; 69 70 bool 71 IsValid () const; 72 73 void 74 OffsetWithSeconds (uint64_t sec); 75 76 void 77 OffsetWithMicroSeconds (uint64_t usec); 78 79 void 80 OffsetWithNanoSeconds (uint64_t nsec); 81 82 static TimeValue 83 Now(); 84 85 void 86 Dump (Stream *s, uint32_t width = 0) const; 87 88protected: 89 //------------------------------------------------------------------ 90 // Classes that inherit from TimeValue can see and modify these 91 //------------------------------------------------------------------ 92 uint64_t m_nano_seconds; 93}; 94 95bool operator == (const TimeValue &lhs, const TimeValue &rhs); 96bool operator != (const TimeValue &lhs, const TimeValue &rhs); 97bool operator < (const TimeValue &lhs, const TimeValue &rhs); 98bool operator <= (const TimeValue &lhs, const TimeValue &rhs); 99bool operator > (const TimeValue &lhs, const TimeValue &rhs); 100bool operator >= (const TimeValue &lhs, const TimeValue &rhs); 101 102uint64_t operator -(const TimeValue &lhs, const TimeValue &rhs); 103 104} // namespace lldb_private 105 106 107#endif // liblldb_TimeValue_h_ 108