aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2017-08-08 18:02:30 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-08-09 11:33:26 +0200
commit91a4d98ec7ed723fdbfd6f35b85bedafee907884 (patch)
tree39f704c0f8888d08c8814da85d4a9a2ce4f4917f
parent21436e062a12b64c8bee665b0cf79dfe48cff114 (diff)
blaze_util_posix.cc: fix call to nanosleep
The struct timespec consists of a time_t and a long entry. So provide arguments of correct type, instead of two times an unsigned int, and explicitly cast appropriately. Fixes type errors on 32-bit machines. While there, also explicitly inlcude time.h, required for nanosleep. Change-Id: I56aabed1cc0c82d93f9c4b9b69d2c9d549207855 PiperOrigin-RevId: 164599502
-rw-r--r--src/main/cpp/blaze_util_posix.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
index fcf6d5cab6..55567b9f93 100644
--- a/src/main/cpp/blaze_util_posix.cc
+++ b/src/main/cpp/blaze_util_posix.cc
@@ -23,11 +23,12 @@
#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
+#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/resource.h>
#include <sys/wait.h>
+#include <time.h>
#include <unistd.h>
#include <cassert>
@@ -648,8 +649,8 @@ bool KillServerProcess(int pid, const string& output_base) {
}
void TrySleep(unsigned int milliseconds) {
- unsigned int seconds_part = milliseconds / 1000;
- unsigned int nanoseconds_part = (milliseconds % 1000) * 1000 * 1000;
+ time_t seconds_part = (time_t)(milliseconds / 1000);
+ long nanoseconds_part = ((long)(milliseconds % 1000)) * 1000 * 1000;
struct timespec sleeptime = {seconds_part, nanoseconds_part};
nanosleep(&sleeptime, NULL);
}