diff options
author | Ian Rogers <irogers@google.com> | 2014-12-03 10:48:05 -0800 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-12-03 10:48:05 -0800 |
commit | 14317f030db862bb2210135b9af510df429059fd (patch) | |
tree | 156a4bcc6d1410001d5cf3ba3fa2fda0317146cc | |
parent | 27478e627e08ab42c43d5d934da9ea336ccaf628 (diff) | |
download | art-14317f030db862bb2210135b9af510df429059fd.zip art-14317f030db862bb2210135b9af510df429059fd.tar.gz art-14317f030db862bb2210135b9af510df429059fd.tar.bz2 |
Remove unused headers.
Push Closure into only use in thread_pool.h.
Remove StringFile and NullFile that existed purely for a test.
Change-Id: I329892d5e1f5f017caeb3d60600f803a74114fc1
-rw-r--r-- | build/Android.gtest.mk | 3 | ||||
-rw-r--r-- | runtime/Android.mk | 2 | ||||
-rw-r--r-- | runtime/base/unix_file/null_file.cc | 63 | ||||
-rw-r--r-- | runtime/base/unix_file/null_file.h | 50 | ||||
-rw-r--r-- | runtime/base/unix_file/null_file_test.cc | 67 | ||||
-rw-r--r-- | runtime/base/unix_file/random_access_file_utils_test.cc | 56 | ||||
-rw-r--r-- | runtime/base/unix_file/string_file.cc | 98 | ||||
-rw-r--r-- | runtime/base/unix_file/string_file.h | 59 | ||||
-rw-r--r-- | runtime/base/unix_file/string_file_test.cc | 42 | ||||
-rw-r--r-- | runtime/closure.h | 32 | ||||
-rw-r--r-- | runtime/strutil.h | 40 | ||||
-rw-r--r-- | runtime/thread_pool.h | 7 |
12 files changed, 6 insertions, 513 deletions
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk index 10b0400..380174e 100644 --- a/build/Android.gtest.mk +++ b/build/Android.gtest.mk @@ -90,9 +90,6 @@ RUNTIME_GTEST_COMMON_SRC_FILES := \ runtime/base/stringprintf_test.cc \ runtime/base/timing_logger_test.cc \ runtime/base/unix_file/fd_file_test.cc \ - runtime/base/unix_file/null_file_test.cc \ - runtime/base/unix_file/random_access_file_utils_test.cc \ - runtime/base/unix_file/string_file_test.cc \ runtime/class_linker_test.cc \ runtime/dex_file_test.cc \ runtime/dex_file_verifier_test.cc \ diff --git a/runtime/Android.mk b/runtime/Android.mk index 7dfdb75..b362b73 100644 --- a/runtime/Android.mk +++ b/runtime/Android.mk @@ -31,9 +31,7 @@ LIBART_COMMON_SRC_FILES := \ base/stringprintf.cc \ base/timing_logger.cc \ base/unix_file/fd_file.cc \ - base/unix_file/null_file.cc \ base/unix_file/random_access_file_utils.cc \ - base/unix_file/string_file.cc \ check_jni.cc \ class_linker.cc \ common_throws.cc \ diff --git a/runtime/base/unix_file/null_file.cc b/runtime/base/unix_file/null_file.cc deleted file mode 100644 index 322c25a..0000000 --- a/runtime/base/unix_file/null_file.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "base/unix_file/null_file.h" -#include <errno.h> - -namespace unix_file { - -NullFile::NullFile() { -} - -NullFile::~NullFile() { -} - -int NullFile::Close() { - return 0; -} - -int NullFile::Flush() { - return 0; -} - -int64_t NullFile::Read(char* buf ATTRIBUTE_UNUSED, int64_t byte_count ATTRIBUTE_UNUSED, - int64_t offset) const { - if (offset < 0) { - return -EINVAL; - } - return 0; -} - -int NullFile::SetLength(int64_t new_length) { - if (new_length < 0) { - return -EINVAL; - } - return 0; -} - -int64_t NullFile::GetLength() const { - return 0; -} - -int64_t NullFile::Write(const char* buf ATTRIBUTE_UNUSED, int64_t byte_count ATTRIBUTE_UNUSED, - int64_t offset) { - if (offset < 0) { - return -EINVAL; - } - return byte_count; -} - -} // namespace unix_file diff --git a/runtime/base/unix_file/null_file.h b/runtime/base/unix_file/null_file.h deleted file mode 100644 index 3394731..0000000 --- a/runtime/base/unix_file/null_file.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ -#define ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ - -#include "base/unix_file/random_access_file.h" -#include "base/macros.h" - -namespace unix_file { - -// A RandomAccessFile implementation equivalent to /dev/null. Writes are -// discarded, and there's no data to be read. Callers could use FdFile in -// conjunction with /dev/null, but that's not portable and costs a file -// descriptor. NullFile is "free". -// -// Thread safe. -class NullFile : public RandomAccessFile { - public: - NullFile(); - virtual ~NullFile(); - - // RandomAccessFile API. - virtual int Close(); - virtual int Flush(); - virtual int64_t Read(char* buf, int64_t byte_count, int64_t offset) const; - virtual int SetLength(int64_t new_length); - virtual int64_t GetLength() const; - virtual int64_t Write(const char* buf, int64_t byte_count, int64_t offset); - - private: - DISALLOW_COPY_AND_ASSIGN(NullFile); -}; - -} // namespace unix_file - -#endif // ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ diff --git a/runtime/base/unix_file/null_file_test.cc b/runtime/base/unix_file/null_file_test.cc deleted file mode 100644 index 410fdfc..0000000 --- a/runtime/base/unix_file/null_file_test.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "base/unix_file/null_file.h" - -#include <errno.h> - -#include "gtest/gtest.h" - -namespace unix_file { - -class NullFileTest : public testing::Test { }; - -TEST_F(NullFileTest, Read) { - NullFile f; - char buf[256]; - // You can't read a negative number of bytes... - ASSERT_EQ(-EINVAL, f.Read(buf, 0, -1)); - // ...but everything else is fine (though you'll get no data). - ASSERT_EQ(0, f.Read(buf, 128, 0)); - ASSERT_EQ(0, f.Read(buf, 128, 128)); -} - -TEST_F(NullFileTest, SetLength) { - NullFile f; - // You can't set a negative length... - ASSERT_EQ(-EINVAL, f.SetLength(-1)); - // ...but everything else is fine. - ASSERT_EQ(0, f.SetLength(0)); - ASSERT_EQ(0, f.SetLength(128)); -} - -TEST_F(NullFileTest, GetLength) { - const std::string content("hello"); - NullFile f; - // The length is always 0. - ASSERT_EQ(0, f.GetLength()); - ASSERT_EQ(content.size(), static_cast<uint64_t>(f.Write(content.data(), content.size(), 0))); - ASSERT_EQ(0, f.GetLength()); -} - -TEST_F(NullFileTest, Write) { - const std::string content("hello"); - NullFile f; - // You can't write at a negative offset... - ASSERT_EQ(-EINVAL, f.Write(content.data(), content.size(), -128)); - // But you can write anywhere else... - ASSERT_EQ(content.size(), static_cast<uint64_t>(f.Write(content.data(), content.size(), 0))); - ASSERT_EQ(content.size(), static_cast<uint64_t>(f.Write(content.data(), content.size(), 128))); - // ...though the file will remain empty. - ASSERT_EQ(0, f.GetLength()); -} - -} // namespace unix_file diff --git a/runtime/base/unix_file/random_access_file_utils_test.cc b/runtime/base/unix_file/random_access_file_utils_test.cc deleted file mode 100644 index 9457d22..0000000 --- a/runtime/base/unix_file/random_access_file_utils_test.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "base/unix_file/random_access_file_utils.h" -#include "base/unix_file/fd_file.h" -#include "base/unix_file/string_file.h" -#include "gtest/gtest.h" - -namespace unix_file { - -class RandomAccessFileUtilsTest : public testing::Test { }; - -TEST_F(RandomAccessFileUtilsTest, CopyFile) { - StringFile src; - StringFile dst; - - const std::string content("hello"); - src.Assign(content); - ASSERT_EQ(src.ToStringPiece(), content); - ASSERT_EQ(dst.ToStringPiece(), ""); - - ASSERT_TRUE(CopyFile(src, &dst)); - ASSERT_EQ(src.ToStringPiece(), dst.ToStringPiece()); -} - -TEST_F(RandomAccessFileUtilsTest, BadSrc) { - FdFile src(-1, false); - StringFile dst; - ASSERT_FALSE(CopyFile(src, &dst)); -} - -TEST_F(RandomAccessFileUtilsTest, BadDst) { - StringFile src; - FdFile dst(-1, false); - - // We need some source content to trigger a write. - // Copying an empty file is a no-op. - src.Assign("hello"); - - ASSERT_FALSE(CopyFile(src, &dst)); -} - -} // namespace unix_file diff --git a/runtime/base/unix_file/string_file.cc b/runtime/base/unix_file/string_file.cc deleted file mode 100644 index ff0d0fa..0000000 --- a/runtime/base/unix_file/string_file.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "base/unix_file/string_file.h" -#include <errno.h> -#include <algorithm> -#include "base/logging.h" - -namespace unix_file { - -StringFile::StringFile() { -} - -StringFile::~StringFile() { -} - -int StringFile::Close() { - return 0; -} - -int StringFile::Flush() { - return 0; -} - -int64_t StringFile::Read(char *buf, int64_t byte_count, int64_t offset) const { - CHECK(buf); - CHECK_GE(byte_count, 0); - - if (offset < 0) { - return -EINVAL; - } - - const int64_t available_bytes = std::min(byte_count, GetLength() - offset); - if (available_bytes < 0) { - return 0; // Not an error, but nothing for us to do, either. - } - memcpy(buf, data_.data() + offset, available_bytes); - return available_bytes; -} - -int StringFile::SetLength(int64_t new_length) { - if (new_length < 0) { - return -EINVAL; - } - data_.resize(new_length); - return 0; -} - -int64_t StringFile::GetLength() const { - return data_.size(); -} - -int64_t StringFile::Write(const char *buf, int64_t byte_count, int64_t offset) { - CHECK(buf); - CHECK_GE(byte_count, 0); - - if (offset < 0) { - return -EINVAL; - } - - if (byte_count == 0) { - return 0; - } - - // FUSE seems happy to allow writes past the end. (I'd guess it doesn't - // synthesize a write of zero bytes so that we're free to implement sparse - // files.) GNU as(1) seems to require such writes. Those files are small. - const int64_t bytes_past_end = offset - GetLength(); - if (bytes_past_end > 0) { - data_.append(bytes_past_end, '\0'); - } - - data_.replace(offset, byte_count, buf, byte_count); - return byte_count; -} - -void StringFile::Assign(const art::StringPiece &new_data) { - data_.assign(new_data.data(), new_data.size()); -} - -const art::StringPiece StringFile::ToStringPiece() const { - return data_; -} - -} // namespace unix_file diff --git a/runtime/base/unix_file/string_file.h b/runtime/base/unix_file/string_file.h deleted file mode 100644 index 26904f8..0000000 --- a/runtime/base/unix_file/string_file.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ -#define ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ - -#include <stdint.h> - -#include <string> - -#include "base/macros.h" -#include "base/stringpiece.h" -#include "base/unix_file/random_access_file.h" - -namespace unix_file { - -// A RandomAccessFile implementation backed by a std::string. (That is, all data is -// kept in memory.) -// -// Not thread safe. -class StringFile : public RandomAccessFile { - public: - StringFile(); - virtual ~StringFile(); - - // RandomAccessFile API. - virtual int Close(); - virtual int Flush(); - virtual int64_t Read(char* buf, int64_t byte_count, int64_t offset) const; - virtual int SetLength(int64_t new_length); - virtual int64_t GetLength() const; - virtual int64_t Write(const char* buf, int64_t byte_count, int64_t offset); - - // Bonus API. - void Assign(const art::StringPiece& new_data); - const art::StringPiece ToStringPiece() const; - - private: - std::string data_; - - DISALLOW_COPY_AND_ASSIGN(StringFile); -}; - -} // namespace unix_file - -#endif // ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ diff --git a/runtime/base/unix_file/string_file_test.cc b/runtime/base/unix_file/string_file_test.cc deleted file mode 100644 index 8821461..0000000 --- a/runtime/base/unix_file/string_file_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "base/unix_file/string_file.h" -#include "base/unix_file/random_access_file_test.h" -#include "gtest/gtest.h" - -namespace unix_file { - -class StringFileTest : public RandomAccessFileTest { - protected: - virtual RandomAccessFile* MakeTestFile() { - return new StringFile; - } -}; - -TEST_F(StringFileTest, Read) { - TestRead(); -} - -TEST_F(StringFileTest, SetLength) { - TestSetLength(); -} - -TEST_F(StringFileTest, Write) { - TestWrite(); -} - -} // namespace unix_file diff --git a/runtime/closure.h b/runtime/closure.h deleted file mode 100644 index 9bea28f..0000000 --- a/runtime/closure.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_CLOSURE_H_ -#define ART_RUNTIME_CLOSURE_H_ - -namespace art { - -class Thread; - -class Closure { - public: - virtual ~Closure() { } - virtual void Run(Thread* self) = 0; -}; - -} // namespace art - -#endif // ART_RUNTIME_CLOSURE_H_ diff --git a/runtime/strutil.h b/runtime/strutil.h deleted file mode 100644 index c8d39e2..0000000 --- a/runtime/strutil.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_STRUTIL_H_ -#define ART_RUNTIME_STRUTIL_H_ - -#include <string.h> - -namespace art { - -// Key comparison function for C strings. -struct CStringLt { - bool operator()(const char* s1, const char* s2) const { - return strcmp(s1, s2) < 0; - } -}; - -// Key equality function for C strings. -struct CStringEq { - bool operator()(const char* s1, const char* s2) const { - return strcmp(s1, s2) == 0; - } -}; - -} // namespace art - -#endif // ART_RUNTIME_STRUTIL_H_ diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index d6330c8..8c08067 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -22,13 +22,18 @@ #include "barrier.h" #include "base/mutex.h" -#include "closure.h" #include "mem_map.h" namespace art { class ThreadPool; +class Closure { + public: + virtual ~Closure() { } + virtual void Run(Thread* self) = 0; +}; + class Task : public Closure { public: // Called when references reaches 0. |