diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/file_output_stream.cc | 6 | ||||
| -rw-r--r-- | src/file_output_stream.h | 5 | ||||
| -rw-r--r-- | src/oat_writer.cc | 12 | ||||
| -rw-r--r-- | src/output_stream.h | 12 | ||||
| -rw-r--r-- | src/output_stream_test.cc | 8 | ||||
| -rw-r--r-- | src/vector_output_stream.cc | 18 | ||||
| -rw-r--r-- | src/vector_output_stream.h | 5 |
7 files changed, 33 insertions, 33 deletions
diff --git a/src/file_output_stream.cc b/src/file_output_stream.cc index 8b967af388..0e4a2949ed 100644 --- a/src/file_output_stream.cc +++ b/src/file_output_stream.cc @@ -23,14 +23,14 @@ namespace art { -FileOutputStream::FileOutputStream(File* file) : OutputStream(file->GetPath()), file_(file) {}; +FileOutputStream::FileOutputStream(File* file) : OutputStream(file->GetPath()), file_(file) {} bool FileOutputStream::WriteFully(const void* buffer, int64_t byte_count) { return file_->WriteFully(buffer, byte_count); } -off_t FileOutputStream::lseek(off_t offset, int whence) { - return ::lseek(file_->Fd(), offset, whence); +off_t FileOutputStream::Seek(off_t offset, Whence whence) { + return lseek(file_->Fd(), offset, static_cast<int>(whence)); } } // namespace art diff --git a/src/file_output_stream.h b/src/file_output_stream.h index 41067449cf..b5eb4f8194 100644 --- a/src/file_output_stream.h +++ b/src/file_output_stream.h @@ -24,15 +24,14 @@ namespace art { class FileOutputStream : public OutputStream { - public: FileOutputStream(File* file); - virtual ~FileOutputStream() {}; + virtual ~FileOutputStream() {} virtual bool WriteFully(const void* buffer, int64_t byte_count); - virtual off_t lseek(off_t offset, int whence); + virtual off_t Seek(off_t offset, Whence whence); private: File* file_; diff --git a/src/oat_writer.cc b/src/oat_writer.cc index c5b698ca8b..113bebaa53 100644 --- a/src/oat_writer.cc +++ b/src/oat_writer.cc @@ -422,7 +422,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, } #define DCHECK_CODE_OFFSET() \ - DCHECK_EQ(static_cast<off_t>(code_offset), out.lseek(0, SEEK_CUR)) + DCHECK_EQ(static_cast<off_t>(code_offset), out.Seek(0, kSeekCurrent)) bool OatWriter::Write(OutputStream& out) { if (!out.WriteFully(oat_header_, sizeof(*oat_header_))) { @@ -464,7 +464,7 @@ bool OatWriter::WriteTables(OutputStream& out) { } for (size_t i = 0; i != oat_dex_files_.size(); ++i) { uint32_t expected_offset = oat_dex_files_[i]->dex_file_offset_; - off_t actual_offset = out.lseek(expected_offset, SEEK_SET); + off_t actual_offset = out.Seek(expected_offset, kSeekSet); 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 @@ -488,7 +488,7 @@ bool OatWriter::WriteTables(OutputStream& out) { size_t OatWriter::WriteCode(OutputStream& out) { uint32_t code_offset = oat_header_->GetExecutableOffset(); - off_t new_offset = out.lseek(executable_offset_padding_length_, SEEK_CUR); + off_t new_offset = out.Seek(executable_offset_padding_length_, kSeekCurrent); 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: " << out.GetLocation(); @@ -585,7 +585,7 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t code_offset, size_t 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) { - off_t new_offset = out.lseek(aligned_code_delta, SEEK_CUR); + off_t new_offset = out.Seek(aligned_code_delta, kSeekCurrent); 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: " << out.GetLocation(); @@ -696,7 +696,7 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t code_offset, size_t compiler_->GetInstructionSet()); uint32_t aligned_code_delta = aligned_code_offset - code_offset; if (aligned_code_delta != 0) { - off_t new_offset = out.lseek(aligned_code_delta, SEEK_CUR); + off_t new_offset = out.Seek(aligned_code_delta, kSeekCurrent); 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; @@ -742,7 +742,7 @@ size_t OatWriter::WriteCodeMethod(OutputStream& out, size_t code_offset, size_t uint32_t aligned_code_delta = aligned_code_offset - code_offset; CHECK(aligned_code_delta < 48u); if (aligned_code_delta != 0) { - off_t new_offset = out.lseek(aligned_code_delta, SEEK_CUR); + off_t new_offset = out.Seek(aligned_code_delta, kSeekCurrent); if (static_cast<uint32_t>(new_offset) != aligned_code_offset) { PLOG(ERROR) << "Failed to seek to align proxy stub code. Actual: " << new_offset << " Expected: " << aligned_code_offset; diff --git a/src/output_stream.h b/src/output_stream.h index c35fe25ec2..b03092ddf7 100644 --- a/src/output_stream.h +++ b/src/output_stream.h @@ -25,11 +25,17 @@ namespace art { +enum Whence { + kSeekSet = SEEK_SET, + kSeekCurrent = SEEK_CUR, + kSeekEnd = SEEK_END, +}; + class OutputStream { public: - OutputStream(const std::string& location) : location_(location) {}; + OutputStream(const std::string& location) : location_(location) {} - virtual ~OutputStream() {}; + virtual ~OutputStream() {} const std::string& GetLocation() const { return location_; @@ -37,7 +43,7 @@ class OutputStream { virtual bool WriteFully(const void* buffer, int64_t byte_count) = 0; - virtual off_t lseek(off_t offset, int whence) = 0; + virtual off_t Seek(off_t offset, Whence whence) = 0; private: const std::string location_; diff --git a/src/output_stream_test.cc b/src/output_stream_test.cc index 8415d9fef8..0e02825ff8 100644 --- a/src/output_stream_test.cc +++ b/src/output_stream_test.cc @@ -24,7 +24,7 @@ namespace art { class OutputStreamTest : public CommonTest { protected: void CheckOffset(off_t expected) { - off_t actual = output_stream_->lseek(0, SEEK_CUR); + off_t actual = output_stream_->Seek(0, kSeekCurrent); CHECK_EQ(expected, actual); } @@ -33,14 +33,14 @@ class OutputStreamTest : public CommonTest { } void GenerateTestOutput() { - CHECK_EQ(3, output_stream_->lseek(3, SEEK_CUR)); + CHECK_EQ(3, output_stream_->Seek(3, kSeekCurrent)); CheckOffset(3); - CHECK_EQ(2, output_stream_->lseek(2, SEEK_SET)); + CHECK_EQ(2, output_stream_->Seek(2, kSeekSet)); CheckOffset(2); uint8_t buf[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; CHECK(output_stream_->WriteFully(buf, 2)); CheckOffset(4); - CHECK_EQ(6, output_stream_->lseek(2, SEEK_END)); + CHECK_EQ(6, output_stream_->Seek(2, kSeekEnd)); CheckOffset(6); CHECK(output_stream_->WriteFully(buf, 4)); CheckOffset(10); diff --git a/src/vector_output_stream.cc b/src/vector_output_stream.cc index 73bc209dec..96154ee92b 100644 --- a/src/vector_output_stream.cc +++ b/src/vector_output_stream.cc @@ -23,7 +23,7 @@ namespace art { VectorOutputStream::VectorOutputStream(const std::string& location, std::vector<uint8_t>& vector) - : OutputStream(location), offset_(vector.size()), vector_(vector) {}; + : OutputStream(location), offset_(vector.size()), vector_(vector) {} bool VectorOutputStream::WriteFully(const void* buffer, int64_t byte_count) { off_t new_offset = offset_ + byte_count; @@ -33,26 +33,22 @@ bool VectorOutputStream::WriteFully(const void* buffer, int64_t byte_count) { return true; } -off_t VectorOutputStream::lseek(off_t offset, int whence) { - CHECK(whence == SEEK_SET || whence == SEEK_CUR || whence == SEEK_END) << whence; - off_t new_offset; +off_t VectorOutputStream::Seek(off_t offset, Whence whence) { + CHECK(whence == kSeekSet || whence == kSeekCurrent || whence == kSeekEnd) << whence; + off_t new_offset = 0; switch (whence) { - case SEEK_SET: { + case kSeekSet: { new_offset = offset; break; } - case SEEK_CUR: { + case kSeekCurrent: { new_offset = offset_ + offset; break; } - case SEEK_END: { + case kSeekEnd: { new_offset = vector_.size() + offset; break; } - default: { - LOG(FATAL) << whence; - new_offset = -1; - } } EnsureCapacity(new_offset); offset_ = new_offset; diff --git a/src/vector_output_stream.h b/src/vector_output_stream.h index a11c82b6c5..a99128e6f3 100644 --- a/src/vector_output_stream.h +++ b/src/vector_output_stream.h @@ -25,15 +25,14 @@ namespace art { class VectorOutputStream : public OutputStream { - public: VectorOutputStream(const std::string& location, std::vector<uint8_t>& vector); - virtual ~VectorOutputStream() {}; + virtual ~VectorOutputStream() {} virtual bool WriteFully(const void* buffer, int64_t byte_count); - virtual off_t lseek(off_t offset, int whence); + virtual off_t Seek(off_t offset, Whence whence); private: void EnsureCapacity(off_t new_offset); |