Index: runtime/platform/thread_macos.cc |
=================================================================== |
--- runtime/platform/thread_macos.cc (revision 38492) |
+++ runtime/platform/thread_macos.cc (working copy) |
@@ -297,10 +297,14 @@ |
} else { |
struct timespec ts; |
int64_t secs = micros / kMicrosecondsPerSecond; |
+ if (secs > kMaxInt32) { |
+ // Avoid truncation of overly large timeout values. |
+ secs = kMaxInt32; |
+ } |
int64_t nanos = |
(micros - (secs * kMicrosecondsPerSecond)) * kNanosecondsPerMicrosecond; |
- ts.tv_sec = secs; |
- ts.tv_nsec = nanos; |
+ ts.tv_sec = static_cast<int32_t>(secs); |
+ ts.tv_nsec = static_cast<long>(nanos); // NOLINT (long used in timespec). |
int result = pthread_cond_timedwait_relative_np(data_.cond(), |
data_.mutex(), |
&ts); |