Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/build_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ TEST_F(BuildLogTest, Truncate) {
log1.RecordCommand(state_.edges_[1], 20, 25);
log1.Close();
}

#ifdef __USE_LARGEFILE64
struct stat64 statbuf;
ASSERT_EQ(0, stat64(kTestFilename, &statbuf));
#else
struct stat statbuf;
ASSERT_EQ(0, stat(kTestFilename, &statbuf));
#endif
ASSERT_GT(statbuf.st_size, 0);

// For all possible truncations of the input file, assert that we don't
Expand Down
43 changes: 40 additions & 3 deletions src/deps_log_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,13 @@ TEST_F(DepsLogTest, DoubleEntry) {
deps.push_back(state.GetNode("bar.h", 0));
log.RecordDeps(state.GetNode("out.o", 0), 1, deps);
log.Close();

#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
file_size = (int)st.st_size;
ASSERT_GT(file_size, 0);
}
Expand All @@ -160,9 +164,13 @@ TEST_F(DepsLogTest, DoubleEntry) {
deps.push_back(state.GetNode("bar.h", 0));
log.RecordDeps(state.GetNode("out.o", 0), 1, deps);
log.Close();

#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
int file_size_2 = (int)st.st_size;
ASSERT_EQ(file_size, file_size_2);
}
Expand Down Expand Up @@ -198,9 +206,13 @@ TEST_F(DepsLogTest, Recompact) {
log.RecordDeps(state.GetNode("other_out.o", 0), 1, deps);

log.Close();

#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
file_size = (int)st.st_size;
ASSERT_GT(file_size, 0);
}
Expand All @@ -222,8 +234,13 @@ TEST_F(DepsLogTest, Recompact) {
log.RecordDeps(state.GetNode("out.o", 0), 1, deps);
log.Close();

#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
file_size_2 = (int)st.st_size;
// The file should grow to record the new deps.
ASSERT_GT(file_size_2, file_size);
Expand Down Expand Up @@ -273,8 +290,13 @@ TEST_F(DepsLogTest, Recompact) {
ASSERT_EQ(other_out, log.nodes()[other_out->id()]);

// The file should have shrunk a bit for the smaller deps.
#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
file_size_3 = (int)st.st_size;
ASSERT_LT(file_size_3, file_size_2);
}
Expand Down Expand Up @@ -317,8 +339,13 @@ TEST_F(DepsLogTest, Recompact) {
ASSERT_EQ(-1, state.LookupNode("baz.h")->id());

// The file should have shrunk more.
#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
int file_size_4 = (int)st.st_size;
ASSERT_LT(file_size_4, file_size_3);
}
Expand Down Expand Up @@ -374,8 +401,13 @@ TEST_F(DepsLogTest, Truncated) {
}

// Get the file size.
#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif

// Try reloading at truncated sizes.
// Track how many nodes/deps were found; they should decrease with
Expand Down Expand Up @@ -434,8 +466,13 @@ TEST_F(DepsLogTest, TruncatedRecovery) {

// Shorten the file, corrupting the last record.
{
#ifdef __USE_LARGEFILE64
struct stat64 st;
ASSERT_EQ(0, stat64(kTestFilename, &st));
#else
struct stat st;
ASSERT_EQ(0, stat(kTestFilename, &st));
#endif
string err;
ASSERT_TRUE(Truncate(kTestFilename, st.st_size - 2, &err));
}
Expand Down
5 changes: 5 additions & 0 deletions src/disk_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ TimeStamp RealDiskInterface::Stat(const string& path, string* err) const {
}
DirCache::iterator di = ci->second.find(base);
return di != ci->second.end() ? di->second : 0;
#else
#ifdef __USE_LARGEFILE64
struct stat64 st;
if (stat64(path.c_str(), &st) < 0) {
#else
struct stat st;
if (stat(path.c_str(), &st) < 0) {
#endif
if (errno == ENOENT || errno == ENOTDIR)
return 0;
*err = "stat(" + path + "): " + strerror(errno);
Expand Down
5 changes: 5 additions & 0 deletions src/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,13 @@ int ReadFile(const string& path, string* contents, string* err) {
return -errno;
}

#ifdef __USE_LARGEFILE64
struct stat64 st;
if (fstat64(fileno(f), &st) < 0) {
#else
struct stat st;
if (fstat(fileno(f), &st) < 0) {
#endif
err->assign(strerror(errno));
fclose(f);
return -errno;
Expand Down