[Lldb-commits] [lldb] r133370 - in /lldb/trunk: include/lldb/Host/TimeValue.h source/Core/Communication.cpp source/Core/ConnectionFileDescriptor.cpp source/Host/common/TimeValue.cpp source/Plugins/Process/Utility/UnwindLLDB.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Peter Collingbourne peter at pcc.me.uk
Sat Jun 18 16:52:14 PDT 2011


Author: pcc
Date: Sat Jun 18 18:52:14 2011
New Revision: 133370

URL: http://llvm.org/viewvc/llvm-project?rev=133370&view=rev
Log:
Switch from USEC_PER_SEC/NSEC_PER_SEC/NSEC_PER_USEC to TimeValue constants

Fixes the Linux build.

Modified:
    lldb/trunk/include/lldb/Host/TimeValue.h
    lldb/trunk/source/Core/Communication.cpp
    lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
    lldb/trunk/source/Host/common/TimeValue.cpp
    lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

Modified: lldb/trunk/include/lldb/Host/TimeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/TimeValue.h (original)
+++ lldb/trunk/include/lldb/Host/TimeValue.h Sat Jun 18 18:52:14 2011
@@ -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

Modified: lldb/trunk/source/Core/Communication.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/source/Core/Communication.cpp (original)
+++ lldb/trunk/source/Core/Communication.cpp Sat Jun 18 18:52:14 2011
@@ -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)

Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Sat Jun 18 18:52:14 2011
@@ -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;

Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Sat Jun 18 18:52:14 2011
@@ -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

Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Sat Jun 18 18:52:14 2011
@@ -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

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h Sat Jun 18 18:52:14 2011
@@ -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

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=133370&r1=133369&r2=133370&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Sat Jun 18 18:52:14 2011
@@ -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);
     }
 }





More information about the lldb-commits mailing list