From 9d7cc2bedc55b1d1327645b9c816eea3bcd5d658 Mon Sep 17 00:00:00 2001
From: archshift <admin@archshift.com>
Date: Mon, 8 Sep 2014 17:16:32 -0700
Subject: [PATCH 1/2] common: Prune all redundant includes

---
 src/common/console_listener.cpp | 6 +-----
 src/common/file_search.cpp      | 4 +---
 src/common/file_util.cpp        | 7 -------
 src/common/log_manager.cpp      | 1 -
 src/common/math_util.cpp        | 3 +--
 src/common/mem_arena.cpp        | 4 ----
 src/common/memory_util.cpp      | 3 ---
 src/common/string_util.cpp      | 4 ----
 src/common/thread.cpp           | 1 -
 src/common/utf8.cpp             | 4 ----
 10 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp
index 27697ef1f..6a89edd44 100644
--- a/src/common/console_listener.cpp
+++ b/src/common/console_listener.cpp
@@ -3,14 +3,10 @@
 // Refer to the license.txt file included.
 
 #include <algorithm>
-#include <cmath>
-#include <cstdio>
-#include <string>
+
 #ifdef _WIN32
 #include <windows.h>
 #include <array>
-#else
-#include <cstdarg>
 #endif
 
 #include "common/common.h"
diff --git a/src/common/file_search.cpp b/src/common/file_search.cpp
index a9d19477d..cd50ace75 100644
--- a/src/common/file_search.cpp
+++ b/src/common/file_search.cpp
@@ -4,15 +4,13 @@
 
 
 #include "common/common.h"
-#include "common/common_paths.h"
+
 #ifndef _WIN32
-#include <sys/types.h>
 #include <dirent.h>
 #else
 #include <windows.h>
 #endif
 
-#include <string>
 #include <algorithm>
 
 #include "common/file_search.h"
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index b6ff2e40b..04d222ca1 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -4,9 +4,7 @@
 
 
 #include "common/common.h"
-#include "common/common_paths.h"
 #include "common/file_util.h"
-#include "common/string_util.h"
 
 #ifdef _WIN32
 #include <windows.h>
@@ -16,10 +14,7 @@
 #include <io.h>
 #include <direct.h>        // getcwd
 #else
-#include <cerrno>
-#include <cstdlib>
 #include <sys/param.h>
-#include <sys/types.h>
 #include <dirent.h>
 #endif
 
@@ -32,8 +27,6 @@
 #include <algorithm>
 #include <sys/stat.h>
 
-#include "common/string_util.h"
-
 #ifndef S_ISDIR
 #define S_ISDIR(m)  (((m)&S_IFMT) == S_IFDIR)
 #endif
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp
index 4e1cb60bd..c2b5d0e2c 100644
--- a/src/common/log_manager.cpp
+++ b/src/common/log_manager.cpp
@@ -8,7 +8,6 @@
 #include "common/console_listener.h"
 #include "common/timer.h"
 #include "common/thread.h"
-#include "common/file_util.h"
 
 void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, 
     const char* function, const char* fmt, ...)
diff --git a/src/common/math_util.cpp b/src/common/math_util.cpp
index 82eceab00..ab0e6b75c 100644
--- a/src/common/math_util.cpp
+++ b/src/common/math_util.cpp
@@ -6,8 +6,7 @@
 #include "common/common.h"
 #include "common/math_util.h"
 
