From 9d2da5a6a39862f9212e6c79f65d92b5c5977351 Mon Sep 17 00:00:00 2001
From: jreisch <jreisch@synoptics.de>
Date: Tue, 18 Jan 2022 09:43:51 +0100
Subject: [PATCH] update includes

---
 benchmarks/db_bench.cc          |  5 ++---
 db/autocompact_test.cc          |  5 ++---
 db/builder.cc                   |  4 +++-
 db/builder.h                    |  2 --
 db/c.cc                         |  6 +++++-
 db/corruption_test.cc           |  8 ++++----
 db/db_impl.cc                   | 15 +++++++++++----
 db/db_impl.h                    | 14 +++++++-------
 db/db_iter.cc                   |  5 +++--
 db/db_iter.h                    |  3 ++-
 db/db_test.cc                   | 13 +++++++++----
 db/dbformat.cc                  |  2 +-
 db/dbformat.h                   |  5 ++++-
 db/dbformat_test.cc             |  2 +-
 db/dumpfile.cc                  |  7 +++++--
 db/filename.cc                  |  4 +++-
 db/filename_test.cc             |  2 --
 db/leveldbutil.cc               |  3 +++
 db/log_reader.cc                |  3 ++-
 db/log_reader.h                 |  2 ++
 db/log_writer.cc                |  3 ++-
 db/log_writer.h                 |  4 ++--
 db/memtable.cc                  |  7 +++----
 db/memtable.h                   |  4 +++-
 db/recovery_test.cc             |  7 ++++---
 db/repair.cc                    |  9 ++++-----
 db/skiplist.h                   |  3 +++
 db/skiplist_test.cc             | 10 +++++++++-
 db/table_cache.cc               |  4 ----
 db/table_cache.h                |  4 ++--
 db/version_edit.cc              |  3 +--
 db/version_edit.h               |  4 ++--
 db/version_edit_test.cc         |  2 --
 db/version_set.cc               | 11 ++++-------
 db/version_set.h                | 10 ++++++----
 db/version_set_test.cc          |  5 ++---
 db/write_batch.cc               |  6 ++++--
 db/write_batch_test.cc          |  7 +------
 helpers/memenv/memenv.cc        |  7 ++++++-
 helpers/memenv/memenv_test.cc   | 11 ++++++++---
 include/leveldb/cache.h         |  1 -
 include/leveldb/db.h            |  6 +++---
 include/leveldb/dumpfile.h      |  1 +
 include/leveldb/env.h           |  3 +++
 include/leveldb/iterator.h      |  2 --
 include/leveldb/slice.h         |  1 +
 include/leveldb/status.h        |  3 +++
 include/leveldb/table.h         |  2 --
 include/leveldb/table_builder.h |  3 +++
 port/port.h                     |  1 +
 port/port_stdcxx.h              |  4 ++++
 table/block.cc                  |  6 +++---
 table/block_builder.cc          |  6 ++++--
 table/block_builder.h           |  1 -
 table/filter_block.h            |  3 +++
 table/filter_block_test.cc      |  4 +---
 table/format.cc                 |  3 +--
 table/format.h                  |  3 +++
 table/iterator.cc               |  2 --
 table/iterator_wrapper.h        |  2 +-
 table/merger.cc                 |  4 +++-
 table/table.cc                  |  2 --
 table/table_builder.cc          |  6 ++++--
 table/table_test.cc             | 14 +++++++++-----
 table/two_level_iterator.cc     |  3 ++-
 table/two_level_iterator.h      |  1 -
 util/arena.cc                   |  4 ----
 util/arena.h                    |  3 ++-
 util/bloom_test.cc              |  7 ++-----
 util/cache.cc                   |  6 +++---
 util/cache_test.cc              |  5 ++---
 util/coding.cc                  |  2 --
 util/coding_test.cc             |  4 ++--
 util/comparator.cc              |  6 +++++-
 util/crc32c.cc                  |  7 ++++++-
 util/env_posix.cc               | 27 ++++++++++++++++++++++-----
 util/env_posix_test.cc          | 15 ++++++++++++---
 util/hash.cc                    |  2 ++
 util/histogram.cc               |  1 -
 util/logging.cc                 |  5 +++--
 util/logging_test.cc            |  4 +++-
 util/mutexlock.h                |  3 ++-
 util/no_destructor.h            |  1 +
 util/no_destructor_test.cc      |  3 +++
 util/posix_logger.h             |  8 ++++++--
 util/status.cc                  |  2 +-
 util/status_test.cc             |  3 +++
 util/testutil.cc                |  5 ++++-
 util/testutil.h                 |  6 +++---
 89 files changed, 275 insertions(+), 172 deletions(-)

diff --git a/benchmarks/db_bench.cc b/benchmarks/db_bench.cc
index baa069a..03d4189 100644
--- a/benchmarks/db_bench.cc
+++ b/benchmarks/db_bench.cc
@@ -3,6 +3,7 @@
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
 #include <atomic>
+#include <cstdio>
 #include <cstdlib>
 
 #include "leveldb/cache.h"
@@ -10,10 +11,8 @@
 #include "leveldb/db.h"
 #include "leveldb/env.h"
 #include "leveldb/filter_policy.h"
-#include "leveldb/iterator.h"
-#include "leveldb/options.h"
 #include "leveldb/write_batch.h"
-
+#include "leveldb/options.h"
 #include "util/crc32c.h"
 #include "util/histogram.h"
 #include "util/mutexlock.h"
diff --git a/db/autocompact_test.cc b/db/autocompact_test.cc
index 08ce97b..69341e3 100644
--- a/db/autocompact_test.cc
+++ b/db/autocompact_test.cc
@@ -2,11 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "gtest/gtest.h"
 #include "db/db_impl.h"
-
 #include "leveldb/cache.h"
