[Lldb-commits] [lldb] r154250 - in /lldb/trunk: include/lldb/Host/TimeValue.h source/Host/common/TimeValue.cpp
Jason Molenda
jmolenda at apple.com
Fri Apr 6 21:55:02 PDT 2012
Author: jmolenda
Date: Fri Apr 6 23:55:02 2012
New Revision: 154250
URL: http://llvm.org/viewvc/llvm-project?rev=154250&view=rev
Log:
Fix a integer trauction issue - calculating the current time in
nanoseconds in 32-bit expression would cause pthread_cond_timedwait
to time out immediately. Add explicit casts to the TimeValue::TimeValue
ctor that takes a struct timeval and change the NanoSecsPerSec etc
constants defined in TimeValue to be uint64_t so any other calculations
involving these should be promoted to 64-bit even when lldb is built
for 32-bit.
<rdar://problem/11204073>, <rdar://problem/11179821>, <rdar://problem/11194705>.
Modified:
lldb/trunk/include/lldb/Host/TimeValue.h
lldb/trunk/source/Host/common/TimeValue.cpp
Modified: lldb/trunk/include/lldb/Host/TimeValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/TimeValue.h?rev=154250&r1=154249&r2=154250&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/TimeValue.h (original)
+++ lldb/trunk/include/lldb/Host/TimeValue.h Fri Apr 6 23:55:02 2012
@@ -30,9 +30,9 @@
class TimeValue
{
public:
- static const uint32_t MicroSecPerSec = 1000000UL;
- static const uint32_t NanoSecPerSec = 1000000000UL;
- static const uint32_t NanoSecPerMicroSec = 1000U;
+ static const uint64_t MicroSecPerSec = 1000000UL;
+ static const uint64_t NanoSecPerSec = 1000000000UL;
+ static const uint64_t NanoSecPerMicroSec = 1000U;
//------------------------------------------------------------------
// Constructors and Destructors
Modified: lldb/trunk/source/Host/common/TimeValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/TimeValue.cpp?rev=154250&r1=154249&r2=154250&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/TimeValue.cpp (original)
+++ lldb/trunk/source/Host/common/TimeValue.cpp Fri Apr 6 23:55:02 2012
@@ -38,12 +38,12 @@
}
TimeValue::TimeValue(const struct timespec& ts) :
- m_nano_seconds (ts.tv_sec * NanoSecPerSec + ts.tv_nsec)
+ m_nano_seconds ((uint64_t) ts.tv_sec * NanoSecPerSec + ts.tv_nsec)
{
}
TimeValue::TimeValue(const struct timeval& tv) :
- m_nano_seconds (tv.tv_sec * NanoSecPerSec + tv.tv_usec * NanoSecPerMicroSec)
+ m_nano_seconds ((uint64_t) tv.tv_sec * NanoSecPerSec + (uint64_t) tv.tv_usec * NanoSecPerMicroSec)
{
}
More information about the lldb-commits
mailing list