summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt7
-rw-r--r--src/citra/citra.cpp4
-rw-r--r--src/citra/config.cpp3
-rw-r--r--src/citra/emu_window/emu_window_glfw.cpp2
-rw-r--r--src/citra_qt/bootmanager.cpp1
-rw-r--r--src/citra_qt/bootmanager.h1
-rw-r--r--src/citra_qt/debugger/disassembler.cpp1
-rw-r--r--src/citra_qt/debugger/disassembler.h2
-rw-r--r--src/citra_qt/debugger/graphics_breakpoints.cpp2
-rw-r--r--src/citra_qt/debugger/ramview.cpp3
-rw-r--r--src/citra_qt/main.cpp3
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/assert.h1
-rw-r--r--src/common/bit_field.h2
-rw-r--r--src/common/break_points.cpp1
-rw-r--r--src/common/break_points.h2
-rw-r--r--src/common/chunk_file.h3
-rw-r--r--src/common/common.h120
-rw-r--r--src/common/common_funcs.h82
-rw-r--r--src/common/common_paths.h3
-rw-r--r--src/common/common_types.h15
-rw-r--r--src/common/concurrent_ring_buffer.h2
-rw-r--r--src/common/emu_window.h6
-rw-r--r--src/common/file_util.cpp54
-rw-r--r--src/common/file_util.h2
-rw-r--r--src/common/hash.cpp3
-rw-r--r--src/common/hash.h2
-rw-r--r--src/common/linear_disk_cache.h2
-rw-r--r--src/common/logging/text_formatter.cpp1
-rw-r--r--src/common/math_util.cpp6
-rw-r--r--src/common/math_util.h2
-rw-r--r--src/common/mem_arena.cpp6
-rw-r--r--src/common/mem_arena.h2
-rw-r--r--src/common/memory_util.cpp3
-rw-r--r--src/common/misc.cpp4
-rw-r--r--src/common/platform.h57
-rw-r--r--src/common/profiler.cpp1
-rw-r--r--src/common/string_util.cpp4
-rw-r--r--src/common/string_util.h2
-rw-r--r--src/common/symbols.h4
-rw-r--r--src/common/thread.h1
-rw-r--r--src/common/thread_queue_list.h2
-rw-r--r--src/common/thunk.h2
-rw-r--r--src/common/timer.cpp4
-rw-r--r--src/common/timer.h2
-rw-r--r--src/core/CMakeLists.txt1
-rw-r--r--src/core/arm/arm_interface.h1
-rw-r--r--src/core/arm/dyncom/arm_dyncom.cpp2
-rw-r--r--src/core/arm/interpreter/armsupp.cpp2
-rw-r--r--src/core/arm/skyeye_common/armmmu.h2
-rw-r--r--src/core/arm/skyeye_common/vfp/vfp.cpp1
-rw-r--r--src/core/core.cpp1
-rw-r--r--src/core/core_timing.h2
-rw-r--r--src/core/file_sys/archive_backend.cpp127
-rw-r--r--src/core/file_sys/archive_backend.h147
-rw-r--r--src/core/file_sys/archive_extsavedata.cpp1
-rw-r--r--src/core/file_sys/archive_romfs.cpp1
-rw-r--r--src/core/file_sys/archive_savedata.cpp1
-rw-r--r--src/core/file_sys/archive_savedatacheck.cpp1
-rw-r--r--src/core/file_sys/archive_sdmc.cpp1
-rw-r--r--src/core/file_sys/directory_backend.h3
-rw-r--r--src/core/file_sys/disk_archive.cpp1
-rw-r--r--src/core/file_sys/disk_archive.h2
-rw-r--r--src/core/file_sys/file_backend.h2
-rw-r--r--src/core/file_sys/ivfc_archive.cpp1
-rw-r--r--src/core/file_sys/ivfc_archive.h2
-rw-r--r--src/core/hle/config_mem.cpp5
-rw-r--r--src/core/hle/hle.h7
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp1
-rw-r--r--src/core/hle/kernel/event.cpp2
-rw-r--r--src/core/hle/kernel/kernel.cpp3
-rw-r--r--src/core/hle/kernel/kernel.h14
-rw-r--r--src/core/hle/kernel/mutex.cpp2
-rw-r--r--src/core/hle/kernel/semaphore.cpp2
-rw-r--r--src/core/hle/kernel/shared_memory.cpp2
-rw-r--r--src/core/hle/kernel/thread.cpp4
-rw-r--r--src/core/hle/kernel/timer.cpp3
-rw-r--r--src/core/hle/result.h1
-rw-r--r--src/core/hle/service/am_sys.cpp2
-rw-r--r--src/core/hle/service/apt/apt.cpp2
-rw-r--r--src/core/hle/service/apt/apt_s.cpp3
-rw-r--r--src/core/hle/service/apt/apt_u.cpp1
-rw-r--r--src/core/hle/service/cfg/cfg.cpp8
-rw-r--r--src/core/hle/service/cfg/cfg_u.cpp2
-rw-r--r--src/core/hle/service/dsp_dsp.cpp2
-rw-r--r--src/core/hle/service/err_f.cpp2
-rw-r--r--src/core/hle/service/fs/archive.cpp11
-rw-r--r--src/core/hle/service/fs/archive.h16
-rw-r--r--src/core/hle/service/fs/fs_user.cpp5
-rw-r--r--src/core/hle/service/hid/hid.cpp2
-rw-r--r--src/core/hle/service/ldr_ro.cpp2
-rw-r--r--src/core/hle/service/nim_u.cpp2
-rw-r--r--src/core/hle/service/ns_s.cpp2
-rw-r--r--src/core/hle/service/nwm_uds.cpp2
-rw-r--r--src/core/hle/service/ptm/ptm.cpp3
-rw-r--r--src/core/hle/service/ptm/ptm_u.cpp2
-rw-r--r--src/core/hle/service/service.cpp2
-rw-r--r--src/core/hle/service/service.h2
-rw-r--r--src/core/hle/service/soc_u.cpp1
-rw-r--r--src/core/hle/service/srv.cpp2
-rw-r--r--src/core/hle/service/y2r_u.cpp2
-rw-r--r--src/core/hle/shared_page.cpp4
-rw-r--r--src/core/hle/svc.cpp3
-rw-r--r--src/core/hw/gpu.h4
-rw-r--r--src/core/hw/hw.cpp1
-rw-r--r--src/core/hw/lcd.cpp3
-rw-r--r--src/core/hw/lcd.h3
-rw-r--r--src/core/loader/3dsx.cpp2
-rw-r--r--src/core/loader/elf.cpp3
-rw-r--r--src/core/loader/loader.cpp1
-rw-r--r--src/core/loader/loader.h2
-rw-r--r--src/core/loader/ncch.cpp2
-rw-r--r--src/core/loader/ncch.h4
-rw-r--r--src/core/mem_map.cpp4
-rw-r--r--src/core/mem_map.h3
-rw-r--r--src/core/mem_map_funcs.cpp4
-rw-r--r--src/video_core/color.h2
-rw-r--r--src/video_core/pica.h3
-rw-r--r--src/video_core/renderer_base.h2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp1
-rw-r--r--src/video_core/video_core.cpp2
-rw-r--r--src/video_core/video_core.h1
122 files changed, 433 insertions, 480 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 516aba554..b0fe285db 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,8 +8,11 @@ if (NOT MSVC)
8 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") 8 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")
9 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") 9 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
10else() 10else()
11 # Silence deprecation warnings 11 # Silence "deprecation" warnings
12 add_definitions(/D_CRT_SECURE_NO_WARNINGS) 12 add_definitions(/D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE)
13 # Avoid windows.h junk
14 add_definitions(/DNOMINMAX)
15
13 # set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms) 16 # set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
14 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 17 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
15 18
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 2c6ced920..1d7e7f270 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -4,7 +4,7 @@
4 4
5#include <thread> 5#include <thread>
6 6
7#include "common/common.h" 7#include "common/logging/log.h"
8#include "common/logging/text_formatter.h" 8#include "common/logging/text_formatter.h"
9#include "common/logging/backend.h" 9#include "common/logging/backend.h"
10#include "common/logging/filter.h" 10#include "common/logging/filter.h"
@@ -19,7 +19,7 @@
19#include "citra/emu_window/emu_window_glfw.h" 19#include "citra/emu_window/emu_window_glfw.h"
20 20
21/// Application entry point 21/// Application entry point
22int __cdecl main(int argc, char **argv) { 22int main(int argc, char **argv) {
23 std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger(); 23 std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
24 Log::Filter log_filter(Log::Level::Debug); 24 Log::Filter log_filter(Log::Level::Debug);
25 Log::SetFilter(&log_filter); 25 Log::SetFilter(&log_filter);
diff --git a/src/citra/config.cpp b/src/citra/config.cpp
index 43175d6cb..ab564559d 100644
--- a/src/citra/config.cpp
+++ b/src/citra/config.cpp
@@ -5,7 +5,10 @@
5#include <GLFW/glfw3.h> 5#include <GLFW/glfw3.h>
6 6
7#include "citra/default_ini.h" 7#include "citra/default_ini.h"
8
8#include "common/file_util.h" 9#include "common/file_util.h"
10#include "common/logging/log.h"
11
9#include "core/settings.h" 12#include "core/settings.h"
10#include "core/core.h" 13#include "core/core.h"
11 14
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp
index f879ee7ca..341b48d2a 100644
--- a/src/citra/emu_window/emu_window_glfw.cpp
+++ b/src/citra/emu_window/emu_window_glfw.cpp
@@ -4,7 +4,7 @@
4 4
5#include <GLFW/glfw3.h> 5#include <GLFW/glfw3.h>
6 6
7#include "common/common.h" 7#include "common/logging/log.h"
8 8
9#include "video_core/video_core.h" 9#include "video_core/video_core.h"
10 10
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index a7f949411..d3df289f8 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -8,7 +8,6 @@
8#include <QWindow> 8#include <QWindow>
9#endif 9#endif
10 10
11#include "common/common.h"
12#include "bootmanager.h" 11#include "bootmanager.h"
13#include "main.h" 12#include "main.h"
14 13
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index 715faf2d7..d5d74c949 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -7,7 +7,6 @@
7#include <QThread> 7#include <QThread>
8#include <QGLWidget> 8#include <QGLWidget>
9 9
10#include "common/common.h"
11#include "common/emu_window.h" 10#include "common/emu_window.h"
12#include "common/thread.h" 11#include "common/thread.h"
13 12
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp
index 08c6b49bd..780607e82 100644
--- a/src/citra_qt/debugger/disassembler.cpp
+++ b/src/citra_qt/debugger/disassembler.cpp
@@ -7,7 +7,6 @@
7#include "../bootmanager.h" 7#include "../bootmanager.h"
8#include "../hotkeys.h" 8#include "../hotkeys.h"
9 9
10#include "common/common.h"
11#include "core/mem_map.h" 10#include "core/mem_map.h"
12 11
13#include "core/core.h" 12#include "core/core.h"
diff --git a/src/citra_qt/debugger/disassembler.h b/src/citra_qt/debugger/disassembler.h
index 45b0a7e08..340fb9936 100644
--- a/src/citra_qt/debugger/disassembler.h
+++ b/src/citra_qt/debugger/disassembler.h
@@ -9,8 +9,8 @@
9 9
10#include "ui_disassembler.h" 10#include "ui_disassembler.h"
11 11
12#include "common/common.h"
13#include "common/break_points.h" 12#include "common/break_points.h"
13#include "common/common_types.h"
14 14
15class QAction; 15class QAction;
16class EmuThread; 16class EmuThread;
diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp
index 92348be34..1da64f616 100644
--- a/src/citra_qt/debugger/graphics_breakpoints.cpp
+++ b/src/citra_qt/debugger/graphics_breakpoints.cpp
@@ -8,6 +8,8 @@
8#include <QVBoxLayout> 8#include <QVBoxLayout>
9#include <QLabel> 9#include <QLabel>
10 10
11#include "common/assert.h"
12
11#include "graphics_breakpoints.h" 13#include "graphics_breakpoints.h"
12#include "graphics_breakpoints_p.h" 14#include "graphics_breakpoints_p.h"
13 15
diff --git a/src/citra_qt/debugger/ramview.cpp b/src/citra_qt/debugger/ramview.cpp
index 88570f2cd..7149a0485 100644
--- a/src/citra_qt/debugger/ramview.cpp
+++ b/src/citra_qt/debugger/ramview.cpp
@@ -4,8 +4,9 @@
4 4
5#include "ramview.h" 5#include "ramview.h"
6 6
7#include "common/common.h"
8#include "core/mem_map.h" 7#include "core/mem_map.h"
8
9
9GRamView::GRamView(QWidget* parent) : QHexEdit(parent) 10GRamView::GRamView(QWidget* parent) : QHexEdit(parent)
10{ 11{
11} 12}
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index dd0e4de8f..d15338f0d 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -10,7 +10,6 @@
10#include "qhexedit.h" 10#include "qhexedit.h"
11#include "main.h" 11#include "main.h"
12 12
13#include "common/common.h"
14#include "common/logging/text_formatter.h" 13#include "common/logging/text_formatter.h"
15#include "common/logging/log.h" 14#include "common/logging/log.h"
16#include "common/logging/backend.h" 15#include "common/logging/backend.h"
@@ -349,7 +348,7 @@ void GMainWindow::closeEvent(QCloseEvent* event)
349#undef main 348#undef main
350#endif 349#endif
351 350
352int __cdecl main(int argc, char* argv[]) 351int main(int argc, char* argv[])
353{ 352{
354 std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger(); 353 std::shared_ptr<Log::Logger> logger = Log::InitGlobalLogger();
355 Log::Filter log_filter(Log::Level::Info); 354 Log::Filter log_filter(Log::Level::Info);
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index daa2d59de..9a9f1a46b 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -27,7 +27,6 @@ set(HEADERS
27 bit_field.h 27 bit_field.h
28 break_points.h 28 break_points.h
29 chunk_file.h 29 chunk_file.h
30 common.h
31 common_funcs.h 30 common_funcs.h
32 common_paths.h 31 common_paths.h
33 common_types.h 32 common_types.h
diff --git a/src/common/assert.h b/src/common/assert.h
index 9ca7adb15..4f26c63e9 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <cstdio>
7#include <cstdlib> 8#include <cstdlib>
8 9
9#include "common/common_funcs.h" 10#include "common/common_funcs.h"
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 8eab054b8..1f3ecf844 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -35,7 +35,7 @@
35#include <limits> 35#include <limits>
36#include <type_traits> 36#include <type_traits>
37 37
38#include "common/common.h" 38#include "common/common_funcs.h"
39 39
40/* 40/*
41 * Abstract bitfield class 41 * Abstract bitfield class
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
index 15055bd4e..023a485a4 100644
--- a/src/common/break_points.cpp
+++ b/src/common/break_points.cpp
@@ -2,7 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h"
6#include "common/debug_interface.h" 5#include "common/debug_interface.h"
7#include "common/break_points.h" 6#include "common/break_points.h"
8#include "common/logging/log.h" 7#include "common/logging/log.h"
diff --git a/src/common/break_points.h b/src/common/break_points.h
index 4b26cf90d..f0a55e7b1 100644
--- a/src/common/break_points.h
+++ b/src/common/break_points.h
@@ -7,7 +7,7 @@
7#include <vector> 7#include <vector>
8#include <string> 8#include <string>
9 9
10#include "common/common.h" 10#include "common/common_types.h"
11 11
12class DebugInterface; 12class DebugInterface;
13 13
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 3f97d56bf..dcd80525e 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -34,8 +34,9 @@
34#include <set> 34#include <set>
35#include <type_traits> 35#include <type_traits>
36 36
37#include "common/common.h" 37#include "common/common_types.h"
38#include "common/file_util.h" 38#include "common/file_util.h"
39#include "common/logging/log.h"
39 40
40template <class T> 41template <class T>
41struct LinkedListItem : public T 42struct LinkedListItem : public T
diff --git a/src/common/common.h b/src/common/common.h
deleted file mode 100644
index f7d0f55c5..000000000
--- a/src/common/common.h
+++ /dev/null
@@ -1,120 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7// DO NOT EVER INCLUDE <windows.h> directly _or indirectly_ from this file
8// since it slows down the build a lot.
9
10#include <cstdlib>
11#include <cstdio>
12#include <cstring>
13
14#define STACKALIGN
15
16// An inheritable class to disallow the copy constructor and operator= functions
17class NonCopyable
18{
19protected:
20 NonCopyable() {}
21 NonCopyable(const NonCopyable&&) {}
22 void operator=(const NonCopyable&&) {}
23private:
24 NonCopyable(NonCopyable&);
25 NonCopyable& operator=(NonCopyable& other);
26};
27
28#include "common/assert.h"
29#include "common/logging/log.h"
30#include "common/common_types.h"
31#include "common/common_funcs.h"
32#include "common/common_paths.h"
33#include "common/platform.h"
34
35#ifdef __APPLE__
36// The Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
37// This is only needed on i386 gcc - x86_64 already aligns to 16 bytes.
38 #if defined __i386__ && defined __GNUC__
39 #undef STACKALIGN
40 #define STACKALIGN __attribute__((__force_align_arg_pointer__))
41 #endif
42#elif defined _WIN32
43// Check MSC ver
44 #if defined _MSC_VER && _MSC_VER <= 1000
45 #error needs at least version 1000 of MSC
46 #endif
47
48 #ifndef NOMINMAX
49 #define NOMINMAX
50 #endif
51
52// Alignment
53 #define MEMORY_ALIGNED16(x) __declspec(align(16)) x
54 #define MEMORY_ALIGNED32(x) __declspec(align(32)) x
55 #define MEMORY_ALIGNED64(x) __declspec(align(64)) x
56 #define MEMORY_ALIGNED128(x) __declspec(align(128)) x
57 #define MEMORY_ALIGNED16_DECL(x) __declspec(align(16)) x
58 #define MEMORY_ALIGNED64_DECL(x) __declspec(align(64)) x
59#endif
60
61// Windows compatibility
62#ifndef _WIN32
63 #ifdef _LP64
64 #define _M_X64 1
65 #else
66 #define _M_IX86 1
67 #endif
68 #define __forceinline inline __attribute__((always_inline))
69 #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x
70 #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x
71 #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x
72 #define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x
73 #define MEMORY_ALIGNED16_DECL(x) __attribute__((aligned(16))) x
74 #define MEMORY_ALIGNED64_DECL(x) __attribute__((aligned(64))) x
75#endif
76
77#ifdef _MSC_VER
78 #define __strdup _strdup
79 #define __getcwd _getcwd
80 #define __chdir _chdir
81#else
82 #define __strdup strdup
83 #define __getcwd getcwd
84 #define __chdir chdir
85#endif
86
87#if defined _M_GENERIC
88# define _M_SSE 0x0
89#elif defined __GNUC__
90# if defined __SSE4_2__
91# define _M_SSE 0x402
92# elif defined __SSE4_1__
93# define _M_SSE 0x401
94# elif defined __SSSE3__
95# define _M_SSE 0x301
96# elif defined __SSE3__
97# define _M_SSE 0x300
98# endif
99#elif (_MSC_VER >= 1500) || __INTEL_COMPILER // Visual Studio 2008
100# define _M_SSE 0x402
101#endif
102
103// Host communication.
104enum HOST_COMM
105{
106 // Begin at 10 in case there is already messages with wParam = 0, 1, 2 and so on
107 WM_USER_STOP = 10,
108 WM_USER_CREATE,
109 WM_USER_SETCURSOR,
110};
111
112// Used for notification on emulation state
113enum EMUSTATE_CHANGE
114{
115 EMUSTATE_CHANGE_PLAY = 1,
116 EMUSTATE_CHANGE_PAUSE,
117 EMUSTATE_CHANGE_STOP
118};
119
120#include "swap.h"
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index e76cb7d68..4f9e514c9 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -7,13 +7,6 @@
7#include "common_types.h" 7#include "common_types.h"
8#include <cstdlib> 8#include <cstdlib>
9 9
10#ifdef _WIN32
11#define SLEEP(x) Sleep(x)
12#else
13#include <unistd.h>
14#define SLEEP(x) usleep(x*1000)
15#endif
16
17 10
18#define b2(x) ( (x) | ( (x) >> 1) ) 11#define b2(x) ( (x) | ( (x) >> 1) )
19#define b4(x) ( b2(x) | ( b2(x) >> 2) ) 12#define b4(x) ( b2(x) | ( b2(x) >> 2) )
@@ -34,6 +27,27 @@
34#define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)] 27#define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)]
35#define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)] 28#define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)]
36 29
30#ifdef _WIN32
31 // Alignment
32 #define MEMORY_ALIGNED16(x) __declspec(align(16)) x
33 #define MEMORY_ALIGNED32(x) __declspec(align(32)) x
34 #define MEMORY_ALIGNED64(x) __declspec(align(64)) x
35 #define MEMORY_ALIGNED128(x) __declspec(align(128)) x
36#else
37 // Windows compatibility
38 #ifdef _LP64
39 #define _M_X64 1
40 #else
41 #define _M_IX86 1
42 #endif
43
44 #define __forceinline inline __attribute__((always_inline))
45 #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x
46 #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x
47 #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x
48 #define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x
49#endif
50
37#ifndef _MSC_VER 51#ifndef _MSC_VER
38 52
39#include <errno.h> 53#include <errno.h>
@@ -73,61 +87,11 @@ inline u64 _rotr64(u64 x, unsigned int shift){
73} 87}
74 88
75#else // _MSC_VER 89#else // _MSC_VER
76#include <locale.h> 90 // Function Cross-Compatibility
77
78// Function Cross-Compatibility
79 #define strcasecmp _stricmp
80 #define strncasecmp _strnicmp
81 #define unlink _unlink
82 #define snprintf _snprintf 91 #define snprintf _snprintf
83 #define vscprintf _vscprintf
84 92
85// Locale Cross-Compatibility 93 // Locale Cross-Compatibility
86 #define locale_t _locale_t 94 #define locale_t _locale_t
87 #define freelocale _free_locale
88 #define newlocale(mask, locale, base) _create_locale(mask, locale)
89
90 #define LC_GLOBAL_LOCALE ((locale_t)-1)
91 #define LC_ALL_MASK LC_ALL
92 #define LC_COLLATE_MASK LC_COLLATE
93 #define LC_CTYPE_MASK LC_CTYPE
94 #define LC_MONETARY_MASK LC_MONETARY
95 #define LC_NUMERIC_MASK LC_NUMERIC
96 #define LC_TIME_MASK LC_TIME
97
98 inline locale_t uselocale(locale_t new_locale)
99 {
100 // Retrieve the current per thread locale setting
101 bool bIsPerThread = (_configthreadlocale(0) == _ENABLE_PER_THREAD_LOCALE);
102
103 // Retrieve the current thread-specific locale
104 locale_t old_locale = bIsPerThread ? _get_current_locale() : LC_GLOBAL_LOCALE;
105
106 if(new_locale == LC_GLOBAL_LOCALE)
107 {
108 // Restore the global locale
109 _configthreadlocale(_DISABLE_PER_THREAD_LOCALE);
110 }
111 else if(new_locale != nullptr)
112 {
113 // Configure the thread to set the locale only for this thread
114 _configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
115
116 // Set all locale categories
117 for(int i = LC_MIN; i <= LC_MAX; i++)
118 setlocale(i, new_locale->locinfo->lc_category[i].locale);
119 }
120
121 return old_locale;
122 }
123
124// 64 bit offsets for windows
125 #define fseeko _fseeki64
126 #define ftello _ftelli64
127 #define atoll _atoi64
128 #define stat64 _stat64
129 #define fstat64 _fstat64
130 #define fileno _fileno
131 95
132 extern "C" { 96 extern "C" {
133 __declspec(dllimport) void __stdcall DebugBreak(void); 97 __declspec(dllimport) void __stdcall DebugBreak(void);
diff --git a/src/common/common_paths.h b/src/common/common_paths.h
index 440b06060..2903f2cf2 100644
--- a/src/common/common_paths.h
+++ b/src/common/common_paths.h
@@ -4,9 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7// Make sure we pick up USER_DIR if set in config.h
8#include "common/common.h"
9
10// Directory separators, do we need this? 7// Directory separators, do we need this?
11#define DIR_SEP "/" 8#define DIR_SEP "/"
12#define DIR_SEP_CHR '/' 9#define DIR_SEP_CHR '/'
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 1b453e7f5..644709ba6 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -47,6 +47,11 @@ typedef std::int64_t s64; ///< 64-bit signed int
47typedef float f32; ///< 32-bit floating point 47typedef float f32; ///< 32-bit floating point
48typedef double f64; ///< 64-bit floating point 48typedef double f64; ///< 64-bit floating point
49 49
50// TODO: It would be nice to eventually replace these with strong types that prevent accidental
51// conversion between each other.
52typedef u32 VAddr; ///< Represents a pointer in the userspace virtual address space.
53typedef u32 PAddr; ///< Represents a pointer in the ARM11 physical address space.
54
50/// Union for fast 16-bit type casting 55/// Union for fast 16-bit type casting
51union t16 { 56union t16 {
52 u8 _u8[2]; ///< 8-bit unsigned char(s) 57 u8 _u8[2]; ///< 8-bit unsigned char(s)
@@ -73,6 +78,16 @@ union t64 {
73 u8 _u8[8]; ///< 8-bit unsigned char(s) 78 u8 _u8[8]; ///< 8-bit unsigned char(s)
74}; 79};
75 80
81// An inheritable class to disallow the copy constructor and operator= functions
82class NonCopyable {
83protected:
84 NonCopyable() = default;
85 ~NonCopyable() = default;
86
87 NonCopyable(NonCopyable&) = delete;
88 NonCopyable& operator=(NonCopyable&) = delete;
89};
90
76namespace Common { 91namespace Common {
77/// Rectangle data structure 92/// Rectangle data structure
78class Rect { 93class Rect {
diff --git a/src/common/concurrent_ring_buffer.h b/src/common/concurrent_ring_buffer.h
index fc18e6c86..c5889513a 100644
--- a/src/common/concurrent_ring_buffer.h
+++ b/src/common/concurrent_ring_buffer.h
@@ -10,7 +10,7 @@
10#include <mutex> 10#include <mutex>
11#include <thread> 11#include <thread>
12 12
13#include "common/common.h" // for NonCopyable 13#include "common/common_types.h" // for NonCopyable
14 14
15namespace Common { 15namespace Common {
16 16
diff --git a/src/common/emu_window.h b/src/common/emu_window.h
index e0fc12a48..8eca6b5d5 100644
--- a/src/common/emu_window.h
+++ b/src/common/emu_window.h
@@ -4,11 +4,11 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8#include "common/scm_rev.h"
9#include "common/string_util.h"
10#include "common/key_map.h" 8#include "common/key_map.h"
11#include "common/math_util.h" 9#include "common/math_util.h"
10#include "common/scm_rev.h"
11#include "common/string_util.h"
12 12
13/** 13/**
14 * Abstraction class used to provide an interface between emulation code and the frontend 14 * Abstraction class used to provide an interface between emulation code and the frontend
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 4ef4918d7..7cdd1484f 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -2,42 +2,52 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5 5#include "common/assert.h"
6#include "common/common.h" 6#include "common/common_funcs.h"
7#include "common/common_paths.h"
7#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
8 10
9#ifdef _WIN32 11#ifdef _WIN32
10#include <windows.h> 12 #include <windows.h>
11#include <shlobj.h> // for SHGetFolderPath 13 #include <shlobj.h> // for SHGetFolderPath
12#include <shellapi.h> 14 #include <shellapi.h>
13#include <commdlg.h> // for GetSaveFileName 15 #include <commdlg.h> // for GetSaveFileName
14#include <io.h> 16 #include <io.h>
15#include <direct.h> // getcwd 17 #include <direct.h> // getcwd
16#include <tchar.h> 18 #include <tchar.h>
19
20 // 64 bit offsets for windows
21 #define fseeko _fseeki64
22 #define ftello _ftelli64
23 #define atoll _atoi64
24 #define stat64 _stat64
25 #define fstat64 _fstat64
26 #define fileno _fileno
17#else 27#else
18#include <sys/param.h> 28 #include <sys/param.h>
19#include <sys/types.h> 29 #include <sys/types.h>
20#include <dirent.h> 30 #include <dirent.h>
21#include <pwd.h> 31 #include <pwd.h>
22#include <unistd.h> 32 #include <unistd.h>
23#endif 33#endif
24 34
25#if defined(__APPLE__) 35#if defined(__APPLE__)
26#include <CoreFoundation/CFString.h> 36 #include <CoreFoundation/CFString.h>
27#include <CoreFoundation/CFURL.h> 37 #include <CoreFoundation/CFURL.h>
28#include <CoreFoundation/CFBundle.h> 38 #include <CoreFoundation/CFBundle.h>
29#endif 39#endif
30 40
31#include <algorithm> 41#include <algorithm>
32#include <sys/stat.h> 42#include <sys/stat.h>
33 43
34#ifndef S_ISDIR 44#ifndef S_ISDIR
35#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) 45 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
36#endif 46#endif
37 47
38#ifdef BSD4_4 48#ifdef BSD4_4
39#define stat64 stat 49 #define stat64 stat
40#define fstat64 fstat 50 #define fstat64 fstat
41#endif 51#endif
42 52
43// This namespace has various generic functions related to files and paths. 53// This namespace has various generic functions related to files and paths.
@@ -589,7 +599,7 @@ std::string GetCurrentDir()
589{ 599{
590 char *dir; 600 char *dir;
591 // Get the current working directory (getcwd uses malloc) 601 // Get the current working directory (getcwd uses malloc)
592 if (!(dir = __getcwd(nullptr, 0))) { 602 if (!(dir = getcwd(nullptr, 0))) {
593 603
594 LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s", 604 LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: %s",
595 GetLastErrorMsg()); 605 GetLastErrorMsg());
@@ -603,7 +613,7 @@ std::string GetCurrentDir()
603// Sets the current directory to the given directory 613// Sets the current directory to the given directory
604bool SetCurrentDir(const std::string &directory) 614bool SetCurrentDir(const std::string &directory)
605{ 615{
606 return __chdir(directory.c_str()) == 0; 616 return chdir(directory.c_str()) == 0;
607} 617}
608 618
609#if defined(__APPLE__) 619#if defined(__APPLE__)
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 86aab2e3d..b65829291 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -11,7 +11,7 @@
11#include <string> 11#include <string>
12#include <vector> 12#include <vector>
13 13
14#include "common/common.h" 14#include "common/common_types.h"
15#include "common/string_util.h" 15#include "common/string_util.h"
16 16
17// User directory indices for GetUserPath 17// User directory indices for GetUserPath
diff --git a/src/common/hash.cpp b/src/common/hash.cpp
index 0624dab8d..b0b3613f6 100644
--- a/src/common/hash.cpp
+++ b/src/common/hash.cpp
@@ -4,7 +4,10 @@
4 4
5#include <algorithm> 5#include <algorithm>
6 6
7#include "common/common_funcs.h" // For rotl
7#include "common/hash.h" 8#include "common/hash.h"
9#include "common/platform.h"
10
8#if _M_SSE >= 0x402 11#if _M_SSE >= 0x402
9#include "common/cpu_detect.h" 12#include "common/cpu_detect.h"
10#include <nmmintrin.h> 13#include <nmmintrin.h>
diff --git a/src/common/hash.h b/src/common/hash.h
index 3ac42bc44..0afaf0e37 100644
--- a/src/common/hash.h
+++ b/src/common/hash.h
@@ -4,7 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8 8
9u32 HashFletcher(const u8* data_u8, size_t length); // FAST. Length & 1 == 0. 9u32 HashFletcher(const u8* data_u8, size_t length); // FAST. Length & 1 == 0.
10u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightly slower 10u32 HashAdler32(const u8* data, size_t len); // Fairly accurate, slightly slower
diff --git a/src/common/linear_disk_cache.h b/src/common/linear_disk_cache.h
index 74ce74aba..48529cf42 100644
--- a/src/common/linear_disk_cache.h
+++ b/src/common/linear_disk_cache.h
@@ -4,7 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8#include <fstream> 8#include <fstream>
9 9
10// defined in Version.cpp 10// defined in Version.cpp
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index 36c91c4f6..45be6d0a1 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -14,6 +14,7 @@
14#include "common/logging/log.h" 14#include "common/logging/log.h"
15#include "common/logging/text_formatter.h" 15#include "common/logging/text_formatter.h"
16 16
17#include "common/common_funcs.h"
17#include "common/string_util.h" 18#include "common/string_util.h"
18 19
19namespace Log { 20namespace Log {
diff --git a/src/common/math_util.cpp b/src/common/math_util.cpp
index a83592dd2..bcb70cae5 100644
--- a/src/common/math_util.cpp
+++ b/src/common/math_util.cpp
@@ -2,12 +2,12 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6#include <numeric> // Necessary on OS X, but not Linux
5 7
6#include "common/common.h" 8#include "common/common_types.h"
7#include "common/math_util.h" 9#include "common/math_util.h"
8 10
9#include <numeric> // Necessary on OS X, but not Linux
10
11namespace MathUtil 11namespace MathUtil
12{ 12{
13 13
diff --git a/src/common/math_util.h b/src/common/math_util.h
index 43b0e0dc3..52f579cf7 100644
--- a/src/common/math_util.h
+++ b/src/common/math_util.h
@@ -4,7 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8 8
9#include <algorithm> 9#include <algorithm>
10#include <type_traits> 10#include <type_traits>
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index 76c70701d..f233d4a3a 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -17,12 +17,16 @@
17 17
18#include <string> 18#include <string>
19 19
20#include "common/memory_util.h" 20#include "common/logging/log.h"
21#include "common/mem_arena.h" 21#include "common/mem_arena.h"
22#include "common/memory_util.h"
22#include "common/string_util.h" 23#include "common/string_util.h"
23 24
24#ifndef _WIN32 25#ifndef _WIN32
25#include <fcntl.h> 26#include <fcntl.h>
27#include <string.h>
28#include <unistd.h>
29
26#ifdef ANDROID 30#ifdef ANDROID
27#include <sys/ioctl.h> 31#include <sys/ioctl.h>
28#include <linux/ashmem.h> 32#include <linux/ashmem.h>
diff --git a/src/common/mem_arena.h b/src/common/mem_arena.h
index 3379d2529..d514fe58c 100644
--- a/src/common/mem_arena.h
+++ b/src/common/mem_arena.h
@@ -21,7 +21,7 @@
21#include <windows.h> 21#include <windows.h>
22#endif 22#endif
23 23
24#include "common/common.h" 24#include "common/common_types.h"
25 25
26// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it. 26// This class lets you create a block of anonymous RAM, and then arbitrarily map views into it.
27// Multiple views can mirror the same section of the block, which makes it very convient for emulating 27// Multiple views can mirror the same section of the block, which makes it very convient for emulating
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index 7e69d31cb..2087a1184 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -3,7 +3,8 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5 5
6#include "common/common.h" 6#include "common/common_funcs.h"
7#include "common/logging/log.h"
7#include "common/memory_util.h" 8#include "common/memory_util.h"
8#include "common/string_util.h" 9#include "common/string_util.h"
9 10
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index e33055d10..53cacf37c 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -2,10 +2,12 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/common_funcs.h"
6 6
7#ifdef _WIN32 7#ifdef _WIN32
8#include <windows.h> 8#include <windows.h>
9#else
10#include <string.h>
9#endif 11#endif
10 12
11// Neither Android nor OS X support TLS 13// Neither Android nor OS X support TLS
diff --git a/src/common/platform.h b/src/common/platform.h
index e27d6e31f..1516dc88a 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -64,47 +64,26 @@
64#endif 64#endif
65 65
66//////////////////////////////////////////////////////////////////////////////////////////////////// 66////////////////////////////////////////////////////////////////////////////////////////////////////
67// Compiler-Specific Definitions 67// Feature detection
68 68
69#if EMU_PLATFORM == PLATFORM_WINDOWS 69#if defined _M_GENERIC
70 70# define _M_SSE 0x0
71#include <time.h> 71#elif defined __GNUC__
72 72# if defined __SSE4_2__
73#ifndef NOMINMAX 73# define _M_SSE 0x402
74#define NOMINMAX 74# elif defined __SSE4_1__
75# define _M_SSE 0x401
76# elif defined __SSSE3__
77# define _M_SSE 0x301
78# elif defined __SSE3__
79# define _M_SSE 0x300
80# endif
81#elif (_MSC_VER >= 1500) || __INTEL_COMPILER // Visual Studio 2008
82# define _M_SSE 0x402
75#endif 83#endif
76#define EMU_FASTCALL __fastcall
77
78#ifdef _MSC_VER
79inline struct tm* localtime_r(const time_t *clock, struct tm *result) {
80 if (localtime_s(result, clock) == 0)
81 return result;
82 return nullptr;
83}
84#endif
85
86#else // EMU_PLATFORM != PLATFORM_WINDOWS
87
88#define EMU_FASTCALL __attribute__((fastcall))
89#define __stdcall
90#define __cdecl
91 84
92#define BOOL bool 85////////////////////////////////////////////////////////////////////////////////////////////////////
93#define DWORD u32 86// Compiler-Specific Definitions
94
95// TODO: Hacks..
96#include <limits.h>
97
98#include <strings.h>
99#define stricmp(str1, str2) strcasecmp(str1, str2)
100#define _stricmp(str1, str2) strcasecmp(str1, str2)
101#define _snprintf snprintf
102#define _getcwd getcwd
103#define _tzset tzset
104
105typedef void EXCEPTION_POINTERS;
106
107#endif
108 87
109#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \ 88#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \
110 (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))) 89 (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
diff --git a/src/common/profiler.cpp b/src/common/profiler.cpp
index 65c3df167..b8cde1785 100644
--- a/src/common/profiler.cpp
+++ b/src/common/profiler.cpp
@@ -7,7 +7,6 @@
7#include "common/assert.h" 7#include "common/assert.h"
8 8
9#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013. 9#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013.
10#define NOMINMAX
11#define WIN32_LEAN_AND_MEAN 10#define WIN32_LEAN_AND_MEAN
12#include <Windows.h> // For QueryPerformanceCounter/Frequency 11#include <Windows.h> // For QueryPerformanceCounter/Frequency
13#endif 12#endif
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 3264dd51a..6563611fd 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -4,7 +4,9 @@
4 4
5#include <boost/range/algorithm.hpp> 5#include <boost/range/algorithm.hpp>
6 6
7#include "common/common.h" 7#include "common/common_funcs.h"
8#include "common/common_paths.h"
9#include "common/logging/log.h"
8#include "common/string_util.h" 10#include "common/string_util.h"
9 11
10#ifdef _MSC_VER 12#ifdef _MSC_VER
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 74974263f..a60a84696 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -10,7 +10,7 @@
10#include <sstream> 10#include <sstream>
11#include <vector> 11#include <vector>
12 12
13#include "common/common.h" 13#include "common/common_types.h"
14 14
15namespace Common { 15namespace Common {
16 16
diff --git a/src/common/symbols.h b/src/common/symbols.h
index f76cb6b1e..6b62b011e 100644
--- a/src/common/symbols.h
+++ b/src/common/symbols.h
@@ -5,8 +5,10 @@
5#pragma once 5#pragma once
6 6
7#include <map> 7#include <map>
8#include <string>
9#include <utility>
8 10
9#include "common/common.h" 11#include "common/common_types.h"
10 12
11struct TSymbol 13struct TSymbol
12{ 14{
diff --git a/src/common/thread.h b/src/common/thread.h
index 5fdb6baeb..7bc419497 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7// Don't include common.h here as it will break LogManager
8#include "common/common_types.h" 7#include "common/common_types.h"
9#include <cstdio> 8#include <cstdio>
10#include <cstring> 9#include <cstring>
diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h
index 4f27fc899..12455d7c4 100644
--- a/src/common/thread_queue_list.h
+++ b/src/common/thread_queue_list.h
@@ -9,8 +9,6 @@
9 9
10#include <boost/range/algorithm_ext/erase.hpp> 10#include <boost/range/algorithm_ext/erase.hpp>
11 11
12#include "common/common.h"
13
14namespace Common { 12namespace Common {
15 13
16template<class T, unsigned int N> 14template<class T, unsigned int N>
diff --git a/src/common/thunk.h b/src/common/thunk.h
index 4fb7c98e1..533480056 100644
--- a/src/common/thunk.h
+++ b/src/common/thunk.h
@@ -6,7 +6,7 @@
6 6
7#include <map> 7#include <map>
8 8
9#include "common/common.h" 9#include "common/common_types.h"
10 10
11// This simple class creates a wrapper around a C/C++ function that saves all fp state 11// This simple class creates a wrapper around a C/C++ function that saves all fp state
12// before entering it, and restores it upon exit. This is required to be able to selectively 12// before entering it, and restores it upon exit. This is required to be able to selectively
diff --git a/src/common/timer.cpp b/src/common/timer.cpp
index a6682ea19..b99835ac7 100644
--- a/src/common/timer.cpp
+++ b/src/common/timer.cpp
@@ -12,9 +12,9 @@
12#include <sys/time.h> 12#include <sys/time.h>
13#endif 13#endif
14 14
15#include "common/common.h" 15#include "common/common_types.h"
16#include "common/timer.h"
17#include "common/string_util.h" 16#include "common/string_util.h"
17#include "common/timer.h"
18 18
19namespace Common 19namespace Common
20{ 20{
diff --git a/src/common/timer.h b/src/common/timer.h
index 4b44c33a0..b5f0f2585 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -4,7 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8#include <string> 8#include <string>
9 9
10namespace Common 10namespace Common
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 42733b95e..fa6b4215a 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -12,6 +12,7 @@ set(SRCS
12 arm/skyeye_common/vfp/vfpdouble.cpp 12 arm/skyeye_common/vfp/vfpdouble.cpp
13 arm/skyeye_common/vfp/vfpinstr.cpp 13 arm/skyeye_common/vfp/vfpinstr.cpp
14 arm/skyeye_common/vfp/vfpsingle.cpp 14 arm/skyeye_common/vfp/vfpsingle.cpp
15 file_sys/archive_backend.cpp
15 file_sys/archive_extsavedata.cpp 16 file_sys/archive_extsavedata.cpp
16 file_sys/archive_romfs.cpp 17 file_sys/archive_romfs.cpp
17 file_sys/archive_savedata.cpp 18 file_sys/archive_savedata.cpp
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 310663774..85ed2c698 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h"
8#include "common/common_types.h" 7#include "common/common_types.h"
9#include "core/arm/skyeye_common/arm_regformat.h" 8#include "core/arm/skyeye_common/arm_regformat.h"
10 9
diff --git a/src/core/arm/dyncom/arm_dyncom.cpp b/src/core/arm/dyncom/arm_dyncom.cpp
index 128413262..42a63e46f 100644
--- a/src/core/arm/dyncom/arm_dyncom.cpp
+++ b/src/core/arm/dyncom/arm_dyncom.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6
5#include "common/make_unique.h" 7#include "common/make_unique.h"
6 8
7#include "core/arm/skyeye_common/armemu.h" 9#include "core/arm/skyeye_common/armemu.h"
diff --git a/src/core/arm/interpreter/armsupp.cpp b/src/core/arm/interpreter/armsupp.cpp
index a68d53695..15c6f595b 100644
--- a/src/core/arm/interpreter/armsupp.cpp
+++ b/src/core/arm/interpreter/armsupp.cpp
@@ -15,6 +15,8 @@
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17 17
18#include "common/logging/log.h"
19
18#include "core/mem_map.h" 20#include "core/mem_map.h"
19#include "core/arm/skyeye_common/armdefs.h" 21#include "core/arm/skyeye_common/armdefs.h"
20#include "core/arm/skyeye_common/arm_regformat.h" 22#include "core/arm/skyeye_common/arm_regformat.h"
diff --git a/src/core/arm/skyeye_common/armmmu.h b/src/core/arm/skyeye_common/armmmu.h
index 22e564c3d..0463d83c8 100644
--- a/src/core/arm/skyeye_common/armmmu.h
+++ b/src/core/arm/skyeye_common/armmmu.h
@@ -20,6 +20,8 @@
20 20
21#pragma once 21#pragma once
22 22
23#include "common/swap.h"
24
23#include "core/mem_map.h" 25#include "core/mem_map.h"
24#include "core/arm/skyeye_common/armdefs.h" 26#include "core/arm/skyeye_common/armdefs.h"
25 27
diff --git a/src/core/arm/skyeye_common/vfp/vfp.cpp b/src/core/arm/skyeye_common/vfp/vfp.cpp
index d0fa157a2..b88d47750 100644
--- a/src/core/arm/skyeye_common/vfp/vfp.cpp
+++ b/src/core/arm/skyeye_common/vfp/vfp.cpp
@@ -20,7 +20,6 @@
20 20
21/* Note: this file handles interface with arm core and vfp registers */ 21/* Note: this file handles interface with arm core and vfp registers */
22 22
23#include "common/common.h"
24#include "common/logging/log.h" 23#include "common/logging/log.h"
25 24
26#include "core/arm/skyeye_common/armdefs.h" 25#include "core/arm/skyeye_common/armdefs.h"
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 81e642318..1c9680d41 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/logging/log.h"
6 7
7#include "core/core.h" 8#include "core/core.h"
8#include "core/core_timing.h" 9#include "core/core_timing.h"
diff --git a/src/core/core_timing.h b/src/core/core_timing.h
index d62ff3604..01519608d 100644
--- a/src/core/core_timing.h
+++ b/src/core/core_timing.h
@@ -21,7 +21,7 @@
21 21
22#include <functional> 22#include <functional>
23 23
24#include "common/common.h" 24#include "common/common_types.h"
25 25
26extern int g_clock_rate_arm11; 26extern int g_clock_rate_arm11;
27 27
diff --git a/src/core/file_sys/archive_backend.cpp b/src/core/file_sys/archive_backend.cpp
new file mode 100644
index 000000000..0439868ab
--- /dev/null
+++ b/src/core/file_sys/archive_backend.cpp
@@ -0,0 +1,127 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <sstream>
6
7#include "common/logging/log.h"
8#include "common/string_util.h"
9
10#include "core/file_sys/archive_backend.h"
11#include "core/mem_map.h"
12
13
14namespace FileSys {
15
16Path::Path(LowPathType type, u32 size, u32 pointer) : type(type) {
17 switch (type) {
18 case Binary:
19 {
20 u8* data = Memory::GetPointer(pointer);
21 binary = std::vector<u8>(data, data + size);
22 break;
23 }
24
25 case Char:
26 {
27 const char* data = reinterpret_cast<const char*>(Memory::GetPointer(pointer));
28 string = std::string(data, size - 1); // Data is always null-terminated.
29 break;
30 }
31
32 case Wchar:
33 {
34 const char16_t* data = reinterpret_cast<const char16_t*>(Memory::GetPointer(pointer));
35 u16str = std::u16string(data, size/2 - 1); // Data is always null-terminated.
36 break;
37 }
38
39 default:
40 break;
41 }
42}
43
44const std::string Path::DebugStr() const {
45 switch (GetType()) {
46 case Invalid:
47 default:
48 return "[Invalid]";
49 case Empty:
50 return "[Empty]";
51 case Binary:
52 {
53 std::stringstream res;
54 res << "[Binary: ";
55 for (unsigned byte : binary)
56 res << std::hex << std::setw(2) << std::setfill('0') << byte;
57 res << ']';
58 return res.str();
59 }
60 case Char:
61 return "[Char: " + AsString() + ']';
62 case Wchar:
63 return "[Wchar: " + AsString() + ']';
64 }
65}
66
67const std::string Path::AsString() const {
68 switch (GetType()) {
69 case Char:
70 return string;
71 case Wchar:
72 return Common::UTF16ToUTF8(u16str);
73 case Empty:
74 return{};
75 case Invalid:
76 case Binary:
77 default:
78 // TODO(yuriks): Add assert
79 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
80 return{};
81 }
82}
83
84const std::u16string Path::AsU16Str() const {
85 switch (GetType()) {
86 case Char:
87 return Common::UTF8ToUTF16(string);
88 case Wchar:
89 return u16str;
90 case Empty:
91 return{};
92 case Invalid:
93 case Binary:
94 // TODO(yuriks): Add assert
95 LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!");
96 return{};
97 }
98}
99
100const std::vector<u8> Path::AsBinary() const {
101 switch (GetType()) {
102 case Binary:
103 return binary;
104 case Char:
105 return std::vector<u8>(string.begin(), string.end());
106 case Wchar:
107 {
108 // use two u8 for each character of u16str
109 std::vector<u8> to_return(u16str.size() * 2);
110 for (size_t i = 0; i < u16str.size(); ++i) {
111 u16 tmp_char = u16str.at(i);
112 to_return[i*2] = (tmp_char & 0xFF00) >> 8;
113 to_return[i*2 + 1] = (tmp_char & 0x00FF);
114 }
115 return to_return;
116 }
117 case Empty:
118 return{};
119 case Invalid:
120 default:
121 // TODO(yuriks): Add assert
122 LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!");
123 return{};
124 }
125}
126
127}
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h
index 43a106549..c6a1be79d 100644
--- a/src/core/file_sys/archive_backend.h
+++ b/src/core/file_sys/archive_backend.h
@@ -5,22 +5,21 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <string>
9#include <utility>
10#include <vector>
8 11
9#include "common/common_types.h"
10#include "common/string_util.h"
11#include "common/bit_field.h" 12#include "common/bit_field.h"
13#include "common/common_types.h"
12 14
13#include "core/file_sys/file_backend.h" 15#include "core/hle/result.h"
14#include "core/file_sys/directory_backend.h"
15
16#include "core/mem_map.h"
17#include "core/hle/kernel/kernel.h"
18 16
19////////////////////////////////////////////////////////////////////////////////////////////////////
20// FileSys namespace
21 17
22namespace FileSys { 18namespace FileSys {
23 19
20class FileBackend;
21class DirectoryBackend;
22
24// Path string type 23// Path string type
25enum LowPathType : u32 { 24enum LowPathType : u32 {
26 Invalid = 0, 25 Invalid = 0,
@@ -39,134 +38,22 @@ union Mode {
39 38
40class Path { 39class Path {
41public: 40public:
41 Path() : type(Invalid) {}
42 Path(const char* path) : type(Char), string(path) {}
43 Path(std::vector<u8> binary_data) : type(Binary), binary(std::move(binary_data)) {}
44 Path(LowPathType type, u32 size, u32 pointer);
42 45
43 Path() : type(Invalid) { 46 LowPathType GetType() const { return type; }
44 }
45
46 Path(const char* path) : type(Char), string(path) {
47 }
48
49 Path(std::vector<u8> binary_data) : type(Binary), binary(std::move(binary_data)) {
50 }
51
52 Path(LowPathType type, u32 size, u32 pointer) : type(type) {
53 switch (type) {
54 case Binary:
55 {
56 u8* data = Memory::GetPointer(pointer);
57 binary = std::vector<u8>(data, data + size);
58 break;
59 }
60
61 case Char:
62 {
63 const char* data = reinterpret_cast<const char*>(Memory::GetPointer(pointer));
64 string = std::string(data, size - 1); // Data is always null-terminated.
65 break;
66 }
67
68 case Wchar:
69 {
70 const char16_t* data = reinterpret_cast<const char16_t*>(Memory::GetPointer(pointer));
71 u16str = std::u16string(data, size/2 - 1); // Data is always null-terminated.
72 break;
73 }
74
75 default:
76 break;
77 }
78 }
79
80 LowPathType GetType() const {
81 return type;
82 }
83 47
84 /** 48 /**
85 * Gets the string representation of the path for debugging 49 * Gets the string representation of the path for debugging
86 * @return String representation of the path for debugging 50 * @return String representation of the path for debugging
87 */ 51 */
88 const std::string DebugStr() const { 52 const std::string DebugStr() const;
89 switch (GetType()) {
90 case Invalid:
91 default:
92 return "[Invalid]";
93 case Empty:
94 return "[Empty]";
95 case Binary:
96 {
97 std::stringstream res;
98 res << "[Binary: ";
99 for (unsigned byte : binary)
100 res << std::hex << std::setw(2) << std::setfill('0') << byte;
101 res << ']';
102 return res.str();
103 }
104 case Char:
105 return "[Char: " + AsString() + ']';
106 case Wchar:
107 return "[Wchar: " + AsString() + ']';
108 }
109 }
110 53
111 const std::string AsString() const { 54 const std::string AsString() const;
112 switch (GetType()) { 55 const std::u16string AsU16Str() const;
113 case Char: 56 const std::vector<u8> AsBinary() const;
114 return string;
115 case Wchar:
116 return Common::UTF16ToUTF8(u16str);
117 case Empty:
118 return {};
119 case Invalid:
120 case Binary:
121 default:
122 // TODO(yuriks): Add assert
123 LOG_ERROR(Service_FS, "LowPathType cannot be converted to string!");
124 return {};
125 }
126 }
127
128 const std::u16string AsU16Str() const {
129 switch (GetType()) {
130 case Char:
131 return Common::UTF8ToUTF16(string);
132 case Wchar:
133 return u16str;
134 case Empty:
135 return {};
136 case Invalid:
137 case Binary:
138 // TODO(yuriks): Add assert
139 LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!");
140 return {};
141 }
142 }
143
144 const std::vector<u8> AsBinary() const {
145 switch (GetType()) {
146 case Binary:
147 return binary;
148 case Char:
149 return std::vector<u8>(string.begin(), string.end());
150 case Wchar:
151 {
152 // use two u8 for each character of u16str
153 std::vector<u8> to_return(u16str.size() * 2);
154 for (size_t i = 0; i < u16str.size(); ++i) {
155 u16 tmp_char = u16str.at(i);
156 to_return[i*2] = (tmp_char & 0xFF00) >> 8;
157 to_return[i*2 + 1] = (tmp_char & 0x00FF);
158 }
159 return to_return;
160 }
161 case Empty:
162 return {};
163 case Invalid:
164 default:
165 // TODO(yuriks): Add assert
166 LOG_ERROR(Service_FS, "LowPathType cannot be converted to binary!");
167 return {};
168 }
169 }
170 57
171private: 58private:
172 LowPathType type; 59 LowPathType type;
diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp
index 3076fa263..38d498d0e 100644
--- a/src/core/file_sys/archive_extsavedata.cpp
+++ b/src/core/file_sys/archive_extsavedata.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
9#include "common/make_unique.h" 10#include "common/make_unique.h"
10 11
11#include "core/file_sys/archive_extsavedata.h" 12#include "core/file_sys/archive_extsavedata.h"
diff --git a/src/core/file_sys/archive_romfs.cpp b/src/core/file_sys/archive_romfs.cpp
index bf54a3866..d4a12ed10 100644
--- a/src/core/file_sys/archive_romfs.cpp
+++ b/src/core/file_sys/archive_romfs.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
9#include "common/make_unique.h" 10#include "common/make_unique.h"
10 11
11#include "core/file_sys/archive_romfs.h" 12#include "core/file_sys/archive_romfs.h"
diff --git a/src/core/file_sys/archive_savedata.cpp b/src/core/file_sys/archive_savedata.cpp
index 8496e06f3..12624fa31 100644
--- a/src/core/file_sys/archive_savedata.cpp
+++ b/src/core/file_sys/archive_savedata.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
9#include "common/make_unique.h" 10#include "common/make_unique.h"
10 11
11#include "core/file_sys/archive_savedata.h" 12#include "core/file_sys/archive_savedata.h"
diff --git a/src/core/file_sys/archive_savedatacheck.cpp b/src/core/file_sys/archive_savedatacheck.cpp
index 47d8a9d25..e7e4fbf1d 100644
--- a/src/core/file_sys/archive_savedatacheck.cpp
+++ b/src/core/file_sys/archive_savedatacheck.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/file_util.h" 5#include "common/file_util.h"
6#include "common/logging/log.h"
6#include "common/make_unique.h" 7#include "common/make_unique.h"
7 8
8#include "core/file_sys/archive_savedatacheck.h" 9#include "core/file_sys/archive_savedatacheck.h"
diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp
index 92b20c7f6..c1234a186 100644
--- a/src/core/file_sys/archive_sdmc.cpp
+++ b/src/core/file_sys/archive_sdmc.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
9#include "common/make_unique.h" 10#include "common/make_unique.h"
10 11
11#include "core/file_sys/archive_sdmc.h" 12#include "core/file_sys/archive_sdmc.h"
diff --git a/src/core/file_sys/directory_backend.h b/src/core/file_sys/directory_backend.h
index 7f327dc42..a25dc0cfa 100644
--- a/src/core/file_sys/directory_backend.h
+++ b/src/core/file_sys/directory_backend.h
@@ -4,12 +4,11 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
7#include <cstddef> 8#include <cstddef>
8 9
9#include "common/common_types.h" 10#include "common/common_types.h"
10 11
11#include "core/hle/kernel/kernel.h"
12
13//////////////////////////////////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////////////////////////////////
14// FileSys namespace 13// FileSys namespace
15 14
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index f53fd57db..9980cced1 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
9#include "common/make_unique.h" 10#include "common/make_unique.h"
10 11
11#include "core/file_sys/disk_archive.h" 12#include "core/file_sys/disk_archive.h"
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h
index 770bd715e..a22d3837a 100644
--- a/src/core/file_sys/disk_archive.h
+++ b/src/core/file_sys/disk_archive.h
@@ -8,6 +8,8 @@
8#include "common/file_util.h" 8#include "common/file_util.h"
9 9
10#include "core/file_sys/archive_backend.h" 10#include "core/file_sys/archive_backend.h"
11#include "core/file_sys/directory_backend.h"
12#include "core/file_sys/file_backend.h"
11#include "core/loader/loader.h" 13#include "core/loader/loader.h"
12 14
13//////////////////////////////////////////////////////////////////////////////////////////////////// 15////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/file_sys/file_backend.h b/src/core/file_sys/file_backend.h
index 35890af1f..0fcff1845 100644
--- a/src/core/file_sys/file_backend.h
+++ b/src/core/file_sys/file_backend.h
@@ -6,8 +6,6 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8 8
9#include "core/hle/kernel/kernel.h"
10
11//////////////////////////////////////////////////////////////////////////////////////////////////// 9////////////////////////////////////////////////////////////////////////////////////////////////////
12// FileSys namespace 10// FileSys namespace
13 11
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp
index 35aca54fa..2d2509d16 100644
--- a/src/core/file_sys/ivfc_archive.cpp
+++ b/src/core/file_sys/ivfc_archive.cpp
@@ -6,6 +6,7 @@
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/file_util.h" 8#include "common/file_util.h"
9#include "common/logging/log.h"
9#include "common/make_unique.h" 10#include "common/make_unique.h"
10 11
11#include "core/file_sys/ivfc_archive.h" 12#include "core/file_sys/ivfc_archive.h"
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h
index 1aff9e0a4..10415798d 100644
--- a/src/core/file_sys/ivfc_archive.h
+++ b/src/core/file_sys/ivfc_archive.h
@@ -10,6 +10,8 @@
10#include "common/common_types.h" 10#include "common/common_types.h"
11 11
12#include "core/file_sys/archive_backend.h" 12#include "core/file_sys/archive_backend.h"
13#include "core/file_sys/directory_backend.h"
14#include "core/file_sys/file_backend.h"
13#include "core/loader/loader.h" 15#include "core/loader/loader.h"
14 16
15//////////////////////////////////////////////////////////////////////////////////////////////////// 17////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/hle/config_mem.cpp b/src/core/hle/config_mem.cpp
index 9fcfcc285..35dc9cf58 100644
--- a/src/core/hle/config_mem.cpp
+++ b/src/core/hle/config_mem.cpp
@@ -2,6 +2,9 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6
7#include "common/assert.h"
5#include "common/common_types.h" 8#include "common/common_types.h"
6#include "common/common_funcs.h" 9#include "common/common_funcs.h"
7 10
@@ -61,7 +64,7 @@ template void Read<u16>(u16 &var, const u32 addr);
61template void Read<u8>(u8 &var, const u32 addr); 64template void Read<u8>(u8 &var, const u32 addr);
62 65
63void Init() { 66void Init() {
64 memset(&config_mem, 0, sizeof(config_mem)); 67 std::memset(&config_mem, 0, sizeof(config_mem));
65 68
66 config_mem.update_flag = 0; // No update 69 config_mem.update_flag = 0; // No update
67 config_mem.sys_core_ver = 0x2; 70 config_mem.sys_core_ver = 0x2;
diff --git a/src/core/hle/hle.h b/src/core/hle/hle.h
index 23de1aab7..e0b97797c 100644
--- a/src/core/hle/hle.h
+++ b/src/core/hle/hle.h
@@ -4,6 +4,13 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h"
8
9typedef u32 Handle;
10typedef s32 Result;
11
12const Handle INVALID_HANDLE = 0;
13
7namespace HLE { 14namespace HLE {
8 15
9extern bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread 16extern bool g_reschedule; ///< If true, immediately reschedules the CPU to a new thread
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 19135266c..9d7f6b280 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/logging/log.h"
6 7
7#include "core/mem_map.h" 8#include "core/mem_map.h"
8 9
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
index 420906ec0..f338f3266 100644
--- a/src/core/hle/kernel/event.cpp
+++ b/src/core/hle/kernel/event.cpp
@@ -6,7 +6,7 @@
6#include <algorithm> 6#include <algorithm>
7#include <vector> 7#include <vector>
8 8
9#include "common/common.h" 9#include "common/assert.h"
10 10
11#include "core/hle/kernel/kernel.h" 11#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/event.h" 12#include "core/hle/kernel/event.h"
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index fca582bbe..533fe65fd 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -4,7 +4,8 @@
4 4
5#include <algorithm> 5#include <algorithm>
6 6
7#include "common/common.h" 7#include "common/assert.h"
8#include "common/logging/log.h"
8 9
9#include "core/arm/arm_interface.h" 10#include "core/arm/arm_interface.h"
10#include "core/core.h" 11#include "core/core.h"
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index ab06fa025..a7bc6b71a 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -10,18 +10,10 @@
10#include <string> 10#include <string>
11#include <vector> 11#include <vector>
12 12
13#include "common/common.h" 13#include "common/common_types.h"
14#include "core/hle/result.h"
15
16typedef u32 Handle;
17typedef s32 Result;
18 14
19// TODO: It would be nice to eventually replace these with strong types that prevent accidental 15#include "core/hle/hle.h"
20// conversion between each other. 16#include "core/hle/result.h"
21typedef u32 VAddr; ///< Represents a pointer in the userspace virtual address space.
22typedef u32 PAddr; ///< Represents a pointer in the ARM11 physical address space.
23
24const Handle INVALID_HANDLE = 0;
25 17
26namespace Kernel { 18namespace Kernel {
27 19
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index ebc9e79d7..f530217fd 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -7,7 +7,7 @@
7 7
8#include <boost/range/algorithm_ext/erase.hpp> 8#include <boost/range/algorithm_ext/erase.hpp>
9 9
10#include "common/common.h" 10#include "common/assert.h"
11 11
12#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
13#include "core/hle/kernel/mutex.h" 13#include "core/hle/kernel/mutex.h"
diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp
index 6aecc24aa..5d6543ef4 100644
--- a/src/core/hle/kernel/semaphore.cpp
+++ b/src/core/hle/kernel/semaphore.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/assert.h"
6 6
7#include "core/hle/kernel/kernel.h" 7#include "core/hle/kernel/kernel.h"
8#include "core/hle/kernel/semaphore.h" 8#include "core/hle/kernel/semaphore.h"
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 9b2511b53..cb5c16696 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/logging/log.h"
6 6
7#include "core/mem_map.h" 7#include "core/mem_map.h"
8#include "core/hle/kernel/shared_memory.h" 8#include "core/hle/kernel/shared_memory.h"
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index d678f5f6f..9577b889a 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -6,7 +6,9 @@
6#include <list> 6#include <list>
7#include <vector> 7#include <vector>
8 8
9#include "common/common.h" 9#include "common/assert.h"
10#include "common/common_types.h"
11#include "common/logging/log.h"
10#include "common/math_util.h" 12#include "common/math_util.h"
11#include "common/thread_queue_list.h" 13#include "common/thread_queue_list.h"
12 14
diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp
index 36979248d..e69fece65 100644
--- a/src/core/hle/kernel/timer.cpp
+++ b/src/core/hle/kernel/timer.cpp
@@ -2,7 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/assert.h"
6#include "common/logging/log.h"
6 7
7#include "core/core_timing.h" 8#include "core/core_timing.h"
8#include "core/hle/kernel/kernel.h" 9#include "core/hle/kernel/kernel.h"
diff --git a/src/core/hle/result.h b/src/core/hle/result.h
index 3648a168b..ce633d841 100644
--- a/src/core/hle/result.h
+++ b/src/core/hle/result.h
@@ -8,6 +8,7 @@
8#include <type_traits> 8#include <type_traits>
9#include <utility> 9#include <utility>
10 10
11#include "common/assert.h"
11#include "common/bit_field.h" 12#include "common/bit_field.h"
12#include "common/common_funcs.h" 13#include "common/common_funcs.h"
13#include "common/common_types.h" 14#include "common/common_types.h"
diff --git a/src/core/hle/service/am_sys.cpp b/src/core/hle/service/am_sys.cpp
index b244190a2..f9e3fe4b7 100644
--- a/src/core/hle/service/am_sys.cpp
+++ b/src/core/hle/service/am_sys.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/service/am_sys.h" 8#include "core/hle/service/am_sys.h"
7 9
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp
index 98ae80b3a..560c9dcf6 100644
--- a/src/core/hle/service/apt/apt.cpp
+++ b/src/core/hle/service/apt/apt.cpp
@@ -2,7 +2,9 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_paths.h"
5#include "common/file_util.h" 6#include "common/file_util.h"
7#include "common/logging/log.h"
6 8
7#include "core/hle/service/service.h" 9#include "core/hle/service/service.h"
8#include "core/hle/service/apt/apt.h" 10#include "core/hle/service/apt/apt.h"
diff --git a/src/core/hle/service/apt/apt_s.cpp b/src/core/hle/service/apt/apt_s.cpp
index 3fd348651..396d1f04a 100644
--- a/src/core/hle/service/apt/apt_s.cpp
+++ b/src/core/hle/service/apt/apt_s.cpp
@@ -3,9 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5 5
6#include "common/common.h"
7#include "common/file_util.h"
8
9#include "core/hle/hle.h" 6#include "core/hle/hle.h"
10#include "core/hle/service/apt/apt.h" 7#include "core/hle/service/apt/apt.h"
11#include "core/hle/service/apt/apt_s.h" 8#include "core/hle/service/apt/apt_s.h"
diff --git a/src/core/hle/service/apt/apt_u.cpp b/src/core/hle/service/apt/apt_u.cpp
index 5ab23801e..d006b5930 100644
--- a/src/core/hle/service/apt/apt_u.cpp
+++ b/src/core/hle/service/apt/apt_u.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5 5
6#include "common/common.h"
7#include "common/file_util.h" 6#include "common/file_util.h"
8 7
9#include "core/hle/service/apt/apt.h" 8#include "core/hle/service/apt/apt.h"
diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp
index 5eccdecf7..2d26c9330 100644
--- a/src/core/hle/service/cfg/cfg.cpp
+++ b/src/core/hle/service/cfg/cfg.cpp
@@ -4,12 +4,16 @@
4 4
5#include <algorithm> 5#include <algorithm>
6 6
7#include "core/hle/service/fs/archive.h" 7#include "common/logging/log.h"
8#include "core/hle/service/service.h" 8#include "common/string_util.h"
9
10#include "core/file_sys/file_backend.h"
9#include "core/hle/service/cfg/cfg.h" 11#include "core/hle/service/cfg/cfg.h"
10#include "core/hle/service/cfg/cfg_i.h" 12#include "core/hle/service/cfg/cfg_i.h"
11#include "core/hle/service/cfg/cfg_s.h" 13#include "core/hle/service/cfg/cfg_s.h"
12#include "core/hle/service/cfg/cfg_u.h" 14#include "core/hle/service/cfg/cfg_u.h"
15#include "core/hle/service/fs/archive.h"
16#include "core/hle/service/service.h"
13 17
14namespace Service { 18namespace Service {
15namespace CFG { 19namespace CFG {
diff --git a/src/core/hle/service/cfg/cfg_u.cpp b/src/core/hle/service/cfg/cfg_u.cpp
index c8c1c5b17..221de9918 100644
--- a/src/core/hle/service/cfg/cfg_u.cpp
+++ b/src/core/hle/service/cfg/cfg_u.cpp
@@ -3,7 +3,9 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/file_util.h" 5#include "common/file_util.h"
6#include "common/logging/log.h"
6#include "common/string_util.h" 7#include "common/string_util.h"
8
7#include "core/settings.h" 9#include "core/settings.h"
8#include "core/file_sys/archive_systemsavedata.h" 10#include "core/file_sys/archive_systemsavedata.h"
9#include "core/hle/hle.h" 11#include "core/hle/hle.h"
diff --git a/src/core/hle/service/dsp_dsp.cpp b/src/core/hle/service/dsp_dsp.cpp
index 2e759a3e3..20dc4d648 100644
--- a/src/core/hle/service/dsp_dsp.cpp
+++ b/src/core/hle/service/dsp_dsp.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/kernel/event.h" 8#include "core/hle/kernel/event.h"
7#include "core/hle/service/dsp_dsp.h" 9#include "core/hle/service/dsp_dsp.h"
diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp
index 58c5acd1e..e8c06c1cf 100644
--- a/src/core/hle/service/err_f.cpp
+++ b/src/core/hle/service/err_f.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/service/err_f.h" 8#include "core/hle/service/err_f.h"
7 9
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index b0fd834c7..6d4a9c7c9 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -9,6 +9,7 @@
9 9
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/file_util.h" 11#include "common/file_util.h"
12#include "common/logging/log.h"
12#include "common/make_unique.h" 13#include "common/make_unique.h"
13#include "common/math_util.h" 14#include "common/math_util.h"
14 15
@@ -78,6 +79,11 @@ enum class DirectoryCommand : u32 {
78 Close = 0x08020000, 79 Close = 0x08020000,
79}; 80};
80 81
82File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path & path)
83 : path(path), priority(0), backend(std::move(backend)) {}
84
85File::~File() {}
86
81ResultVal<bool> File::SyncRequest() { 87ResultVal<bool> File::SyncRequest() {
82 u32* cmd_buff = Kernel::GetCommandBuffer(); 88 u32* cmd_buff = Kernel::GetCommandBuffer();
83 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); 89 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
@@ -172,6 +178,11 @@ ResultVal<bool> File::SyncRequest() {
172 return MakeResult<bool>(false); 178 return MakeResult<bool>(false);
173} 179}
174 180
181Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path & path)
182 : path(path), backend(std::move(backend)) {}
183
184Directory::~Directory() {}
185
175ResultVal<bool> Directory::SyncRequest() { 186ResultVal<bool> Directory::SyncRequest() {
176 u32* cmd_buff = Kernel::GetCommandBuffer(); 187 u32* cmd_buff = Kernel::GetCommandBuffer();
177 DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); 188 DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index b00f0fd60..faab0cb79 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -45,31 +45,27 @@ typedef u64 ArchiveHandle;
45 45
46class File : public Kernel::Session { 46class File : public Kernel::Session {
47public: 47public:
48 File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path) 48 File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path& path);
49 : path(path), priority(0), backend(std::move(backend)) { 49 ~File();
50 }
51 50
52 std::string GetName() const override { return "Path: " + path.DebugStr(); } 51 std::string GetName() const override { return "Path: " + path.DebugStr(); }
52 ResultVal<bool> SyncRequest() override;
53 53
54 FileSys::Path path; ///< Path of the file 54 FileSys::Path path; ///< Path of the file
55 u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means 55 u32 priority; ///< Priority of the file. TODO(Subv): Find out what this means
56 std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface 56 std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
57
58 ResultVal<bool> SyncRequest() override;
59}; 57};
60 58
61class Directory : public Kernel::Session { 59class Directory : public Kernel::Session {
62public: 60public:
63 Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path) 61 Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, const FileSys::Path& path);
64 : path(path), backend(std::move(backend)) { 62 ~Directory();
65 }
66 63
67 std::string GetName() const override { return "Directory: " + path.DebugStr(); } 64 std::string GetName() const override { return "Directory: " + path.DebugStr(); }
65 ResultVal<bool> SyncRequest() override;
68 66
69 FileSys::Path path; ///< Path of the directory 67 FileSys::Path path; ///< Path of the directory
70 std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface 68 std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
71
72 ResultVal<bool> SyncRequest() override;
73}; 69};
74 70
75/** 71/**
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 5bc94b1b1..0d2a426b0 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -2,10 +2,13 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/assert.h"
6#include "common/common_types.h"
6#include "common/file_util.h" 7#include "common/file_util.h"
8#include "common/logging/log.h"
7#include "common/scope_exit.h" 9#include "common/scope_exit.h"
8#include "common/string_util.h" 10#include "common/string_util.h"
11
9#include "core/hle/result.h" 12#include "core/hle/result.h"
10#include "core/hle/service/fs/archive.h" 13#include "core/hle/service/fs/archive.h"
11#include "core/hle/service/fs/fs_user.h" 14#include "core/hle/service/fs/fs_user.h"
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 0f30f743a..dd85848d0 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
6#include "core/hle/service/hid/hid.h" 8#include "core/hle/service/hid/hid.h"
7#include "core/hle/service/hid/hid_spvr.h" 9#include "core/hle/service/hid/hid_spvr.h"
diff --git a/src/core/hle/service/ldr_ro.cpp b/src/core/hle/service/ldr_ro.cpp
index c0c4a2344..155b97f69 100644
--- a/src/core/hle/service/ldr_ro.cpp
+++ b/src/core/hle/service/ldr_ro.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/service/ldr_ro.h" 8#include "core/hle/service/ldr_ro.h"
7 9
diff --git a/src/core/hle/service/nim_u.cpp b/src/core/hle/service/nim_u.cpp
index a87d17ef0..5f13bd98e 100644
--- a/src/core/hle/service/nim_u.cpp
+++ b/src/core/hle/service/nim_u.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/service/nim_u.h" 8#include "core/hle/service/nim_u.h"
7 9
diff --git a/src/core/hle/service/ns_s.cpp b/src/core/hle/service/ns_s.cpp
index 5cf3e2039..6b3ef6ece 100644
--- a/src/core/hle/service/ns_s.cpp
+++ b/src/core/hle/service/ns_s.cpp
@@ -3,8 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5 5
6#include "common/common.h"
7
8#include "core/hle/hle.h" 6#include "core/hle/hle.h"
9#include "core/hle/service/ns_s.h" 7#include "core/hle/service/ns_s.h"
10 8
diff --git a/src/core/hle/service/nwm_uds.cpp b/src/core/hle/service/nwm_uds.cpp
index 4b06efc3a..25b01860e 100644
--- a/src/core/hle/service/nwm_uds.cpp
+++ b/src/core/hle/service/nwm_uds.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/kernel/event.h" 8#include "core/hle/kernel/event.h"
7#include "core/hle/service/nwm_uds.h" 9#include "core/hle/service/nwm_uds.h"
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp
index d44510c1b..6480a323d 100644
--- a/src/core/hle/service/ptm/ptm.cpp
+++ b/src/core/hle/service/ptm/ptm.cpp
@@ -2,12 +2,13 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "core/hle/service/service.h" 5#include "core/file_sys/file_backend.h"
6#include "core/hle/service/fs/archive.h" 6#include "core/hle/service/fs/archive.h"
7#include "core/hle/service/ptm/ptm.h" 7#include "core/hle/service/ptm/ptm.h"
8#include "core/hle/service/ptm/ptm_play.h" 8#include "core/hle/service/ptm/ptm_play.h"
9#include "core/hle/service/ptm/ptm_sysm.h" 9#include "core/hle/service/ptm/ptm_sysm.h"
10#include "core/hle/service/ptm/ptm_u.h" 10#include "core/hle/service/ptm/ptm_u.h"
11#include "core/hle/service/service.h"
11 12
12namespace Service { 13namespace Service {
13namespace PTM { 14namespace PTM {
diff --git a/src/core/hle/service/ptm/ptm_u.cpp b/src/core/hle/service/ptm/ptm_u.cpp
index 0af7c8bf6..9d6a5b0d7 100644
--- a/src/core/hle/service/ptm/ptm_u.cpp
+++ b/src/core/hle/service/ptm/ptm_u.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/make_unique.h" 5#include "common/logging/log.h"
6 6
7#include "core/hle/hle.h" 7#include "core/hle/hle.h"
8#include "core/hle/service/ptm/ptm.h" 8#include "core/hle/service/ptm/ptm.h"
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index d50327cb9..64185c62e 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/logging/log.h"
6#include "common/string_util.h" 6#include "common/string_util.h"
7 7
8#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 21ada67b5..77bfb9ff1 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -9,7 +9,7 @@
9 9
10#include <boost/container/flat_map.hpp> 10#include <boost/container/flat_map.hpp>
11 11
12#include "common/common.h" 12#include "common/common_types.h"
13 13
14#include "core/hle/kernel/kernel.h" 14#include "core/hle/kernel/kernel.h"
15#include "core/hle/kernel/session.h" 15#include "core/hle/kernel/session.h"
diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp
index 231ead185..39b8d65fd 100644
--- a/src/core/hle/service/soc_u.cpp
+++ b/src/core/hle/service/soc_u.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
5#include "common/platform.h" 6#include "common/platform.h"
6 7
7#if EMU_PLATFORM == PLATFORM_WINDOWS 8#if EMU_PLATFORM == PLATFORM_WINDOWS
diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp
index cc59a03ce..6c49fa6cf 100644
--- a/src/core/hle/service/srv.cpp
+++ b/src/core/hle/service/srv.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/service/srv.h" 8#include "core/hle/service/srv.h"
7#include "core/hle/kernel/event.h" 9#include "core/hle/kernel/event.h"
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp
index 33ecf64a2..085192a07 100644
--- a/src/core/hle/service/y2r_u.cpp
+++ b/src/core/hle/service/y2r_u.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h"
6
5#include "core/hle/hle.h" 7#include "core/hle/hle.h"
6#include "core/hle/kernel/event.h" 8#include "core/hle/kernel/event.h"
7#include "core/hle/service/y2r_u.h" 9#include "core/hle/service/y2r_u.h"
diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp
index 94fae2551..4f227a370 100644
--- a/src/core/hle/shared_page.cpp
+++ b/src/core/hle/shared_page.cpp
@@ -2,6 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6
5#include "common/common_types.h" 7#include "common/common_types.h"
6#include "common/common_funcs.h" 8#include "common/common_funcs.h"
7 9
@@ -62,7 +64,7 @@ template void Read<u16>(u16 &var, const u32 addr);
62template void Read<u8>(u8 &var, const u32 addr); 64template void Read<u8>(u8 &var, const u32 addr);
63 65
64void Set3DSlider(float amount) { 66void Set3DSlider(float amount) {
65 memset(&shared_page, 0, sizeof(shared_page)); 67 std::memset(&shared_page, 0, sizeof(shared_page));
66 68
67 shared_page.sliderstate_3d = amount; 69 shared_page.sliderstate_3d = amount;
68 shared_page.ledstate_3d = (amount == 0.0f); // off when non-zero 70 shared_page.ledstate_3d = (amount == 0.0f); // off when non-zero
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 2da488d83..393cfbe79 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -4,6 +4,7 @@
4 4
5#include <map> 5#include <map>
6 6
7#include "common/logging/log.h"
7#include "common/profiler.h" 8#include "common/profiler.h"
8#include "common/string_util.h" 9#include "common/string_util.h"
9#include "common/symbols.h" 10#include "common/symbols.h"
@@ -311,7 +312,7 @@ static ResultCode GetResourceLimit(Handle* resource_limit, Handle process) {
311/// Get resource limit current values 312/// Get resource limit current values
312static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names, 313static ResultCode GetResourceLimitCurrentValues(s64* values, Handle resource_limit, void* names,
313 s32 name_count) { 314 s32 name_count) {
314 LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%s, name_count=%d", 315 LOG_ERROR(Kernel_SVC, "(UNIMPLEMENTED) called resource_limit=%08X, names=%p, name_count=%d",
315 resource_limit, names, name_count); 316 resource_limit, names, name_count);
316 Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now 317 Memory::Write32(Core::g_app_core->GetReg(0), 0); // Normmatt: Set used memory to 0 for now
317 return RESULT_SUCCESS; 318 return RESULT_SUCCESS;
diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h
index c8f884494..699bcd2a5 100644
--- a/src/core/hw/gpu.h
+++ b/src/core/hw/gpu.h
@@ -6,8 +6,10 @@
6 6
7#include <cstddef> 7#include <cstddef>
8 8
9#include "common/common_types.h" 9#include "common/assert.h"
10#include "common/bit_field.h" 10#include "common/bit_field.h"
11#include "common/common_funcs.h"
12#include "common/common_types.h"
11 13
12namespace GPU { 14namespace GPU {
13 15
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 236958139..f4906cc7e 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common_types.h" 5#include "common/common_types.h"
6#include "common/logging/log.h"
6 7
7#include "core/hw/hw.h" 8#include "core/hw/hw.h"
8#include "core/hw/gpu.h" 9#include "core/hw/gpu.h"
diff --git a/src/core/hw/lcd.cpp b/src/core/hw/lcd.cpp
index 8a09c3bc0..09134c95b 100644
--- a/src/core/hw/lcd.cpp
+++ b/src/core/hw/lcd.cpp
@@ -2,7 +2,10 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <cstring>
6
5#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/logging/log.h"
6 9
7#include "core/arm/arm_interface.h" 10#include "core/arm/arm_interface.h"
8#include "core/hle/hle.h" 11#include "core/hle/hle.h"
diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h
index 43893a625..fb14c3b21 100644
--- a/src/core/hw/lcd.h
+++ b/src/core/hw/lcd.h
@@ -6,8 +6,9 @@
6 6
7#include <cstddef> 7#include <cstddef>
8 8
9#include "common/common_types.h"
10#include "common/bit_field.h" 9#include "common/bit_field.h"
10#include "common/common_funcs.h"
11#include "common/common_types.h"
11 12
12#define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32)) 13#define LCD_REG_INDEX(field_name) (offsetof(LCD::Regs, field_name) / sizeof(u32))
13 14
diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp
index 958dd03e8..5d806c5d0 100644
--- a/src/core/loader/3dsx.cpp
+++ b/src/core/loader/3dsx.cpp
@@ -5,6 +5,8 @@
5#include <algorithm> 5#include <algorithm>
6#include <vector> 6#include <vector>
7 7
8#include "common/logging/log.h"
9
8#include "core/file_sys/archive_romfs.h" 10#include "core/file_sys/archive_romfs.h"
9#include "core/loader/elf.h" 11#include "core/loader/elf.h"
10#include "core/loader/ncch.h" 12#include "core/loader/ncch.h"
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 773eaf771..467e91924 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -5,8 +5,9 @@
5#include <string> 5#include <string>
6#include <memory> 6#include <memory>
7 7
8#include "common/common.h" 8#include "common/common_types.h"
9#include "common/file_util.h" 9#include "common/file_util.h"
10#include "common/logging/log.h"
10#include "common/symbols.h" 11#include "common/symbols.h"
11 12
12#include "core/mem_map.h" 13#include "core/mem_map.h"
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index aca09b374..de0ab540a 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -4,6 +4,7 @@
4 4
5#include <string> 5#include <string>
6 6
7#include "common/logging/log.h"
7#include "common/make_unique.h" 8#include "common/make_unique.h"
8 9
9#include "core/file_sys/archive_romfs.h" 10#include "core/file_sys/archive_romfs.h"
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 3510c6b28..2b87239cf 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -6,7 +6,7 @@
6 6
7#include <vector> 7#include <vector>
8 8
9#include "common/common.h" 9#include "common/common_types.h"
10#include "common/file_util.h" 10#include "common/file_util.h"
11 11
12//////////////////////////////////////////////////////////////////////////////////////////////////// 12////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 4efed78bf..9bce2b79d 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -4,6 +4,8 @@
4 4
5#include <memory> 5#include <memory>
6 6
7#include "common/logging/log.h"
8
7#include "core/loader/ncch.h" 9#include "core/loader/ncch.h"
8#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
9#include "core/mem_map.h" 11#include "core/mem_map.h"
diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h
index 3dd151dbd..44c72a4e2 100644
--- a/src/core/loader/ncch.h
+++ b/src/core/loader/ncch.h
@@ -4,7 +4,9 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include <memory>
8
9#include "common/common_types.h"
8 10
9#include "core/loader/loader.h" 11#include "core/loader/loader.h"
10 12
diff --git a/src/core/mem_map.cpp b/src/core/mem_map.cpp
index 22e359b3e..ae88cfb11 100644
--- a/src/core/mem_map.cpp
+++ b/src/core/mem_map.cpp
@@ -2,7 +2,9 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/common_funcs.h"
6#include "common/common_types.h"
7#include "common/logging/log.h"
6#include "common/mem_arena.h" 8#include "common/mem_arena.h"
7 9
8#include "core/mem_map.h" 10#include "core/mem_map.h"
diff --git a/src/core/mem_map.h b/src/core/mem_map.h
index 1af02973b..b11f2ea68 100644
--- a/src/core/mem_map.h
+++ b/src/core/mem_map.h
@@ -4,11 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h"
8#include "common/common_types.h" 7#include "common/common_types.h"
9 8
10#include "core/hle/kernel/kernel.h"
11
12namespace Memory { 9namespace Memory {
13 10
14//////////////////////////////////////////////////////////////////////////////////////////////////// 11////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index 8759ebdfb..9a19c9bf8 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -4,7 +4,9 @@
4 4
5#include <map> 5#include <map>
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8#include "common/logging/log.h"
9#include "common/swap.h"
8 10
9#include "core/mem_map.h" 11#include "core/mem_map.h"
10#include "core/hw/hw.h" 12#include "core/hw/hw.h"
diff --git a/src/video_core/color.h b/src/video_core/color.h
index 43d635e2c..4d2026eb0 100644
--- a/src/video_core/color.h
+++ b/src/video_core/color.h
@@ -5,6 +5,8 @@
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include "common/common_types.h"
8#include "common/swap.h"
9
8#include "video_core/math.h" 10#include "video_core/math.h"
9 11
10namespace Color { 12namespace Color {
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
index 8acad8676..a0ba715f3 100644
--- a/src/video_core/pica.h
+++ b/src/video_core/pica.h
@@ -10,8 +10,11 @@
10#include <map> 10#include <map>
11#include <vector> 11#include <vector>
12 12
13#include "common/assert.h"
13#include "common/bit_field.h" 14#include "common/bit_field.h"
15#include "common/common_funcs.h"
14#include "common/common_types.h" 16#include "common/common_types.h"
17#include "common/logging/log.h"
15 18
16#include "core/mem_map.h" 19#include "core/mem_map.h"
17 20
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h
index b77f29c11..b62409538 100644
--- a/src/video_core/renderer_base.h
+++ b/src/video_core/renderer_base.h
@@ -4,7 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h" 7#include "common/common_types.h"
8 8
9class RendererBase : NonCopyable { 9class RendererBase : NonCopyable {
10public: 10public:
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 5e864b75e..6b242a6ed 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -9,6 +9,7 @@
9#include "core/settings.h" 9#include "core/settings.h"
10 10
11#include "common/emu_window.h" 11#include "common/emu_window.h"
12#include "common/logging/log.h"
12#include "common/profiler_reporting.h" 13#include "common/profiler_reporting.h"
13 14
14#include "video_core/video_core.h" 15#include "video_core/video_core.h"
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index b9d4ede3a..42e3bdd5b 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -2,7 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/common.h" 5#include "common/logging/log.h"
6#include "common/emu_window.h" 6#include "common/emu_window.h"
7 7
8#include "core/core.h" 8#include "core/core.h"
diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h
index 1b51d39bf..f885bec21 100644
--- a/src/video_core/video_core.h
+++ b/src/video_core/video_core.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common.h"
8#include "common/emu_window.h" 7#include "common/emu_window.h"
9 8
10#include "renderer_base.h" 9#include "renderer_base.h"