-#include <cmath>
-#include <numeric>
+#include <numeric> // Necessary on OS X, but not Linux
 
 namespace MathUtil
 {
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index b76ac92d3..a456beb28 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -22,11 +22,7 @@
 #include "common/string_util.h"
 
 #ifndef _WIN32
-#include <sys/stat.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <cerrno>
-#include <cstring>
 #ifdef ANDROID
 #include <sys/ioctl.h>
 #include <linux/ashmem.h>
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index e01e63175..45bf5a496 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -10,9 +10,6 @@
 #ifdef _WIN32
 #include <windows.h>
 #include <psapi.h>
-#else
-#include <cerrno>
-#include <cstdio>
 #endif
 
 #if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index c1f22bda3..a3c7f479e 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -3,17 +3,13 @@
 // Refer to the license.txt file included.
 
 #include <algorithm>
-#include <cstdlib>
-#include <cstdio>
 
 #include "common/common.h"
-#include "common/common_paths.h"
 #include "common/string_util.h"
 
 #ifdef _WIN32
     #include <Windows.h>
 #else
-    #include <cerrno>
     #include <iconv.h>
 #endif
 
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index 830795182..60d8ed075 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -3,7 +3,6 @@
 // Refer to the license.txt file included.
 
 #include "common/thread.h"
-#include "common/common.h"
 
 #ifdef __APPLE__
 #include <mach/mach.h>
diff --git a/src/common/utf8.cpp b/src/common/utf8.cpp
index c83824d35..be4ebc855 100644
--- a/src/common/utf8.cpp
+++ b/src/common/utf8.cpp
@@ -19,12 +19,8 @@
 #endif
 
 #include <cstdlib>
-#include <cstdio>
 #include <cstring>
-#include <cstdarg>
-
 #include <algorithm>
-#include <string>
 
 #include "common/common_types.h"
 #include "common/utf8.h"

From 6e606c515f56b456a8031b235fd4f8d8453483a4 Mon Sep 17 00:00:00 2001
From: archshift <admin@archshift.com>
Date: Mon, 8 Sep 2014 17:52:00 -0700
Subject: [PATCH 2/2] core: Prune redundant includes

---
 src/core/arm/disassembler/load_symbol_map.cpp | 1 -
 src/core/core.cpp                             | 6 ------
 src/core/hle/config_mem.cpp                   | 1 -
 src/core/hle/coprocessor.cpp                  | 1 -
 src/core/hle/hle.cpp                          | 1 -
 src/core/hle/kernel/archive.cpp               | 1 -
 src/core/hle/kernel/kernel.cpp                | 2 --
 src/core/hle/kernel/thread.cpp                | 3 ---
 src/core/hle/service/fs.cpp                   | 2 --
 src/core/hle/service/gsp.cpp                  | 1 -
 src/core/hle/service/ndm.cpp                  | 2 --
 src/core/hle/service/service.cpp              | 5 -----
 src/core/hle/service/srv.cpp                  | 1 -
 src/core/hle/svc.cpp                          | 3 ---
 src/core/hw/gpu.cpp                           | 2 --
 src/core/hw/hw.cpp                            | 1 -
 src/core/hw/ndma.cpp                          | 1 -
 src/core/loader/loader.cpp                    | 1 -
 src/core/mem_map.cpp                          | 1 -
 src/core/mem_map_funcs.cpp                    | 1 -
 20 files changed, 37 deletions(-)

diff --git a/src/core/arm/disassembler/load_symbol_map.cpp b/src/core/arm/disassembler/load_symbol_map.cpp
index d7fc0a042..f156c43ce 100644
--- a/src/core/arm/disassembler/load_symbol_map.cpp
+++ b/src/core/arm/disassembler/load_symbol_map.cpp
@@ -6,7 +6,6 @@
 #include <vector>
 
 #include "common/symbols.h"
-#include "common/common_types.h"
 #include "common/file_util.h"
 
 #include "core/arm/disassembler/load_symbol_map.h"
diff --git a/src/core/core.cpp b/src/core/core.cpp
index f21801e52..01d4f0afa 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -3,15 +3,9 @@
 // Refer to the license.txt file included.
 
 #include "common/common_types.h"
-#include "common/log.h"
-#include "common/symbols.h"
-
-#include "video_core/video_core.h"
 
 #include "core/core.h"
-#include "core/mem_map.h"
 #include "core/hw/hw.h"
-#include "core/hw/gpu.h"
 #include "core/arm/disassembler/arm_disasm.h"
 #include "core/arm/interpreter/arm_interpreter.h"
 
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index 8c898b265..a45e61427 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.cpp
@@ -3,7 +3,6 @@
 // Refer to the license.txt file included.  
 
 #include "common/common_types.h"
-#include "common/log.h"
 
 #include "core/hle/config_mem.h"
 
diff --git a/src/core/hle/coprocessor.cpp b/src/core/hle/coprocessor.cpp
index 9a5b0deda..1eb33eb86 100644
--- a/src/core/hle/coprocessor.cpp
+++ b/src/core/hle/coprocessor.cpp
@@ -5,7 +5,6 @@
 #include "core/hle/coprocessor.h"
 #include "core/hle/hle.h"
 #include "core/mem_map.h"
-#include "core/core.h"
 
 namespace HLE {
 
diff --git a/src/core/hle/hle.cpp b/src/core/hle/hle.cpp
index 53cda4a61..b03894ad7 100644
--- a/src/core/hle/hle.cpp
+++ b/src/core/hle/hle.cpp
@@ -6,7 +6,6 @@
 
 #include "core/mem_map.h"
 #include "core/hle/hle.h"
-#include "core/hle/svc.h"
 #include "core/hle/kernel/thread.h"
 #include "core/hle/service/service.h"
 
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index 1596367c3..20536f40f 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -7,7 +7,6 @@
 
 #include "core/file_sys/archive.h"
 #include "core/hle/service/service.h"
-#include "core/hle/kernel/kernel.h"
 #include "core/hle/kernel/archive.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index a4a258875..e56f1879e 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -2,8 +2,6 @@
 // Licensed under GPLv2
 // Refer to the license.txt file included.  
 
-#include <string.h>
-
 #include "common/common.h"
 
 #include "core/core.h"
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 8bd9ca1a1..33c0b2a47 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -3,10 +3,8 @@
 // Refer to the license.txt file included.  
 
 #include <algorithm>
-#include <cstdio>
 #include <list>
 #include <map>
-#include <string>
 #include <vector>
 
 #include "common/common.h"
@@ -15,7 +13,6 @@
 #include "core/core.h"
 #include "core/mem_map.h"
 #include "core/hle/hle.h"
-#include "core/hle/svc.h"
 #include "core/hle/kernel/kernel.h"
 #include "core/hle/kernel/thread.h"
 
diff --git a/src/core/hle/service/fs.cpp b/src/core/hle/service/fs.cpp
index 5eabf36ad..9e1998b0f 100644
--- a/src/core/hle/service/fs.cpp
+++ b/src/core/hle/service/fs.cpp
@@ -4,8 +4,6 @@
 
 #include "common/common.h"
 
-#include "core/loader/loader.h"
-#include "core/hle/hle.h"
 #include "core/hle/service/fs.h"
 #include "core/hle/kernel/archive.h"
 
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp
index 46c5a8ddd..accbe84e3 100644
--- a/src/core/hle/service/gsp.cpp
+++ b/src/core/hle/service/gsp.cpp
@@ -7,7 +7,6 @@
 #include "common/bit_field.h"
 
 #include "core/mem_map.h"
-#include "core/hle/hle.h"
 #include "core/hle/kernel/event.h"
 #include "core/hle/kernel/shared_memory.h"
 #include "core/hle/service/gsp.h"
diff --git a/src/core/hle/service/ndm.cpp b/src/core/hle/service/ndm.cpp
index 48755b6a7..f6af0a153 100644
--- a/src/core/hle/service/ndm.cpp
+++ b/src/core/hle/service/ndm.cpp
@@ -2,8 +2,6 @@
 // Licensed under GPLv2
 // Refer to the license.txt file included.
 
-#include "common/log.h"
-
 #include "core/hle/hle.h"
 #include "core/hle/service/ndm.h"
 
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 00ac1c9c6..9eb1726aa 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -3,11 +3,8 @@
 // Refer to the license.txt file included.
 
 #include "common/common.h"
-#include "common/log.h"
 #include "common/string_util.h"
 
-#include "core/hle/hle.h"
-
 #include "core/hle/service/service.h"
 #include "core/hle/service/apt.h"
 #include "core/hle/service/fs.h"
@@ -16,8 +13,6 @@
 #include "core/hle/service/ndm.h"
 #include "core/hle/service/srv.h"
 
-#include "core/hle/kernel/kernel.h"
-
 namespace Service {
 
 Manager* g_manager = nullptr;  ///< Service manager
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index 23be3cf2c..eb2c73f93 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -4,7 +4,6 @@
 
 #include "core/hle/hle.h"
 #include "core/hle/service/srv.h"
-#include "core/hle/service/service.h"
 #include "core/hle/kernel/event.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index bdcfae6f5..07a750b89 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -3,7 +3,6 @@
 // Refer to the license.txt file included.  
 
 #include <map>
-#include <string>
 
 #include "common/string_util.h"
 #include "common/symbols.h"
@@ -12,13 +11,11 @@
 
 #include "core/hle/kernel/address_arbiter.h"
 #include "core/hle/kernel/event.h"
-#include "core/hle/kernel/kernel.h"
 #include "core/hle/kernel/mutex.h"
 #include "core/hle/kernel/shared_memory.h"
 #include "core/hle/kernel/thread.h"
 
 #include "core/hle/function_wrappers.h"
-#include "core/hle/svc.h"
 #include "core/hle/service/service.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index 8709b8eb7..2e0943776 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -3,13 +3,11 @@
 // Refer to the license.txt file included.
 
 #include "common/common_types.h"
-#include "common/log.h"
 
 #include "core/core.h"
 #include "core/mem_map.h"
 
 #include "core/hle/hle.h"
-#include "core/hle/kernel/thread.h"
 #include "core/hle/service/gsp.h"
 
 #include "core/hw/gpu.h"
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index ed70486e6..efd94f147 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -3,7 +3,6 @@
 // Refer to the license.txt file included.
 
 #include "common/common_types.h"
-#include "common/log.h"
 
 #include "core/hw/hw.h"
 #include "core/hw/gpu.h"
diff --git a/src/core/hw/ndma.cpp b/src/core/hw/ndma.cpp
index f6aa72d16..158241fd6 100644
--- a/src/core/hw/ndma.cpp
+++ b/src/core/hw/ndma.cpp
@@ -3,7 +3,6 @@
 // Refer to the license.txt file included.
 
 #include "common/common_types.h"
-#include "common/log.h"
 
 #include "core/hw/ndma.h"
 
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 365f5a277..5cbb26f54 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -5,7 +5,6 @@
 #include <memory>
 
 #include "core/file_sys/archive_romfs.h"
-#include "core/loader/loader.h"
 #include "core/loader/elf.h"
 #include "core/loader/ncch.h"
 #include "core/hle/kernel/archive.h"
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index 14fc01471..cf12f24d9 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -6,7 +6,6 @@
 #include "common/mem_arena.h"
 
 #include "core/mem_map.h"
-#include "core/core.h"
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index 391b75fc2..f510df835 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -8,7 +8,6 @@
 
 #include "core/mem_map.h"
 #include "core/hw/hw.h"
-#include "hle/hle.h"
 #include "hle/config_mem.h"
 
 namespace Memory {