Attempt to fix freebsd build after r287864
authorPavel Labath <labath@google.com>
Thu, 24 Nov 2016 11:22:43 +0000 (11:22 +0000)
committerPavel Labath <labath@google.com>
Thu, 24 Nov 2016 11:22:43 +0000 (11:22 +0000)
the chrono library there uses long long as the underlying chrono type, but
defines int64_t as long (or the other way around, I am not sure). In any case,
this caused the implicit conversion to not trigger. This should address that.

Also fix up the relevant unit test.

llvm-svn: 287867

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/unittests/Process/gdb-remote/GDBRemoteTestUtils.h

index 619113d..a73ba4e 100644 (file)
@@ -57,9 +57,9 @@ template <typename Ratio>
 class Timeout : public llvm::Optional<std::chrono::duration<int64_t, Ratio>> {
 private:
   template <typename Ratio2> using Dur = std::chrono::duration<int64_t, Ratio2>;
-  template <typename Ratio2>
+  template <typename Rep2, typename Ratio2>
   using EnableIf = std::enable_if<
-      std::is_convertible<std::chrono::duration<int64_t, Ratio2>,
+      std::is_convertible<std::chrono::duration<Rep2, Ratio2>,
                           std::chrono::duration<int64_t, Ratio>>::value>;
 
   using Base = llvm::Optional<Dur<Ratio>>;
@@ -68,12 +68,15 @@ public:
   Timeout(llvm::NoneType none) : Base(none) {}
   Timeout(const Timeout &other) = default;
 
-  template <typename Ratio2, typename = typename EnableIf<Ratio2>::type>
+  template <typename Ratio2,
+            typename = typename EnableIf<int64_t, Ratio2>::type>
   Timeout(const Timeout<Ratio2> &other)
       : Base(other ? Base(Dur<Ratio>(*other)) : llvm::None) {}
 
-  template <typename Ratio2, typename = typename EnableIf<Ratio2>::type>
-  Timeout(const Dur<Ratio2> &other) : Base(Dur<Ratio>(other)) {}
+  template <typename Rep2, typename Ratio2,
+            typename = typename EnableIf<Rep2, Ratio2>::type>
+  Timeout(const std::chrono::duration<Rep2, Ratio2> &other)
+      : Base(Dur<Ratio>(other)) {}
 };
 
 class GDBRemoteCommunication : public Communication {
index f4fc92c..d7700f2 100644 (file)
@@ -36,10 +36,9 @@ struct MockServer : public GDBRemoteCommunicationServer {
   }
 
   PacketResult GetPacket(StringExtractorGDBRemote &response) {
-    const unsigned timeout_usec = 1000000; // 1s
     const bool sync_on_timeout = false;
-    return WaitForPacketWithTimeoutMicroSecondsNoLock(response, timeout_usec,
-                                                      sync_on_timeout);
+    return WaitForPacketNoLock(response, std::chrono::seconds(1),
+                               sync_on_timeout);
   }
 
   using GDBRemoteCommunicationServer::SendOKResponse;