Switch from USEC_PER_SEC/NSEC_PER_SEC/NSEC_PER_USEC to TimeValue constants

Fixes the Linux build.

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@133370 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Host/TimeValue.h b/include/lldb/Host/TimeValue.h
index 04b6015..d804111 100644
--- a/include/lldb/Host/TimeValue.h
+++ b/include/lldb/Host/TimeValue.h
@@ -29,7 +29,9 @@
 class TimeValue
 {
 public:
-    static const uint32_t NanoSecondPerSecond = 1000000000U;
+    static const uint32_t MicroSecPerSec = 1000000UL;
+    static const uint32_t NanoSecPerSec = 1000000000UL;
+    static const uint32_t NanoSecPerMicroSec = 1000U;
 
     //------------------------------------------------------------------
     // Constructors and Destructors
diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp
index 3f10d8b..81c1bce 100644
--- a/source/Core/Communication.cpp
+++ b/source/Core/Communication.cpp
@@ -340,7 +340,7 @@
     bool done = false;
     while (!done && comm->m_read_thread_enabled)
     {
-        size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * USEC_PER_SEC, status, &error);
+        size_t bytes_read = comm->ReadFromConnection (buf, sizeof(buf), 5 * TimeValue::MicroSecPerSec, status, &error);
         if (bytes_read > 0)
             comm->AppendBytesToCache (buf, bytes_read, true, status);
         else if ((bytes_read == 0)
diff --git a/source/Core/ConnectionFileDescriptor.cpp b/source/Core/ConnectionFileDescriptor.cpp
index 2de4dac..e367a9c 100644
--- a/source/Core/ConnectionFileDescriptor.cpp
+++ b/source/Core/ConnectionFileDescriptor.cpp
@@ -735,8 +735,8 @@
             return true;
 
         struct timeval timeout;
-        timeout.tv_sec = timeout_usec / USEC_PER_SEC;
-        timeout.tv_usec = timeout_usec % USEC_PER_SEC;
+        timeout.tv_sec = timeout_usec / TimeValue::MicroSecPerSec;
+        timeout.tv_usec = timeout_usec % TimeValue::MicroSecPerSec;
         if (::setsockopt (m_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) == 0)
         {
             m_socket_timeout_usec = timeout_usec;
diff --git a/source/Host/common/TimeValue.cpp b/source/Host/common/TimeValue.cpp
index 1ae6a51..416db41 100644
--- a/source/Host/common/TimeValue.cpp
+++ b/source/Host/common/TimeValue.cpp
@@ -15,10 +15,6 @@
 // Other libraries and framework includes
 // Project includes
 
-#define NSEC_PER_USEC   1000ull
-#define USEC_PER_SEC    1000000ull
-#define NSEC_PER_SEC    1000000000ull
-
 using namespace lldb_private;
 
 //----------------------------------------------------------------------
@@ -38,12 +34,12 @@
 }
 
 TimeValue::TimeValue(const struct timespec& ts) :
-    m_nano_seconds (ts.tv_sec * NSEC_PER_SEC + ts.tv_nsec)
+    m_nano_seconds (ts.tv_sec * NanoSecPerSec + ts.tv_nsec)
 {
 }
 
 TimeValue::TimeValue(const struct timeval& tv) :
-    m_nano_seconds (tv.tv_sec * NSEC_PER_SEC + tv.tv_usec * NSEC_PER_USEC)
+    m_nano_seconds (tv.tv_sec * NanoSecPerSec + tv.tv_usec * NanoSecPerMicroSec)
 {
 }
 
@@ -64,15 +60,15 @@
 uint64_t
 TimeValue::GetAsMicroSecondsSinceJan1_1970() const
 {
-    return m_nano_seconds / NSEC_PER_USEC;
+    return m_nano_seconds / NanoSecPerMicroSec;
 }
 
 struct timespec
 TimeValue::GetAsTimeSpec () const
 {
     struct timespec ts;
-    ts.tv_sec = m_nano_seconds / NSEC_PER_SEC;
-    ts.tv_nsec = m_nano_seconds % NSEC_PER_SEC;
+    ts.tv_sec = m_nano_seconds / NanoSecPerSec;
+    ts.tv_nsec = m_nano_seconds % NanoSecPerSec;
     return ts;
 }
 
@@ -80,8 +76,8 @@
 TimeValue::GetAsTimeVal () const
 {
     struct timeval tv;
-    tv.tv_sec = m_nano_seconds / NSEC_PER_SEC;
-    tv.tv_usec = (m_nano_seconds % NSEC_PER_SEC) / NSEC_PER_USEC;
+    tv.tv_sec = m_nano_seconds / NanoSecPerSec;
+    tv.tv_usec = (m_nano_seconds % NanoSecPerSec) / NanoSecPerMicroSec;
     return tv;
 }
 
@@ -100,13 +96,13 @@
 void
 TimeValue::OffsetWithSeconds (uint64_t sec)
 {
-    m_nano_seconds += sec * NSEC_PER_SEC;
+    m_nano_seconds += sec * NanoSecPerSec;
 }
 
 void
 TimeValue::OffsetWithMicroSeconds (uint64_t usec)
 {
-    m_nano_seconds += usec * NSEC_PER_USEC;
+    m_nano_seconds += usec * NanoSecPerMicroSec;
 }
 
 void
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index 39b4522..4ed69e8 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -53,9 +53,9 @@
                 uint64_t delta_t = now - time_value;
                 printf ("%u frames in %llu.%09llu ms (%g frames/sec)\n", 
                         FRAME_COUNT,
-                        delta_t / NSEC_PER_SEC, 
-                        delta_t % NSEC_PER_SEC,
-                        (float)FRAME_COUNT / ((float)delta_t / (float)NSEC_PER_SEC));
+                        delta_t / TimeValue::NanoSecPerSec, 
+                        delta_t % TimeValue::NanoSecPerSec,
+                        (float)FRAME_COUNT / ((float)delta_t / (float)TimeValue::NanoSecPerSec));
                 time_value = now;
             }
 #endif
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index addec5b..c50e52a 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -22,6 +22,7 @@
 #include "lldb/Core/Listener.h"
 #include "lldb/Host/Mutex.h"
 #include "lldb/Host/Predicate.h"
