Remove the damage caused by my bad advice.
The old world never coped with > 32-bit file offsets, Mac OS doesn't have an
off64_t, and we should fix bionic to have _FILE_OFFSET_BITS rather than turd
up all calling code.
Change-Id: I0cb8b1f83fc19ce1fcf51257594551cfd1aa968c
diff --git a/src/file.h b/src/file.h
index babcb8b..3353602 100644
--- a/src/file.h
+++ b/src/file.h
@@ -27,11 +27,11 @@
// Get the length of the file. Returns a negative value if the length cannot
// be determined (e.g. not seekable device).
- virtual off64_t Length() = 0;
+ virtual off_t Length() = 0;
// Get the current position in the file.
// Returns a negative value if position cannot be determined.
- virtual off64_t Position() = 0;
+ virtual off_t Position() = 0;
virtual int Fd() = 0;
diff --git a/src/file_linux.cc b/src/file_linux.cc
index 1f4be51..367dbe8 100644
--- a/src/file_linux.cc
+++ b/src/file_linux.cc
@@ -43,21 +43,21 @@
}
-off64_t LinuxFile::Position() {
+off_t LinuxFile::Position() {
DCHECK_GE(fd_, 0);
- return lseek64(fd_, 0, SEEK_CUR);
+ return lseek(fd_, 0, SEEK_CUR);
}
-off64_t LinuxFile::Length() {
+off_t LinuxFile::Length() {
DCHECK_GE(fd_, 0);
- off64_t position = lseek64(fd_, 0, SEEK_CUR);
+ off_t position = lseek(fd_, 0, SEEK_CUR);
if (position < 0) {
// The file is not capable of seeking. Return an error.
return -1;
}
- off64_t result = lseek64(fd_, 0, SEEK_END);
- lseek64(fd_, position, SEEK_SET);
+ off_t result = lseek(fd_, 0, SEEK_END);
+ lseek(fd_, position, SEEK_SET);
return result;
}
diff --git a/src/file_linux.h b/src/file_linux.h
index 51605e2..3d381d5 100644
--- a/src/file_linux.h
+++ b/src/file_linux.h
@@ -19,8 +19,8 @@
virtual int64_t Read(void* buffer, int64_t num_bytes);
virtual int64_t Write(const void* buffer, int64_t num_bytes);
- virtual off64_t Length();
- virtual off64_t Position();
+ virtual off_t Length();
+ virtual off_t Position();
virtual int Fd() {
return fd_;
diff --git a/src/oat_writer.cc b/src/oat_writer.cc
index 3ab2fb9..ac41e4d 100644
--- a/src/oat_writer.cc
+++ b/src/oat_writer.cc
@@ -321,7 +321,7 @@
}
#define DCHECK_CODE_OFFSET() \
- DCHECK_EQ(static_cast<off64_t>(code_offset), lseek64(file->Fd(), 0, SEEK_CUR))
+ DCHECK_EQ(static_cast<off_t>(code_offset), lseek(file->Fd(), 0, SEEK_CUR))
bool OatWriter::Write(File* file) {
if (!file->WriteFully(oat_header_, sizeof(*oat_header_))) {
@@ -358,7 +358,7 @@
}
for (size_t i = 0; i != oat_dex_files_.size(); ++i) {
uint32_t expected_offset = oat_dex_files_[i]->dex_file_offset_;
- off64_t actual_offset = lseek64(file->Fd(), expected_offset, SEEK_SET);
+ off_t actual_offset = lseek(file->Fd(), expected_offset, SEEK_SET);
if (static_cast<uint32_t>(actual_offset) != expected_offset) {
const DexFile* dex_file = (*dex_files_)[i];
PLOG(ERROR) << "Failed to seek to dex file section. Actual: " << actual_offset
@@ -388,7 +388,7 @@
size_t OatWriter::WriteCode(File* file) {
uint32_t code_offset = oat_header_->GetExecutableOffset();
- off64_t new_offset = lseek64(file->Fd(), executable_offset_padding_length_, SEEK_CUR);
+ off_t new_offset = lseek(file->Fd(), executable_offset_padding_length_, SEEK_CUR);
if (static_cast<uint32_t>(new_offset) != code_offset) {
PLOG(ERROR) << "Failed to seek to oat code section. Actual: " << new_offset
<< " Expected: " << code_offset << " File: " << file->name();
@@ -489,7 +489,7 @@
uint32_t aligned_code_offset = compiled_method->AlignCode(code_offset);
uint32_t aligned_code_delta = aligned_code_offset - code_offset;
if (aligned_code_delta != 0) {
- off64_t new_offset = lseek64(file->Fd(), aligned_code_delta, SEEK_CUR);
+ off_t new_offset = lseek(file->Fd(), aligned_code_delta, SEEK_CUR);
if (static_cast<uint32_t>(new_offset) != aligned_code_offset) {
PLOG(ERROR) << "Failed to seek to align oat code. Actual: " << new_offset
<< " Expected: " << aligned_code_offset << " File: " << file->name();
@@ -595,7 +595,7 @@
compiler_->GetInstructionSet());
uint32_t aligned_code_delta = aligned_code_offset - code_offset;
if (aligned_code_delta != 0) {
- off64_t new_offset = lseek64(file->Fd(), aligned_code_delta, SEEK_CUR);
+ off_t new_offset = lseek(file->Fd(), aligned_code_delta, SEEK_CUR);
if (static_cast<uint32_t>(new_offset) != aligned_code_offset) {
PLOG(ERROR) << "Failed to seek to align invoke stub code. Actual: " << new_offset
<< " Expected: " << aligned_code_offset;