-#include "leveldb/iterator.h"
-
+#include "leveldb/db.h"
 #include "util/testutil.h"
 
 namespace leveldb {
diff --git a/db/builder.cc b/db/builder.cc
index c9de137..e7b7d2f 100644
--- a/db/builder.cc
+++ b/db/builder.cc
@@ -2,10 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "db/builder.h"
+
+#include "db/dbformat.h"
 #include "db/filename.h"
 #include "db/table_cache.h"
 #include "db/version_edit.h"
-
 #include "leveldb/env.h"
 #include "leveldb/iterator.h"
 #include "leveldb/table_builder.h"
diff --git a/db/builder.h b/db/builder.h
index e12f543..7bd0b80 100644
--- a/db/builder.h
+++ b/db/builder.h
@@ -5,8 +5,6 @@
 #ifndef STORAGE_LEVELDB_DB_BUILDER_H_
 #define STORAGE_LEVELDB_DB_BUILDER_H_
 
-#include <string>
-
 #include "leveldb/status.h"
 
 namespace leveldb {
diff --git a/db/c.cc b/db/c.cc
index f859c1f..8bdde38 100644
--- a/db/c.cc
+++ b/db/c.cc
@@ -4,7 +4,10 @@
 
 #include "leveldb/c.h"
 
-#include <cstring>
+#include <string.h>
+
+#include <cstdint>
+#include <cstdlib>
 
 #include "leveldb/cache.h"
 #include "leveldb/comparator.h"
@@ -13,6 +16,7 @@
 #include "leveldb/filter_policy.h"
 #include "leveldb/iterator.h"
 #include "leveldb/options.h"
+#include "leveldb/status.h"
 #include "leveldb/write_batch.h"
 
 using leveldb::Cache;
diff --git a/db/corruption_test.cc b/db/corruption_test.cc
index a35c89d..af2339d 100644
--- a/db/corruption_test.cc
+++ b/db/corruption_test.cc
@@ -2,16 +2,16 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include <sys/types.h>
+
+#include "gtest/gtest.h"
 #include "db/db_impl.h"
 #include "db/filename.h"
 #include "db/log_format.h"
-
 #include "leveldb/cache.h"
-#include "leveldb/iterator.h"
+#include "leveldb/db.h"
 #include "leveldb/write_batch.h"
-
 #include "util/logging.h"
-#include "util/random.h"
 #include "util/testutil.h"
 
 namespace leveldb {
diff --git a/db/db_impl.cc b/db/db_impl.cc
index 4d2f6d6..3a99dbe 100644
--- a/db/db_impl.cc
+++ b/db/db_impl.cc
@@ -4,8 +4,17 @@
 
 #include "db/db_impl.h"
 
+#include <algorithm>
+#include <atomic>
+#include <cstdint>
+#include <cstdio>
+#include <set>
+#include <string>
+#include <vector>
+
 #include "db/builder.h"
 #include "db/db_iter.h"
+#include "db/dbformat.h"
 #include "db/filename.h"
 #include "db/log_reader.h"
 #include "db/log_writer.h"
@@ -13,12 +22,10 @@
 #include "db/table_cache.h"
 #include "db/version_set.h"
 #include "db/write_batch_internal.h"
-#include <algorithm>
-
+#include "leveldb/db.h"
 #include "leveldb/env.h"
-#include "leveldb/iterator.h"
+#include "leveldb/status.h"
 #include "leveldb/table_builder.h"
-
 #include "table/merger.h"
 #include "util/logging.h"
 #include "util/mutexlock.h"
diff --git a/db/db_impl.h b/db/db_impl.h
index 2953af1..98ee51e 100644
--- a/db/db_impl.h
+++ b/db/db_impl.h
@@ -5,19 +5,19 @@
 #ifndef STORAGE_LEVELDB_DB_DB_IMPL_H_
 #define STORAGE_LEVELDB_DB_DB_IMPL_H_
 
-#include "db/log_writer.h"
-#include "db/snapshot.h"
 #include <atomic>
 #include <deque>
-#include <map>
 #include <set>
-#include <vector>
+#include <string>
 
+#include "db/dbformat.h"
+#include "db/log_writer.h"
+#include "db/snapshot.h"
+#include "leveldb/db.h"
 #include "leveldb/env.h"
 #include "leveldb/options.h"
-#include "leveldb/status.h"
-
-#include "port/port_stdcxx.h"
+#include "port/port.h"
+#include "port/thread_annotations.h"
 
 namespace leveldb {
 
diff --git a/db/db_iter.cc b/db/db_iter.cc
index 4f386c1..f422266 100644
--- a/db/db_iter.cc
+++ b/db/db_iter.cc
@@ -2,10 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "db/db_iter.h"
+
 #include "db/db_impl.h"
-
+#include "db/dbformat.h"
 #include "leveldb/iterator.h"
-
 #include "util/random.h"
 
 namespace leveldb {
diff --git a/db/db_iter.h b/db/db_iter.h
index 3f85e12..deab29d 100644
--- a/db/db_iter.h
+++ b/db/db_iter.h
@@ -5,8 +5,9 @@
 #ifndef STORAGE_LEVELDB_DB_DB_ITER_H_
 #define STORAGE_LEVELDB_DB_DB_ITER_H_
 
-#include "db/dbformat.h"
+#include <cstdint>
 
+#include "db/dbformat.h"
 #include "leveldb/iterator.h"
 
 namespace leveldb {
diff --git a/db/db_test.cc b/db/db_test.cc
index c4db54d..83efefc 100644
--- a/db/db_test.cc
+++ b/db/db_test.cc
@@ -2,16 +2,21 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "leveldb/db.h"
+
+#include <atomic>
+#include <string>
+
+#include "gtest/gtest.h"
 #include "db/db_impl.h"
 #include "db/filename.h"
-
 #include "leveldb/cache.h"
-#include "leveldb/iterator.h"
+#include "leveldb/env.h"
+#include "leveldb/filter_policy.h"
 #include "leveldb/write_batch.h"
-
+#include "port/thread_annotations.h"
 #include "util/logging.h"
 #include "util/mutexlock.h"
-#include "util/random.h"
 #include "util/testutil.h"
 
 namespace leveldb {
diff --git a/db/dbformat.cc b/db/dbformat.cc
index d7aa8f5..0e2f162 100644
--- a/db/dbformat.cc
+++ b/db/dbformat.cc
@@ -4,9 +4,9 @@
 
 #include "db/dbformat.h"
 
-#include <cstring>
 #include <sstream>
 
+#include "util/coding.h"
 #include "util/logging.h"
 
 namespace leveldb {
diff --git a/db/dbformat.h b/db/dbformat.h
index acffcf1..1750f64 100644
--- a/db/dbformat.h
+++ b/db/dbformat.h
@@ -5,10 +5,13 @@
 #ifndef STORAGE_LEVELDB_DB_DBFORMAT_H_
 #define STORAGE_LEVELDB_DB_DBFORMAT_H_
 
+#include <cstddef>
+#include <cstdint>
+#include <string>
+
 #include "leveldb/comparator.h"
 #include "leveldb/filter_policy.h"
 #include "leveldb/slice.h"
-
 #include "util/coding.h"
 
 namespace leveldb {
diff --git a/db/dbformat_test.cc b/db/dbformat_test.cc
index e71c899..4312234 100644
--- a/db/dbformat_test.cc
+++ b/db/dbformat_test.cc
@@ -4,7 +4,7 @@
 
 #include "db/dbformat.h"
 
-#include <gtest/gtest_pred_impl.h>
+#include "gtest/gtest.h"
 
 namespace leveldb {
 
diff --git a/db/dumpfile.cc b/db/dumpfile.cc
index 271b97e..602c724 100644
--- a/db/dumpfile.cc
+++ b/db/dumpfile.cc
@@ -2,16 +2,19 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "leveldb/dumpfile.h"
+
+#include "db/dbformat.h"
 #include "db/filename.h"
 #include "db/log_reader.h"
 #include "db/version_edit.h"
 #include "db/write_batch_internal.h"
-
 #include "leveldb/env.h"
 #include "leveldb/iterator.h"
 #include "leveldb/options.h"
+#include "leveldb/status.h"
 #include "leveldb/table.h"
-
+#include "leveldb/write_batch.h"
 #include "util/logging.h"
 
 namespace leveldb {
diff --git a/db/filename.cc b/db/filename.cc
index 9c019d5..2d3afb6 100644
--- a/db/filename.cc
+++ b/db/filename.cc
@@ -4,8 +4,10 @@
 
 #include "db/filename.h"
 
-#include "leveldb/env.h"
+#include <cassert>
+#include <cstdio>
 
+#include "leveldb/env.h"
 #include "util/logging.h"
 
 namespace leveldb {
diff --git a/db/filename_test.cc b/db/filename_test.cc
index cdddab5..f7e4d2d 100644
--- a/db/filename_test.cc
+++ b/db/filename_test.cc
@@ -4,8 +4,6 @@
 
 #include "db/filename.h"
 
-#include "leveldb/slice.h"
-
 #include "gtest/gtest.h"
 
 namespace leveldb {
diff --git a/db/leveldbutil.cc b/db/leveldbutil.cc
index 4426edd..95ee897 100644
--- a/db/leveldbutil.cc
+++ b/db/leveldbutil.cc
@@ -2,8 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include <cstdio>
+
 #include "leveldb/dumpfile.h"
 #include "leveldb/env.h"
+#include "leveldb/status.h"
 
 namespace leveldb {
 namespace {
diff --git a/db/log_reader.cc b/db/log_reader.cc
index 9b53c25..9880279 100644
--- a/db/log_reader.cc
+++ b/db/log_reader.cc
@@ -4,8 +4,9 @@
 
 #include "db/log_reader.h"
 
-#include "leveldb/env.h"
+#include <cstdio>
 
+#include "leveldb/env.h"
 #include "util/coding.h"
 #include "util/crc32c.h"
 
diff --git a/db/log_reader.h b/db/log_reader.h
index cd1a498..ba711f8 100644
--- a/db/log_reader.h
+++ b/db/log_reader.h
@@ -5,6 +5,8 @@
 #ifndef STORAGE_LEVELDB_DB_LOG_READER_H_
 #define STORAGE_LEVELDB_DB_LOG_READER_H_
 
+#include <cstdint>
+
 #include "db/log_format.h"
 #include "leveldb/slice.h"
 #include "leveldb/status.h"
diff --git a/db/log_writer.cc b/db/log_writer.cc
index 065ca12..ad66bfb 100644
--- a/db/log_writer.cc
+++ b/db/log_writer.cc
@@ -4,8 +4,9 @@
 
 #include "db/log_writer.h"
 
-#include "leveldb/env.h"
+#include <cstdint>
 
+#include "leveldb/env.h"
 #include "util/coding.h"
 #include "util/crc32c.h"
 
diff --git a/db/log_writer.h b/db/log_writer.h
index 14b86dc..ad36794 100644
--- a/db/log_writer.h
+++ b/db/log_writer.h
@@ -5,10 +5,10 @@
 #ifndef STORAGE_LEVELDB_DB_LOG_WRITER_H_
 #define STORAGE_LEVELDB_DB_LOG_WRITER_H_
 
-#include "db/log_format.h"
 #include <cstdint>
-#include <cstddef>
 
+#include "db/log_format.h"
+#include "leveldb/slice.h"
 #include "leveldb/status.h"
 
 namespace leveldb {
diff --git a/db/memtable.cc b/db/memtable.cc
index 0945eb6..43f262f 100644
--- a/db/memtable.cc
+++ b/db/memtable.cc
@@ -3,11 +3,10 @@
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
 #include "db/memtable.h"
-
-#include <cstring>
-
+#include "db/dbformat.h"
+#include "leveldb/comparator.h"
 #include "leveldb/iterator.h"
-#include "leveldb/status.h"
+#include "util/coding.h"
 
 namespace leveldb {
 
diff --git a/db/memtable.h b/db/memtable.h
index 565f66d..f1ab0cb 100644
--- a/db/memtable.h
+++ b/db/memtable.h
@@ -5,10 +5,12 @@
 #ifndef STORAGE_LEVELDB_DB_MEMTABLE_H_
 #define STORAGE_LEVELDB_DB_MEMTABLE_H_
 
+#include <string>
+
 #include "db/dbformat.h"
 #include "db/skiplist.h"
-
 #include "leveldb/iterator.h"
+#include "util/arena.h"
 
 namespace leveldb {
 
diff --git a/db/recovery_test.cc b/db/recovery_test.cc
index f30da61..0d65a16 100644
--- a/db/recovery_test.cc
+++ b/db/recovery_test.cc
@@ -2,14 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "gtest/gtest.h"
 #include "db/db_impl.h"
 #include "db/filename.h"
 #include "db/write_batch_internal.h"
-
+#include "leveldb/db.h"
+#include "leveldb/env.h"
+#include "leveldb/write_batch.h"
 #include "util/testutil.h"
 
-#include "log_writer.h"
-
 namespace leveldb {
 
 class RecoveryTest : public testing::Test {
diff --git a/db/repair.cc b/db/repair.cc
index b28b4b1..c9b7108 100644
--- a/db/repair.cc
+++ b/db/repair.cc
@@ -26,6 +26,7 @@
 
 #include "db/builder.h"
 #include "db/db_impl.h"
+#include "db/dbformat.h"
 #include "db/filename.h"
 #include "db/log_reader.h"
 #include "db/log_writer.h"
@@ -33,12 +34,10 @@
 #include "db/table_cache.h"
 #include "db/version_edit.h"
 #include "db/write_batch_internal.h"
-
-#include "leveldb/env.h"
-#include "leveldb/iterator.h"
-#include "leveldb/table_builder.h"
-
 #include "util/logging.h"
+#include "leveldb/comparator.h"
+#include "leveldb/env.h"
+#include "leveldb/table_builder.h"
 
 namespace leveldb {
 
diff --git a/db/skiplist.h b/db/skiplist.h
index e179987..6bbf075 100644
--- a/db/skiplist.h
+++ b/db/skiplist.h
@@ -27,6 +27,9 @@
 //
 // ... prev vs. next pointer ordering ...
 
+#include <atomic>
+#include <cassert>
+
 #include "util/arena.h"
 #include "util/random.h"
 
diff --git a/db/skiplist_test.cc b/db/skiplist_test.cc
index b9aed48..1d355cb 100644
--- a/db/skiplist_test.cc
+++ b/db/skiplist_test.cc
@@ -4,8 +4,16 @@
 
 #include "db/skiplist.h"
 
-#include "port/port_stdcxx.h"
+#include <atomic>
+#include <set>
+
+#include "gtest/gtest.h"
+#include "leveldb/env.h"
+#include "port/port.h"
+#include "port/thread_annotations.h"
+#include "util/arena.h"
 #include "util/hash.h"
+#include "util/random.h"
 #include "util/testutil.h"
 
 namespace leveldb {
diff --git a/db/table_cache.cc b/db/table_cache.cc
index 93db0bf..73f05fd 100644
--- a/db/table_cache.cc
+++ b/db/table_cache.cc
@@ -5,12 +5,8 @@
 #include "db/table_cache.h"
 
 #include "db/filename.h"
-
 #include "leveldb/env.h"
-#include "leveldb/iterator.h"
-#include "leveldb/options.h"
 #include "leveldb/table.h"
-
 #include "util/coding.h"
 
 namespace leveldb {
diff --git a/db/table_cache.h b/db/table_cache.h
index 5c46732..8acc8f7 100644
--- a/db/table_cache.h
+++ b/db/table_cache.h
@@ -7,12 +7,12 @@
 #ifndef STORAGE_LEVELDB_DB_TABLE_CACHE_H_
 #define STORAGE_LEVELDB_DB_TABLE_CACHE_H_
 
+#include <cstdint>
 #include <string>
 
 #include "leveldb/cache.h"
-#include "leveldb/iterator.h"
-#include "leveldb/options.h"
 #include "leveldb/table.h"
+#include "leveldb/options.h"
 
 namespace leveldb {
 
diff --git a/db/version_edit.cc b/db/version_edit.cc
index e9e2e7a..b1b7d7e 100644
--- a/db/version_edit.cc
+++ b/db/version_edit.cc
@@ -4,8 +4,7 @@
 
 #include "db/version_edit.h"
 
-#include "leveldb/status.h"
-
+#include "util/coding.h"
 #include "util/logging.h"
 
 namespace leveldb {
diff --git a/db/version_edit.h b/db/version_edit.h
index 7094cae..1379db0 100644
--- a/db/version_edit.h
+++ b/db/version_edit.h
@@ -5,11 +5,11 @@
 #ifndef STORAGE_LEVELDB_DB_VERSION_EDIT_H_
 #define STORAGE_LEVELDB_DB_VERSION_EDIT_H_
 
-#include "db/dbformat.h"
-#include <map>
 #include <set>
+#include <utility>
 #include <vector>
 
+#include "db/dbformat.h"
 #include "leveldb/status.h"
 
 namespace leveldb {
diff --git a/db/version_edit_test.cc b/db/version_edit_test.cc
index dfb6b5d..a108c15 100644
--- a/db/version_edit_test.cc
+++ b/db/version_edit_test.cc
@@ -4,8 +4,6 @@
 
 #include "db/version_edit.h"
 
-#include "leveldb/status.h"
-
 #include "gtest/gtest.h"
 
 namespace leveldb {
diff --git a/db/version_set.cc b/db/version_set.cc
index 8fbf5a4..9b2feeb 100644
--- a/db/version_set.cc
+++ b/db/version_set.cc
@@ -4,20 +4,17 @@
 
 #include "db/version_set.h"
 
+#include <algorithm>
+#include <cstdio>
+
 #include "db/filename.h"
 #include "db/log_reader.h"
 #include "db/log_writer.h"
 #include "db/table_cache.h"
-#include <algorithm>
-
 #include "leveldb/env.h"
-#include "leveldb/iterator.h"
-#include "leveldb/options.h"
-#include "leveldb/table.h"
-
-#include "port/port_stdcxx.h"
 #include "table/merger.h"
 #include "table/two_level_iterator.h"
+#include "util/coding.h"
 #include "util/logging.h"
 
 namespace leveldb {
diff --git a/db/version_set.h b/db/version_set.h
index d55ff94..01e35c9 100644
--- a/db/version_set.h
+++ b/db/version_set.h
@@ -15,12 +15,14 @@
 #ifndef STORAGE_LEVELDB_DB_VERSION_SET_H_
 #define STORAGE_LEVELDB_DB_VERSION_SET_H_
 
+#include <map>
+#include <set>
+#include <vector>
+
+#include "db/dbformat.h"
 #include "db/version_edit.h"
-
 #include "leveldb/options.h"
-#include "leveldb/status.h"
-
-#include "port/port_stdcxx.h"
+#include "port/port.h"
 #include "port/thread_annotations.h"
 
 namespace leveldb {
diff --git a/db/version_set_test.cc b/db/version_set_test.cc
index c6f3063..b2353a5 100644
--- a/db/version_set_test.cc
+++ b/db/version_set_test.cc
@@ -4,9 +4,8 @@
 
 #include "db/version_set.h"
 
-#include <gtest/gtest_pred_impl.h>
-
-#include "version_edit.h"
+#include "gtest/gtest.h"
+#include "util/logging.h"
 
 namespace leveldb {
 
diff --git a/db/write_batch.cc b/db/write_batch.cc
index 366a3b6..ea81aa0 100644
--- a/db/write_batch.cc
+++ b/db/write_batch.cc
@@ -13,10 +13,12 @@
 //    len: varint32
 //    data: uint8[len]
 
+#include "leveldb/write_batch.h"
+
+#include "db/dbformat.h"
 #include "db/memtable.h"
 #include "db/write_batch_internal.h"
-
-#include "leveldb/status.h"
+#include "util/coding.h"
 
 namespace leveldb {
 
diff --git a/db/write_batch_test.cc b/db/write_batch_test.cc
index affc568..b96b928 100644
--- a/db/write_batch_test.cc
+++ b/db/write_batch_test.cc
@@ -2,16 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "gtest/gtest.h"
 #include "db/memtable.h"
 #include "db/write_batch_internal.h"
-
-#include "leveldb/iterator.h"
-#include "leveldb/status.h"
-
 #include "util/logging.h"
 
-#include "gtest/gtest.h"
-
 namespace leveldb {
 
 static std::string PrintContents(WriteBatch* b) {
diff --git a/helpers/memenv/memenv.cc b/helpers/memenv/memenv.cc
index 927bac1..5b2d59e 100644
--- a/helpers/memenv/memenv.cc
+++ b/helpers/memenv/memenv.cc
@@ -2,11 +2,16 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "helpers/memenv/memenv.h"
+
 #include <cstring>
 #include <map>
+#include <string>
+#include <vector>
 
 #include "leveldb/env.h"
-
+#include "leveldb/status.h"
+#include "port/thread_annotations.h"
 #include "util/mutexlock.h"
 
 namespace leveldb {
diff --git a/helpers/memenv/memenv_test.cc b/helpers/memenv/memenv_test.cc
index 800b08e..909a0ca 100644
--- a/helpers/memenv/memenv_test.cc
+++ b/helpers/memenv/memenv_test.cc
@@ -2,10 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "helpers/memenv/memenv.h"
+
+#include <string>
+#include <vector>
+
+#include "gtest/gtest.h"
 #include "db/db_impl.h"
-
-#include "leveldb/iterator.h"
-
+#include "leveldb/db.h"
+#include "leveldb/env.h"
 #include "util/testutil.h"
 
 namespace leveldb {
diff --git a/include/leveldb/cache.h b/include/leveldb/cache.h
index 92853b9..a94c683 100644
--- a/include/leveldb/cache.h
+++ b/include/leveldb/cache.h
@@ -19,7 +19,6 @@
 #define STORAGE_LEVELDB_INCLUDE_CACHE_H_
 
 #include <cstdint>
-#include <cstddef>
 
 #include "leveldb/export.h"
 #include "leveldb/slice.h"
diff --git a/include/leveldb/db.h b/include/leveldb/db.h
index 7ff06c1..9fe5c29 100644
--- a/include/leveldb/db.h
+++ b/include/leveldb/db.h
@@ -5,10 +5,10 @@
 #ifndef STORAGE_LEVELDB_INCLUDE_DB_H_
 #define STORAGE_LEVELDB_INCLUDE_DB_H_
 
-#include "leveldb/iterator.h"
+#include <cstdint>
 
-#include "slice.h"
-#include "status.h"
+#include "leveldb/export.h"
+#include "leveldb/iterator.h"
 
 namespace leveldb {
 
diff --git a/include/leveldb/dumpfile.h b/include/leveldb/dumpfile.h
index f58374d..a58bc6b 100644
--- a/include/leveldb/dumpfile.h
+++ b/include/leveldb/dumpfile.h
@@ -9,6 +9,7 @@
 
 #include "leveldb/env.h"
 #include "leveldb/export.h"
+#include "leveldb/status.h"
 
 namespace leveldb {
 
diff --git a/include/leveldb/env.h b/include/leveldb/env.h
index 9f94b31..e00895a 100644
--- a/include/leveldb/env.h
+++ b/include/leveldb/env.h
@@ -14,8 +14,11 @@
 #define STORAGE_LEVELDB_INCLUDE_ENV_H_
 
 #include <cstdarg>
+#include <cstdint>
+#include <string>
 #include <vector>
 
+#include "leveldb/export.h"
 #include "leveldb/status.h"
 
 // This workaround can be removed when leveldb::Env::DeleteFile is removed.
diff --git a/include/leveldb/iterator.h b/include/leveldb/iterator.h
index 895937f..bb9a5df 100644
--- a/include/leveldb/iterator.h
+++ b/include/leveldb/iterator.h
@@ -15,8 +15,6 @@
 #ifndef STORAGE_LEVELDB_INCLUDE_ITERATOR_H_
 #define STORAGE_LEVELDB_INCLUDE_ITERATOR_H_
 
-#include <assert.h>
-
 #include "leveldb/export.h"
 #include "leveldb/slice.h"
 #include "leveldb/status.h"
diff --git a/include/leveldb/slice.h b/include/leveldb/slice.h
index 163120f..37cb821 100644
--- a/include/leveldb/slice.h
+++ b/include/leveldb/slice.h
@@ -16,6 +16,7 @@
 #define STORAGE_LEVELDB_INCLUDE_SLICE_H_
 
 #include <cassert>
+#include <cstddef>
 #include <cstring>
 #include <string>
 
diff --git a/include/leveldb/status.h b/include/leveldb/status.h
index b38f312..822328a 100644
--- a/include/leveldb/status.h
+++ b/include/leveldb/status.h
@@ -13,6 +13,9 @@
 #ifndef STORAGE_LEVELDB_INCLUDE_STATUS_H_
 #define STORAGE_LEVELDB_INCLUDE_STATUS_H_
 
+#include <string>
+
+#include "leveldb/export.h"
 #include "leveldb/slice.h"
 
 namespace leveldb {
diff --git a/include/leveldb/table.h b/include/leveldb/table.h
index c160eb8..a30e903 100644
--- a/include/leveldb/table.h
+++ b/include/leveldb/table.h
@@ -10,8 +10,6 @@
 #include "leveldb/export.h"
 #include "leveldb/iterator.h"
 
-#include "status.h"
-
 namespace leveldb {
 
 class Block;
diff --git a/include/leveldb/table_builder.h b/include/leveldb/table_builder.h
index 7b26218..85710c3 100644
--- a/include/leveldb/table_builder.h
+++ b/include/leveldb/table_builder.h
@@ -13,6 +13,9 @@
 #ifndef STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_
 #define STORAGE_LEVELDB_INCLUDE_TABLE_BUILDER_H_
 
+#include <cstdint>
+
+#include "leveldb/export.h"
 #include "leveldb/options.h"
 #include "leveldb/status.h"
 
diff --git a/port/port.h b/port/port.h
index ff972a0..e6ee941 100644
--- a/port/port.h
+++ b/port/port.h
@@ -9,6 +9,7 @@
 // porting to a new platform, see "port_example.h" for documentation
 // of what the new port_<platform>.h file must provide.
 #if defined(LEVELDB_PLATFORM_POSIX) || defined(LEVELDB_PLATFORM_WINDOWS)
+#include "port/port_stdcxx.h"
 #elif defined(LEVELDB_PLATFORM_CHROMIUM)
 #include "port/port_chromium.h"
 #endif
diff --git a/port/port_stdcxx.h b/port/port_stdcxx.h
index 41e7958..2bda48d 100644
--- a/port/port_stdcxx.h
+++ b/port/port_stdcxx.h
@@ -31,6 +31,10 @@
 
 #include <cassert>
 #include <condition_variable>  // NOLINT
+#include <cstddef>
+#include <cstdint>
+#include <mutex>  // NOLINT
+#include <string>
 
 #include "port/thread_annotations.h"
 
diff --git a/table/block.cc b/table/block.cc
index e443198..09f05f3 100644
--- a/table/block.cc
+++ b/table/block.cc
@@ -6,10 +6,10 @@
 
 #include "table/block.h"
 
-#include "leveldb/comparator.h"
-#include "leveldb/iterator.h"
-#include "leveldb/status.h"
+#include <cstdint>
+#include <vector>
 
+#include "leveldb/comparator.h"
 #include "table/format.h"
 #include "util/coding.h"
 
diff --git a/table/block_builder.cc b/table/block_builder.cc
index e6cb522..37d4008 100644
--- a/table/block_builder.cc
+++ b/table/block_builder.cc
@@ -28,9 +28,11 @@
 
 #include "table/block_builder.h"
 
-#include "leveldb/options.h"
-#include "leveldb/slice.h"
+#include <algorithm>
+#include <cassert>
 
+#include "leveldb/comparator.h"
+#include "leveldb/options.h"
 #include "util/coding.h"
 
 namespace leveldb {
diff --git a/table/block_builder.h b/table/block_builder.h
index f14a0d6..7a481cd 100644
--- a/table/block_builder.h
+++ b/table/block_builder.h
@@ -6,7 +6,6 @@
 #define STORAGE_LEVELDB_TABLE_BLOCK_BUILDER_H_
 
 #include <cstdint>
-#include <string>
 #include <vector>
 
 #include "leveldb/slice.h"
diff --git a/table/filter_block.h b/table/filter_block.h
index 31a3968..aa0de87 100644
--- a/table/filter_block.h
+++ b/table/filter_block.h
@@ -9,6 +9,9 @@
 #ifndef STORAGE_LEVELDB_TABLE_FILTER_BLOCK_H_
 #define STORAGE_LEVELDB_TABLE_FILTER_BLOCK_H_
 
+#include <cstddef>
+#include <cstdint>
+#include <string>
 #include <vector>
 
 #include "leveldb/slice.h"
diff --git a/table/filter_block_test.cc b/table/filter_block_test.cc
index d6a6398..b54b5b4 100644
--- a/table/filter_block_test.cc
+++ b/table/filter_block_test.cc
@@ -4,14 +4,12 @@
 
 #include "table/filter_block.h"
 
+#include "gtest/gtest.h"
 #include "leveldb/filter_policy.h"
-
 #include "util/coding.h"
 #include "util/hash.h"
 #include "util/logging.h"
 
-#include "gtest/gtest.h"
-
 namespace leveldb {
 
 // For testing: emit an array with one hash value per key
diff --git a/table/format.cc b/table/format.cc
index 7206fe3..5ea6b6f 100644
--- a/table/format.cc
+++ b/table/format.cc
@@ -6,8 +6,7 @@
 
 #include "leveldb/env.h"
 #include "leveldb/options.h"
-
-#include "port/port_stdcxx.h"
+#include "port/port.h"
 #include "util/coding.h"
 #include "util/crc32c.h"
 
diff --git a/table/format.h b/table/format.h
index 15065d6..1fc873d 100644
--- a/table/format.h
+++ b/table/format.h
@@ -5,6 +5,9 @@
 #ifndef STORAGE_LEVELDB_TABLE_FORMAT_H_
 #define STORAGE_LEVELDB_TABLE_FORMAT_H_
 
+#include <cstdint>
+#include <string>
+
 #include "leveldb/slice.h"
 #include "leveldb/status.h"
 
diff --git a/table/iterator.cc b/table/iterator.cc
index 8edf7fd..dfef083 100644
--- a/table/iterator.cc
+++ b/table/iterator.cc
@@ -4,8 +4,6 @@
 
 #include "leveldb/iterator.h"
 
-#include "leveldb/status.h"
-
 namespace leveldb {
 
 Iterator::Iterator() {
diff --git a/table/iterator_wrapper.h b/table/iterator_wrapper.h
index f5deace..c230572 100644
--- a/table/iterator_wrapper.h
+++ b/table/iterator_wrapper.h
@@ -6,7 +6,7 @@
 #define STORAGE_LEVELDB_TABLE_ITERATOR_WRAPPER_H_
 
 #include "leveldb/iterator.h"
-#include "leveldb/status.h"
+#include "leveldb/slice.h"
 
 namespace leveldb {
 
diff --git a/table/merger.cc b/table/merger.cc
index 449024f..76441b1 100644
--- a/table/merger.cc
+++ b/table/merger.cc
@@ -2,8 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#include "leveldb/comparator.h"
+#include "table/merger.h"
 
+#include "leveldb/comparator.h"
+#include "leveldb/iterator.h"
 #include "table/iterator_wrapper.h"
 
 namespace leveldb {
diff --git a/table/table.cc b/table/table.cc
index e6df04c..29e835f 100644
--- a/table/table.cc
+++ b/table/table.cc
@@ -8,9 +8,7 @@
 #include "leveldb/comparator.h"
 #include "leveldb/env.h"
 #include "leveldb/filter_policy.h"
-#include "leveldb/iterator.h"
 #include "leveldb/options.h"
-
 #include "table/block.h"
 #include "table/filter_block.h"
 #include "table/format.h"
diff --git a/table/table_builder.cc b/table/table_builder.cc
index 915e1c3..1e98f97 100644
--- a/table/table_builder.cc
+++ b/table/table_builder.cc
@@ -4,16 +4,18 @@
 
 #include "leveldb/table_builder.h"
 
+#include <cassert>
+
 #include "leveldb/comparator.h"
 #include "leveldb/env.h"
 #include "leveldb/filter_policy.h"
-
-#include "port/port_stdcxx.h"
+#include "leveldb/options.h"
 #include "table/block_builder.h"
 #include "table/filter_block.h"
 #include "table/format.h"
 #include "util/coding.h"
 #include "util/crc32c.h"
+#include "port/port.h"
 
 namespace leveldb {
 
diff --git a/table/table_test.cc b/table/table_test.cc
index 11b2b50..456c14b 100644
--- a/table/table_test.cc
+++ b/table/table_test.cc
@@ -4,20 +4,24 @@
 
 #include "leveldb/table.h"
 
+#include <map>
+#include <string>
+
+#include "gtest/gtest.h"
+#include "db/dbformat.h"
 #include "db/memtable.h"
 #include "db/write_batch_internal.h"
-#include <cstring>
-
 #include "leveldb/db.h"
+#include "leveldb/env.h"
 #include "leveldb/iterator.h"
 #include "leveldb/table_builder.h"
-
-#include "port/port_stdcxx.h"
 #include "table/block.h"
 #include "table/block_builder.h"
 #include "table/format.h"
-#include "util/logging.h"
+#include "util/random.h"
 #include "util/testutil.h"
+#include "util/logging.h"
+#include "port/port.h"
 
 namespace leveldb {
 
diff --git a/table/two_level_iterator.cc b/table/two_level_iterator.cc
index c2125c0..e0a35e5 100644
--- a/table/two_level_iterator.cc
+++ b/table/two_level_iterator.cc
@@ -2,8 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#include "leveldb/options.h"
+#include "table/two_level_iterator.h"
 
+#include "leveldb/options.h"
 #include "table/iterator_wrapper.h"
 
 namespace leveldb {
diff --git a/table/two_level_iterator.h b/table/two_level_iterator.h
index e3a5eb7..81ffe80 100644
--- a/table/two_level_iterator.h
+++ b/table/two_level_iterator.h
@@ -6,7 +6,6 @@
 #define STORAGE_LEVELDB_TABLE_TWO_LEVEL_ITERATOR_H_
 
 #include "leveldb/iterator.h"
-#include "leveldb/slice.h"
 
 namespace leveldb {
 
diff --git a/util/arena.cc b/util/arena.cc
index 28aaf17..46e3b2e 100644
--- a/util/arena.cc
+++ b/util/arena.cc
@@ -4,10 +4,6 @@
 
 #include "util/arena.h"
 
-#include <cassert>
-#include <atomic>
-#include <vector>
-
 namespace leveldb {
 
 static const int kBlockSize = 4096;
diff --git a/util/arena.h b/util/arena.h
index a9340af..0f76ac7 100644
--- a/util/arena.h
+++ b/util/arena.h
@@ -5,8 +5,9 @@
 #ifndef STORAGE_LEVELDB_UTIL_ARENA_H_
 #define STORAGE_LEVELDB_UTIL_ARENA_H_
 
-#include <cassert>
 #include <atomic>
+#include <cassert>
+#include <cstddef>
 #include <vector>
 
 namespace leveldb {
diff --git a/util/bloom_test.cc b/util/bloom_test.cc
index b688144..1d2f9cd 100644
--- a/util/bloom_test.cc
+++ b/util/bloom_test.cc
@@ -2,12 +2,9 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#include "leveldb/filter_policy.h"
-#include "leveldb/slice.h"
-
-#include "util/coding.h"
-
 #include "gtest/gtest.h"
+#include "leveldb/filter_policy.h"
+#include "util/coding.h"
 
 namespace leveldb {
 
diff --git a/util/cache.cc b/util/cache.cc
index 42b14d5..762fa61 100644
--- a/util/cache.cc
+++ b/util/cache.cc
@@ -4,10 +4,10 @@
 
 #include "leveldb/cache.h"
 
-#include <cstring>
-
-#include "leveldb/slice.h"
+#include <cassert>
+#include <cstdlib>
 
+#include "port/thread_annotations.h"
 #include "util/hash.h"
 #include "util/mutexlock.h"
 
diff --git a/util/cache_test.cc b/util/cache_test.cc
index 3d54a03..e68da34 100644
--- a/util/cache_test.cc
+++ b/util/cache_test.cc
@@ -4,11 +4,10 @@
 
 #include "leveldb/cache.h"
 
-#include "leveldb/slice.h"
-
-#include "util/coding.h"
+#include <vector>
 
 #include "gtest/gtest.h"
+#include "util/coding.h"
 
 namespace leveldb {
 
diff --git a/util/coding.cc b/util/coding.cc
index 390eb3a..a8f8af8 100644
--- a/util/coding.cc
+++ b/util/coding.cc
@@ -4,8 +4,6 @@
 
 #include "util/coding.h"
 
-#include "leveldb/slice.h"
-
 namespace leveldb {
 
 void PutFixed32(std::string* dst, uint32_t value) {
diff --git a/util/coding_test.cc b/util/coding_test.cc
index b617590..cceda14 100644
--- a/util/coding_test.cc
+++ b/util/coding_test.cc
@@ -4,9 +4,9 @@
 
 #include "util/coding.h"
 
-#include <gtest/gtest_pred_impl.h>
+#include <vector>
 
-#include "leveldb/slice.h"
+#include "gtest/gtest.h"
 
 namespace leveldb {
 
diff --git a/util/comparator.cc b/util/comparator.cc
index c67103b..7b0ab6a 100644
--- a/util/comparator.cc
+++ b/util/comparator.cc
@@ -4,8 +4,12 @@
 
 #include "leveldb/comparator.h"
 
-#include "leveldb/slice.h"
+#include <algorithm>
+#include <cstdint>
+#include <string>
+#include <type_traits>
 
+#include "leveldb/slice.h"
 #include "util/no_destructor.h"
 
 namespace leveldb {
diff --git a/util/crc32c.cc b/util/crc32c.cc
index 06cb846..3f18908 100644
--- a/util/crc32c.cc
+++ b/util/crc32c.cc
@@ -4,7 +4,12 @@
 //
 // A portable implementation of crc32c.
 
-#include "port/port_stdcxx.h"
+#include "util/crc32c.h"
+
+#include <cstddef>
+#include <cstdint>
+
+#include "port/port.h"
 #include "util/coding.h"
 
 namespace leveldb {
diff --git a/util/env_posix.cc b/util/env_posix.cc
index b1b473f..ffd06c4 100644
--- a/util/env_posix.cc
+++ b/util/env_posix.cc
@@ -8,14 +8,31 @@
 #ifndef __Fuchsia__
 #include <sys/resource.h>
 #endif
-#include <atomic>
-#include <cstring>
-#include <queue>
-#include <set>
 #include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
 #include <unistd.h>
 
-#include "port/port_stdcxx.h"
+#include <atomic>
+#include <cerrno>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <limits>
+#include <queue>
+#include <set>
+#include <string>
+#include <thread>
+#include <type_traits>
+#include <utility>
+
+#include "leveldb/env.h"
+#include "leveldb/slice.h"
+#include "leveldb/status.h"
+#include "port/port.h"
+#include "port/thread_annotations.h"
 #include "util/env_posix_test_helper.h"
 #include "util/posix_logger.h"
 
diff --git a/util/env_posix_test.cc b/util/env_posix_test.cc
index ce25a48..34bda62 100644
--- a/util/env_posix_test.cc
+++ b/util/env_posix_test.cc
@@ -2,11 +2,20 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#include <cstring>
-#include <port/port_config.h>
 #include <sys/resource.h>
-#include <unordered_set>
+#include <sys/wait.h>
+#include <unistd.h>
 
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <string>
+#include <unordered_set>
+#include <vector>
+
+#include "gtest/gtest.h"
+#include "leveldb/env.h"
+#include "port/port.h"
 #include "util/env_posix_test_helper.h"
 #include "util/testutil.h"
 
diff --git a/util/hash.cc b/util/hash.cc
index cb01b80..2027397 100644
--- a/util/hash.cc
+++ b/util/hash.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "util/hash.h"
+
 #include "util/coding.h"
 
 // The FALLTHROUGH_INTENDED macro can be used to annotate implicit fall-through
diff --git a/util/histogram.cc b/util/histogram.cc
index 66f495c..0f866fa 100644
--- a/util/histogram.cc
+++ b/util/histogram.cc
@@ -6,7 +6,6 @@
 
 #include <cmath>
 #include <cstdio>
-#include <string>
 
 namespace leveldb {
 
diff --git a/util/logging.cc b/util/logging.cc
index 34d4b2b..1605d10 100644
--- a/util/logging.cc
+++ b/util/logging.cc
@@ -2,10 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
+#include "util/logging.h"
+
 #include <cstdarg>
-#include <cstdint>
+#include <cstdio>
 #include <limits>
-#include <string>
 
 #include "leveldb/slice.h"
 
diff --git a/util/logging_test.cc b/util/logging_test.cc
index 4488c71..1746c57 100644
--- a/util/logging_test.cc
+++ b/util/logging_test.cc
@@ -4,8 +4,10 @@
 
 #include "util/logging.h"
 
-#include <gtest/gtest_pred_impl.h>
+#include <limits>
+#include <string>
 
+#include "gtest/gtest.h"
 #include "leveldb/slice.h"
 
 namespace leveldb {
diff --git a/util/mutexlock.h b/util/mutexlock.h
index e2b1633..0cb2e25 100644
--- a/util/mutexlock.h
+++ b/util/mutexlock.h
@@ -5,7 +5,8 @@
 #ifndef STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
 #define STORAGE_LEVELDB_UTIL_MUTEXLOCK_H_
 
-#include "port/port_stdcxx.h"
+#include "port/port.h"
+#include "port/thread_annotations.h"
 
 namespace leveldb {
 
diff --git a/util/no_destructor.h b/util/no_destructor.h
index b418547..a0d3b87 100644
--- a/util/no_destructor.h
+++ b/util/no_destructor.h
@@ -5,6 +5,7 @@
 #ifndef STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
 #define STORAGE_LEVELDB_UTIL_NO_DESTRUCTOR_H_
 
+#include <type_traits>
 #include <utility>
 
 namespace leveldb {
diff --git a/util/no_destructor_test.cc b/util/no_destructor_test.cc
index 7593f34..32b7ab8 100644
--- a/util/no_destructor_test.cc
+++ b/util/no_destructor_test.cc
@@ -4,6 +4,9 @@
 
 #include "util/no_destructor.h"
 
+#include <cstdint>
+#include <cstdlib>
+
 #include "gtest/gtest.h"
 
 namespace leveldb {
diff --git a/util/posix_logger.h b/util/posix_logger.h
index cd67235..6bbc1a0 100644
--- a/util/posix_logger.h
+++ b/util/posix_logger.h
@@ -8,9 +8,13 @@
 #ifndef STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_
 #define STORAGE_LEVELDB_UTIL_POSIX_LOGGER_H_
 
-#include <cstdarg>
-#include <sstream>
 #include <sys/time.h>
+
+#include <cassert>
+#include <cstdarg>
+#include <cstdio>
+#include <ctime>
+#include <sstream>
 #include <thread>
 
 #include "leveldb/env.h"
diff --git a/util/status.cc b/util/status.cc
index 294e12a..13ae9de 100644
--- a/util/status.cc
+++ b/util/status.cc
@@ -4,7 +4,7 @@
 
 #include "leveldb/status.h"
 
-#include <cstring>
+#include <cstdio>
 
 namespace leveldb {
 
diff --git a/util/status_test.cc b/util/status_test.cc
index 8466341..dbf5faa 100644
--- a/util/status_test.cc
+++ b/util/status_test.cc
@@ -4,7 +4,10 @@
 
 #include "leveldb/status.h"
 
+#include <utility>
+
 #include "gtest/gtest.h"
+#include "leveldb/slice.h"
 
 namespace leveldb {
 
diff --git a/util/testutil.cc b/util/testutil.cc
index 8eebda3..7e562f8 100644
--- a/util/testutil.cc
+++ b/util/testutil.cc
@@ -2,9 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file. See the AUTHORS file for names of contributors.
 
-#include "leveldb/slice.h"
+#include "util/testutil.h"
+
+#include <string>
 
 #include "util/random.h"
+#include "leveldb/slice.h"
 
 namespace leveldb {
 namespace test {
diff --git a/util/testutil.h b/util/testutil.h
index 55d443d..e0e2d64 100644
--- a/util/testutil.h
+++ b/util/testutil.h
@@ -5,11 +5,11 @@
 #ifndef STORAGE_LEVELDB_UTIL_TESTUTIL_H_
 #define STORAGE_LEVELDB_UTIL_TESTUTIL_H_
 
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
 #include "helpers/memenv/memenv.h"
-#include <gmock/gmock-matchers.h>
-
 #include "leveldb/env.h"
-
+#include "leveldb/slice.h"
 #include "util/random.h"
 
 namespace leveldb {