+#include "lldb/Host/TimeValue.h"
 
 #include "Utility/StringExtractorGDBRemote.h"
 
@@ -116,7 +117,7 @@
     uint32_t
     GetPacketTimeoutInMicroSeconds () const
     {
-        return m_packet_timeout * USEC_PER_SEC;
+        return m_packet_timeout * lldb_private::TimeValue::MicroSecPerSec;
     }
     //------------------------------------------------------------------
     // Start a debugserver instance on the current host using the
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index b648ac1..afe376a 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1430,13 +1430,13 @@
                 }
                 end_time = TimeValue::Now();
                 total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970();
-                packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecondPerSecond;
+                packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec;
                 printf ("%u qSpeedTest(send=%-5u, recv=%-5u) in %llu.%09.9llu sec for %f packets/sec.\n", 
                         num_packets, 
                         send_size,
                         recv_size,
-                        total_time_nsec / TimeValue::NanoSecondPerSecond,
-                        total_time_nsec % TimeValue::NanoSecondPerSecond, 
+                        total_time_nsec / TimeValue::NanoSecPerSec,
+                        total_time_nsec % TimeValue::NanoSecPerSec, 
                         packets_per_second);
                 if (recv_size == 0)
                     recv_size = 32;
@@ -1454,11 +1454,11 @@
         }
         end_time = TimeValue::Now();
         total_time_nsec = end_time.GetAsNanoSecondsSinceJan1_1970() - start_time.GetAsNanoSecondsSinceJan1_1970();
-        packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecondPerSecond;
+        packets_per_second = (((float)num_packets)/(float)total_time_nsec) * (float)TimeValue::NanoSecPerSec;
         printf ("%u 'qC' packets packets in 0x%llu%09.9llu sec for %f packets/sec.\n", 
                 num_packets, 
-                total_time_nsec / TimeValue::NanoSecondPerSecond, 
-                total_time_nsec % TimeValue::NanoSecondPerSecond, 
+                total_time_nsec / TimeValue::NanoSecPerSec, 
+                total_time_nsec % TimeValue::NanoSecPerSec, 
                 packets_per_second);
     }
 }