summaryrefslogtreecommitdiffstats
path: root/src/deps_log.cc
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2017-10-20 17:18:16 (GMT)
committerGitHub <noreply@github.com>2017-10-20 17:18:16 (GMT)
commite234a7bdb6c42f4539c0ab09b624f191287c2c10 (patch)
tree2bfad4ed54dcb5c22672a62d74dad2db25ee32d0 /src/deps_log.cc
parent0d9bf7866322c9abd4e7e537d64d979af56498d7 (diff)
parent0c42653da8ccaeb14b7c28ba9670eeac0460037e (diff)
downloadNinja-e234a7bdb6c42f4539c0ab09b624f191287c2c10.zip
Ninja-e234a7bdb6c42f4539c0ab09b624f191287c2c10.tar.gz
Ninja-e234a7bdb6c42f4539c0ab09b624f191287c2c10.tar.bz2
Merge pull request #1219 from QuLogic/resolution
Use high-resolution timestamps
Diffstat (limited to 'src/deps_log.cc')
-rw-r--r--src/deps_log.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/deps_log.cc b/src/deps_log.cc
index 8734dd7..eb81a37 100644
--- a/src/deps_log.cc
+++ b/src/deps_log.cc
@@ -30,7 +30,7 @@
// The version is stored as 4 bytes after the signature and also serves as a
// byte order mark. Signature and version combined are 16 bytes long.
const char kFileSignature[] = "# ninjadeps\n";
-const int kCurrentVersion = 3;
+const int kCurrentVersion = 4;
// Record size is currently limited to less than the full 32 bit, due to
// internal buffers having to have this size.
@@ -124,7 +124,7 @@ bool DepsLog::RecordDeps(Node* node, TimeStamp mtime,
return true;
// Update on-disk representation.
- unsigned size = 4 * (1 + 1 + node_count);
+ unsigned size = 4 * (1 + 2 + node_count);
if (size > kMaxRecordSize) {
errno = ERANGE;
return false;
@@ -135,8 +135,11 @@ bool DepsLog::RecordDeps(Node* node, TimeStamp mtime,
int id = node->id();
if (fwrite(&id, 4, 1, file_) < 1)
return false;
- int timestamp = mtime;
- if (fwrite(&timestamp, 4, 1, file_) < 1)
+ uint32_t mtime_part = static_cast<uint32_t>(mtime & 0xffffffff);
+ if (fwrite(&mtime_part, 4, 1, file_) < 1)
+ return false;
+ mtime_part = static_cast<uint32_t>((mtime >> 32) & 0xffffffff);
+ if (fwrite(&mtime_part, 4, 1, file_) < 1)
return false;
for (int i = 0; i < node_count; ++i) {
id = nodes[i]->id();
@@ -218,9 +221,11 @@ bool DepsLog::Load(const string& path, State* state, string* err) {
assert(size % 4 == 0);
int* deps_data = reinterpret_cast<int*>(buf);
int out_id = deps_data[0];
- int mtime = deps_data[1];
- deps_data += 2;
- int deps_count = (size / 4) - 2;
+ TimeStamp mtime;
+ mtime = (TimeStamp)(((uint64_t)(unsigned int)deps_data[2] << 32) |
+ (uint64_t)(unsigned int)deps_data[1]);
+ deps_data += 3;
+ int deps_count = (size / 4) - 3;
Deps* deps = new Deps(mtime, deps_count);
for (int i = 0; i < deps_count; ++i) {