Move logging.h into base/logging.h.
Change-Id: Id68f85f7c3a71b156cb40dec63f94d4fb827f279
diff --git a/src/base/logging.cc b/src/base/logging.cc
new file mode 100644
index 0000000..6d0452b
--- /dev/null
+++ b/src/base/logging.cc
@@ -0,0 +1,232 @@
+/*
+ * 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.
+ */
+
+#include "logging.h"
+
+#include "base/mutex.h"
+#include "runtime.h"
+#include "thread.h"
+#include "utils.h"
+
+namespace art {
+
+LogVerbosity gLogVerbosity;
+
+bool gAborting = false;
+
+static LogSeverity gMinimumLogSeverity = INFO;
+static std::string* gCmdLine;
+static std::string* gProgramInvocationName;
+static std::string* gProgramInvocationShortName;
+
+const char* GetCmdLine() {
+ return (gCmdLine != NULL) ? gCmdLine->c_str() : NULL;
+}
+
+const char* ProgramInvocationName() {
+ return (gProgramInvocationName != NULL) ? gProgramInvocationName->c_str() : "art";
+}
+
+const char* ProgramInvocationShortName() {
+ return (gProgramInvocationShortName != NULL) ? gProgramInvocationShortName->c_str() : "art";
+}
+
+// Configure logging based on ANDROID_LOG_TAGS environment variable.
+// We need to parse a string that looks like
+//
+// *:v jdwp:d dalvikvm:d dalvikvm-gc:i dalvikvmi:i
+//
+// The tag (or '*' for the global level) comes first, followed by a colon
+// and a letter indicating the minimum priority level we're expected to log.
+// This can be used to reveal or conceal logs with specific tags.
+void InitLogging(char* argv[]) {
+ // TODO: Move this to a more obvious InitART...
+ Locks::Init();
+
+ // Stash the command line for later use. We can use /proc/self/cmdline on Linux to recover this,
+ // but we don't have that luxury on the Mac, and there are a couple of argv[0] variants that are
+ // commonly used.
+ gCmdLine = new std::string(argv[0]);
+ for (size_t i = 1; argv[i] != NULL; ++i) {
+ gCmdLine->append(" ");
+ gCmdLine->append(argv[i]);
+ }
+ gProgramInvocationName = new std::string(argv[0]);
+ const char* last_slash = strrchr(argv[0], '/');
+ gProgramInvocationShortName = new std::string((last_slash != NULL) ? last_slash + 1 : argv[0]);
+
+ const char* tags = getenv("ANDROID_LOG_TAGS");
+ if (tags == NULL) {
+ return;
+ }
+
+ std::vector<std::string> specs;
+ Split(tags, ' ', specs);
+ for (size_t i = 0; i < specs.size(); ++i) {
+ // "tag-pattern:[vdiwefs]"
+ std::string spec(specs[i]);
+ if (spec.size() == 3 && StartsWith(spec, "*:")) {
+ switch (spec[2]) {
+ case 'v': gMinimumLogSeverity = VERBOSE; continue;
+ case 'd': gMinimumLogSeverity = DEBUG; continue;
+ case 'i': gMinimumLogSeverity = INFO; continue;
+ case 'w': gMinimumLogSeverity = WARNING; continue;
+ case 'e': gMinimumLogSeverity = ERROR; continue;
+ case 'f': gMinimumLogSeverity = FATAL; continue;
+ // liblog will even suppress FATAL if you say 's' for silent, but that's crazy!
+ case 's': gMinimumLogSeverity = FATAL; continue;
+ }
+ }
+ LOG(FATAL) << "unsupported '" << spec << "' in ANDROID_LOG_TAGS (" << tags << ")";
+ }
+}
+
+LogMessageData::LogMessageData(const char* file, int line, LogSeverity severity, int error)
+ : file(file),
+ line_number(line),
+ severity(severity),
+ error(error) {
+ const char* last_slash = strrchr(file, '/');
+ file = (last_slash == NULL) ? file : last_slash + 1;
+}
+
+LogMessage::~LogMessage() {
+ if (data_->severity < gMinimumLogSeverity) {
+ return; // No need to format something we're not going to output.
+ }
+
+ // Finish constructing the message.
+ if (data_->error != -1) {
+ data_->buffer << ": " << strerror(data_->error);
+ }
+ std::string msg(data_->buffer.str());
+
+ // Do the actual logging with the lock held.
+ {
+ MutexLock mu(Thread::Current(), *Locks::logging_lock_);
+ if (msg.find('\n') == std::string::npos) {
+ LogLine(*data_, msg.c_str());
+ } else {
+ msg += '\n';
+ size_t i = 0;
+ while (i < msg.size()) {
+ size_t nl = msg.find('\n', i);
+ msg[nl] = '\0';
+ LogLine(*data_, &msg[i]);
+ i = nl + 1;
+ }
+ }
+ }
+
+ // Abort if necessary.
+ if (data_->severity == FATAL) {
+ Runtime::Abort();
+ }
+
+ delete data_;
+}
+
+std::ostream& LogMessage::stream() {
+ return data_->buffer;
+}
+
+HexDump::HexDump(const void* address, size_t byte_count, bool show_actual_addresses)
+ : address_(address), byte_count_(byte_count), show_actual_addresses_(show_actual_addresses) {
+}
+
+void HexDump::Dump(std::ostream& os) const {
+ if (byte_count_ == 0) {
+ return;
+ }
+
+ if (address_ == NULL) {
+ os << "00000000:";
+ return;
+ }
+
+ static const char gHexDigit[] = "0123456789abcdef";
+ const unsigned char* addr = reinterpret_cast<const unsigned char*>(address_);
+ char out[76]; /* exact fit */
+ unsigned int offset; /* offset to show while printing */
+
+ if (show_actual_addresses_) {
+ offset = reinterpret_cast<int>(addr);
+ } else {
+ offset = 0;
+ }
+ memset(out, ' ', sizeof(out)-1);
+ out[8] = ':';
+ out[sizeof(out)-1] = '\0';
+
+ size_t byte_count = byte_count_;
+ int gap = static_cast<int>(offset & 0x0f);
+ while (byte_count) {
+ unsigned int line_offset = offset & ~0x0f;
+
+ char* hex = out;
+ char* asc = out + 59;
+
+ for (int i = 0; i < 8; i++) {
+ *hex++ = gHexDigit[line_offset >> 28];
+ line_offset <<= 4;
+ }
+ hex++;
+ hex++;
+
+ int count = std::min(static_cast<int>(byte_count), 16 - gap);
+ CHECK_NE(count, 0);
+ CHECK_LE(count + gap, 16);
+
+ if (gap) {
+ /* only on first line */
+ hex += gap * 3;
+ asc += gap;
+ }
+
+ int i;
+ for (i = gap ; i < count+gap; i++) {
+ *hex++ = gHexDigit[*addr >> 4];
+ *hex++ = gHexDigit[*addr & 0x0f];
+ hex++;
+ if (*addr >= 0x20 && *addr < 0x7f /*isprint(*addr)*/) {
+ *asc++ = *addr;
+ } else {
+ *asc++ = '.';
+ }
+ addr++;
+ }
+ for (; i < 16; i++) {
+ /* erase extra stuff; only happens on last line */
+ *hex++ = ' ';
+ *hex++ = ' ';
+ hex++;
+ *asc++ = ' ';
+ }
+
+ os << out;
+
+ gap = 0;
+ byte_count -= count;
+ offset += count;
+ }
+}
+
+std::ostream& operator<<(std::ostream& os, const HexDump& rhs) {
+ rhs.Dump(os);
+ return os;
+}
+
+} // namespace art
diff --git a/src/base/logging.h b/src/base/logging.h
new file mode 100644
index 0000000..a08acab
--- /dev/null
+++ b/src/base/logging.h
@@ -0,0 +1,332 @@
+/*
+ * 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_SRC_BASE_LOGGING_H_
+#define ART_SRC_BASE_LOGGING_H_
+
+#include <cerrno>
+#include <cstring>
+#include <iostream> // NOLINT
+#include <sstream>
+#include <signal.h>
+#include "base/macros.h"
+#include "log_severity.h"
+
+#define CHECK(x) \
+ if (UNLIKELY(!(x))) \
+ ::art::LogMessage(__FILE__, __LINE__, FATAL, -1).stream() \
+ << "Check failed: " #x << " "
+
+#define CHECK_OP(LHS, RHS, OP) \
+ for (::art::EagerEvaluator<typeof(LHS), typeof(RHS)> _values(LHS, RHS); \
+ UNLIKELY(!(_values.lhs OP _values.rhs)); /* empty */) \
+ ::art::LogMessage(__FILE__, __LINE__, FATAL, -1).stream() \
+ << "Check failed: " << #LHS << " " << #OP << " " << #RHS \
+ << " (" #LHS "=" << _values.lhs << ", " #RHS "=" << _values.rhs << ") "
+
+#define CHECK_EQ(x, y) CHECK_OP(x, y, ==)
+#define CHECK_NE(x, y) CHECK_OP(x, y, !=)
+#define CHECK_LE(x, y) CHECK_OP(x, y, <=)
+#define CHECK_LT(x, y) CHECK_OP(x, y, <)
+#define CHECK_GE(x, y) CHECK_OP(x, y, >=)
+#define CHECK_GT(x, y) CHECK_OP(x, y, >)
+
+#define CHECK_STROP(s1, s2, sense) \
+ if (UNLIKELY((strcmp(s1, s2) == 0) != sense)) \
+ LOG(FATAL) << "Check failed: " \
+ << "\"" << s1 << "\"" \
+ << (sense ? " == " : " != ") \
+ << "\"" << s2 << "\""
+
+#define CHECK_STREQ(s1, s2) CHECK_STROP(s1, s2, true)
+#define CHECK_STRNE(s1, s2) CHECK_STROP(s1, s2, false)
+
+#define CHECK_PTHREAD_CALL(call, args, what) \
+ do { \
+ int rc = call args; \
+ if (rc != 0) { \
+ errno = rc; \
+ PLOG(FATAL) << # call << " failed for " << what; \
+ } \
+ } while (false)
+
+#ifndef NDEBUG
+
+#define DCHECK(x) CHECK(x)
+#define DCHECK_EQ(x, y) CHECK_EQ(x, y)
+#define DCHECK_NE(x, y) CHECK_NE(x, y)
+#define DCHECK_LE(x, y) CHECK_LE(x, y)
+#define DCHECK_LT(x, y) CHECK_LT(x, y)
+#define DCHECK_GE(x, y) CHECK_GE(x, y)
+#define DCHECK_GT(x, y) CHECK_GT(x, y)
+#define DCHECK_STREQ(s1, s2) CHECK_STREQ(s1, s2)
+#define DCHECK_STRNE(s1, s2) CHECK_STRNE(s1, s2)
+
+#else // NDEBUG
+
+#define DCHECK(condition) \
+ while (false) \
+ CHECK(condition)
+
+#define DCHECK_EQ(val1, val2) \
+ while (false) \
+ CHECK_EQ(val1, val2)
+
+#define DCHECK_NE(val1, val2) \
+ while (false) \
+ CHECK_NE(val1, val2)
+
+#define DCHECK_LE(val1, val2) \
+ while (false) \
+ CHECK_LE(val1, val2)
+
+#define DCHECK_LT(val1, val2) \
+ while (false) \
+ CHECK_LT(val1, val2)
+
+#define DCHECK_GE(val1, val2) \
+ while (false) \
+ CHECK_GE(val1, val2)
+
+#define DCHECK_GT(val1, val2) \
+ while (false) \
+ CHECK_GT(val1, val2)
+
+#define DCHECK_STREQ(str1, str2) \
+ while (false) \
+ CHECK_STREQ(str1, str2)
+
+#define DCHECK_STRNE(str1, str2) \
+ while (false) \
+ CHECK_STRNE(str1, str2)
+
+#endif
+
+#define LOG(severity) ::art::LogMessage(__FILE__, __LINE__, severity, -1).stream()
+#define PLOG(severity) ::art::LogMessage(__FILE__, __LINE__, severity, errno).stream()
+
+#define LG LOG(INFO)
+
+#define UNIMPLEMENTED(level) LOG(level) << __PRETTY_FUNCTION__ << " unimplemented "
+
+#define VLOG_IS_ON(module) UNLIKELY(::art::gLogVerbosity.module)
+#define VLOG(module) if (VLOG_IS_ON(module)) ::art::LogMessage(__FILE__, __LINE__, INFO, -1).stream()
+
+//
+// Implementation details beyond this point.
+//
+
+namespace art {
+
+template <typename LHS, typename RHS>
+struct EagerEvaluator {
+ EagerEvaluator(LHS lhs, RHS rhs) : lhs(lhs), rhs(rhs) { }
+ LHS lhs;
+ RHS rhs;
+};
+
+// We want char*s to be treated as pointers, not strings. If you want them treated like strings,
+// you'd need to use CHECK_STREQ and CHECK_STRNE anyway to compare the characters rather than their
+// addresses. We could express this more succinctly with std::remove_const, but this is quick and
+// easy to understand, and works before we have C++0x. We rely on signed/unsigned warnings to
+// protect you against combinations not explicitly listed below.
+#define EAGER_PTR_EVALUATOR(T1, T2) \
+ template <> struct EagerEvaluator<T1, T2> { \
+ EagerEvaluator(T1 lhs, T2 rhs) \
+ : lhs(reinterpret_cast<const void*>(lhs)), \
+ rhs(reinterpret_cast<const void*>(rhs)) { } \
+ const void* lhs; \
+ const void* rhs; \
+ }
+EAGER_PTR_EVALUATOR(const char*, const char*);
+EAGER_PTR_EVALUATOR(const char*, char*);
+EAGER_PTR_EVALUATOR(char*, const char*);
+EAGER_PTR_EVALUATOR(char*, char*);
+EAGER_PTR_EVALUATOR(const unsigned char*, const unsigned char*);
+EAGER_PTR_EVALUATOR(const unsigned char*, unsigned char*);
+EAGER_PTR_EVALUATOR(unsigned char*, const unsigned char*);
+EAGER_PTR_EVALUATOR(unsigned char*, unsigned char*);
+EAGER_PTR_EVALUATOR(const signed char*, const signed char*);
+EAGER_PTR_EVALUATOR(const signed char*, signed char*);
+EAGER_PTR_EVALUATOR(signed char*, const signed char*);
+EAGER_PTR_EVALUATOR(signed char*, signed char*);
+
+// This indirection greatly reduces the stack impact of having
+// lots of checks/logging in a function.
+struct LogMessageData {
+ public:
+ LogMessageData(const char* file, int line, LogSeverity severity, int error);
+ std::ostringstream buffer;
+ const char* file;
+ int line_number;
+ LogSeverity severity;
+ int error;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(LogMessageData);
+};
+
+class LogMessage {
+ public:
+ LogMessage(const char* file, int line, LogSeverity severity, int error)
+ : data_(new LogMessageData(file, line, severity, error)) {
+ }
+ ~LogMessage() LOCKS_EXCLUDED(Locks::logging_lock_);
+ std::ostream& stream();
+
+ private:
+ static void LogLine(const LogMessageData& data, const char*);
+
+ LogMessageData* data_;
+
+ friend void HandleUnexpectedSignal(int signal_number, siginfo_t* info, void* raw_context);
+ DISALLOW_COPY_AND_ASSIGN(LogMessage);
+};
+
+// Prints a hex dump in this format:
+//
+// 01234560: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 0123456789abcdef
+// 01234568: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 0123456789abcdef
+class HexDump {
+ public:
+ HexDump(const void* address, size_t byte_count, bool show_actual_addresses = false);
+ void Dump(std::ostream& os) const;
+
+ private:
+ const void* address_;
+ size_t byte_count_;
+ bool show_actual_addresses_;
+
+ // TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*.
+#if GCC_VERSION >= 40300
+ DISALLOW_COPY_AND_ASSIGN(HexDump);
+#endif
+};
+std::ostream& operator<<(std::ostream& os, const HexDump& rhs);
+
+// A convenience to allow any class with a "Dump(std::ostream& os)" member function
+// but without an operator<< to be used as if it had an operator<<. Use like this:
+//
+// os << Dumpable<MyType>(my_type_instance);
+//
+template<typename T>
+class Dumpable {
+ public:
+ explicit Dumpable(T& value) : value_(value) {
+ }
+
+ void Dump(std::ostream& os) const {
+ value_.Dump(os);
+ }
+
+ private:
+ T& value_;
+
+// TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*.
+#if GCC_VERSION >= 40300
+ DISALLOW_COPY_AND_ASSIGN(Dumpable);
+#endif
+};
+
+template<typename T>
+std::ostream& operator<<(std::ostream& os, const Dumpable<T>& rhs) {
+ rhs.Dump(os);
+ return os;
+}
+
+template<typename T>
+class MutatorLockedDumpable {
+ public:
+ explicit MutatorLockedDumpable(T& value)
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) : value_(value) {
+ }
+
+ void Dump(std::ostream& os) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ value_.Dump(os);
+ }
+
+ private:
+ T& value_;
+
+// TODO: Remove the #if when Mac OS build server no longer uses GCC 4.2.*.
+#if GCC_VERSION >= 40300
+ DISALLOW_COPY_AND_ASSIGN(MutatorLockedDumpable);
+#endif
+};
+
+template<typename T>
+std::ostream& operator<<(std::ostream& os, const MutatorLockedDumpable<T>& rhs)
+// TODO: should be SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) however annotalysis
+// currently fails for this.
+ NO_THREAD_SAFETY_ANALYSIS {
+ rhs.Dump(os);
+ return os;
+}
+
+// Helps you use operator<< in a const char*-like context such as our various 'F' methods with
+// format strings.
+template<typename T>
+class ToStr {
+ public:
+ explicit ToStr(const T& value) {
+ std::ostringstream os;
+ os << value;
+ s_ = os.str();
+ }
+
+ const char* c_str() const {
+ return s_.c_str();
+ }
+
+ const std::string& str() const {
+ return s_;
+ }
+
+ private:
+ std::string s_;
+ DISALLOW_COPY_AND_ASSIGN(ToStr);
+};
+
+// The members of this struct are the valid arguments to VLOG and VLOG_IS_ON in code,
+// and the "-verbose:" command line argument.
+struct LogVerbosity {
+ bool class_linker; // Enabled with "-verbose:class".
+ bool compiler;
+ bool heap;
+ bool gc;
+ bool jdwp;
+ bool jni;
+ bool monitor;
+ bool startup;
+ bool third_party_jni; // Enabled with "-verbose:third-party-jni".
+ bool threads;
+};
+
+extern LogVerbosity gLogVerbosity;
+
+// Used on fatal exit. Prevents recursive aborts. Allows us to disable
+// some error checking to ensure fatal shutdown makes forward progress.
+extern bool gAborting;
+
+extern void InitLogging(char* argv[]);
+
+extern const char* GetCmdLine();
+extern const char* ProgramInvocationName();
+extern const char* ProgramInvocationShortName();
+
+} // namespace art
+
+#endif // ART_SRC_BASE_LOGGING_H_
diff --git a/src/base/logging_android.cc b/src/base/logging_android.cc
new file mode 100644
index 0000000..0acf5f9
--- /dev/null
+++ b/src/base/logging_android.cc
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+#include "logging.h"
+#include "stringprintf.h"
+
+#include <iostream>
+#include <unistd.h>
+
+#include "cutils/log.h"
+
+namespace art {
+
+static const int kLogSeverityToAndroidLogPriority[] = {
+ ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, ANDROID_LOG_WARN,
+ ANDROID_LOG_ERROR, ANDROID_LOG_FATAL, ANDROID_LOG_FATAL
+};
+
+void LogMessage::LogLine(const LogMessageData& data, const char* message) {
+ const char* tag = ProgramInvocationShortName();
+ int priority = kLogSeverityToAndroidLogPriority[data.severity];
+ if (priority == ANDROID_LOG_FATAL) {
+ LOG_PRI(priority, tag, "%s:%d] %s", data.file, data.line_number, message);
+ } else {
+ LOG_PRI(priority, tag, "%s", message);
+ }
+}
+
+} // namespace art
diff --git a/src/base/logging_linux.cc b/src/base/logging_linux.cc
new file mode 100644
index 0000000..789c083
--- /dev/null
+++ b/src/base/logging_linux.cc
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <cstdio>
+#include <cstring>
+#include <iostream>
+
+#include "logging.h"
+#include "stringprintf.h"
+#include "utils.h"
+
+namespace art {
+
+void LogMessage::LogLine(const LogMessageData& data, const char* message) {
+ char severity = "VDIWEFF"[data.severity];
+ fprintf(stderr, "%s %c %5d %5d %s:%d] %s\n",
+ ProgramInvocationShortName(), severity, getpid(), ::art::GetTid(),
+ data.file, data.line_number, message);
+}
+
+} // namespace art
diff --git a/src/base/mutex.cc b/src/base/mutex.cc
index 16811d3..a5d890a 100644
--- a/src/base/mutex.cc
+++ b/src/base/mutex.cc
@@ -19,9 +19,9 @@
#include <errno.h>
#include <sys/time.h>
+#include "base/logging.h"
#include "cutils/atomic.h"
#include "cutils/atomic-inline.h"
-#include "logging.h"
#include "runtime.h"
#include "scoped_thread_state_change.h"
#include "thread.h"
diff --git a/src/base/mutex.h b/src/base/mutex.h
index af7becf..5cc021f 100644
--- a/src/base/mutex.h
+++ b/src/base/mutex.h
@@ -23,10 +23,10 @@
#include <iosfwd>
#include <string>
+#include "base/logging.h"
#include "base/macros.h"
#include "globals.h"
#include "locks.h"
-#include "logging.h"
#if defined(__APPLE__)
#define ART_USE_FUTEXES 0
diff --git a/src/base/unix_file/fd_file.cc b/src/base/unix_file/fd_file.cc
index 73130a3..7bb28a1 100644
--- a/src/base/unix_file/fd_file.cc
+++ b/src/base/unix_file/fd_file.cc
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+#include "base/logging.h"
#include "base/unix_file/fd_file.h"
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
-#include "logging.h"
namespace unix_file {
diff --git a/src/base/unix_file/mapped_file.cc b/src/base/unix_file/mapped_file.cc
index 84629b3..b63fdd3 100644
--- a/src/base/unix_file/mapped_file.cc
+++ b/src/base/unix_file/mapped_file.cc
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include "base/logging.h"
#include "base/unix_file/mapped_file.h"
#include <fcntl.h>
#include <sys/mman.h>
@@ -22,7 +23,6 @@
#include <unistd.h>
#include <algorithm>
#include <string>
-#include "logging.h"
namespace unix_file {
diff --git a/src/base/unix_file/mapped_file_test.cc b/src/base/unix_file/mapped_file_test.cc
index f61ed3b..a3b097d 100644
--- a/src/base/unix_file/mapped_file_test.cc
+++ b/src/base/unix_file/mapped_file_test.cc
@@ -15,12 +15,12 @@
*/
#include "base/unix_file/mapped_file.h"
+#include "base/logging.h"
#include "base/unix_file/fd_file.h"
#include "base/unix_file/random_access_file_test.h"
#include "base/unix_file/random_access_file_utils.h"
#include "base/unix_file/string_file.h"
#include "gtest/gtest.h"
-#include "logging.h"
namespace unix_file {
diff --git a/src/base/unix_file/string_file.cc b/src/base/unix_file/string_file.cc
index 5d47b17..ff0d0fa 100644
--- a/src/base/unix_file/string_file.cc
+++ b/src/base/unix_file/string_file.cc
@@ -17,7 +17,7 @@
#include "base/unix_file/string_file.h"
#include <errno.h>
#include <algorithm>
-#include "logging.h"
+#include "base/logging.h"
namespace unix_file {