summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/assert.h1
-rw-r--r--src/common/bit_field.h1
-rw-r--r--src/common/chunk_file.h10
-rw-r--r--src/common/common_funcs.h11
-rw-r--r--src/common/common_types.h2
-rw-r--r--src/common/emu_window.cpp6
-rw-r--r--src/common/emu_window.h12
-rw-r--r--src/common/fifo_queue.h111
-rw-r--r--src/common/file_util.cpp11
-rw-r--r--src/common/file_util.h3
-rw-r--r--src/common/logging/filter.h1
-rw-r--r--src/common/logging/log.h4
-rw-r--r--src/common/make_unique.h1
-rw-r--r--src/common/memory_util.cpp11
-rw-r--r--src/common/memory_util.h4
-rw-r--r--src/common/misc.cpp5
-rw-r--r--src/common/platform.h55
-rw-r--r--src/common/profiler.cpp11
-rw-r--r--src/common/profiler_reporting.h5
-rw-r--r--src/common/string_util.cpp9
-rw-r--r--src/common/string_util.h3
-rw-r--r--src/common/swap.h10
-rw-r--r--src/common/synchronized_wrapper.h1
-rw-r--r--src/common/thread.cpp17
-rw-r--r--src/common/thread.h16
-rw-r--r--src/common/thunk.h42
27 files changed, 86 insertions, 279 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index e78f4f144..4c086cd2f 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -31,7 +31,6 @@ set(HEADERS
31 cpu_detect.h 31 cpu_detect.h
32 debug_interface.h 32 debug_interface.h
33 emu_window.h 33 emu_window.h
34 fifo_queue.h
35 file_util.h 34 file_util.h
36 key_map.h 35 key_map.h
37 linear_disk_cache.h 36 linear_disk_cache.h
@@ -53,7 +52,6 @@ set(HEADERS
53 synchronized_wrapper.h 52 synchronized_wrapper.h
54 thread.h 53 thread.h
55 thread_queue_list.h 54 thread_queue_list.h
56 thunk.h
57 timer.h 55 timer.h
58 vector_math.h 56 vector_math.h
59 ) 57 )
diff --git a/src/common/assert.h b/src/common/assert.h
index 7b7d8bf28..6849778b7 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <cstdio>
8#include <cstdlib> 7#include <cstdlib>
9 8
10#include "common/common_funcs.h" 9#include "common/common_funcs.h"
diff --git a/src/common/bit_field.h b/src/common/bit_field.h
index 1f3ecf844..6595b5ba4 100644
--- a/src/common/bit_field.h
+++ b/src/common/bit_field.h
@@ -32,6 +32,7 @@
32 32
33#pragma once 33#pragma once
34 34
35#include <cstddef>
35#include <limits> 36#include <limits>
36#include <type_traits> 37#include <type_traits>
37 38
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index dcd80525e..8be0b1109 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -26,16 +26,18 @@
26// - Zero backwards/forwards compatibility 26// - Zero backwards/forwards compatibility
27// - Serialization code for anything complex has to be manually written. 27// - Serialization code for anything complex has to be manually written.
28 28
29#include <map> 29#include <cstring>
30#include <vector>
31#include <deque> 30#include <deque>
32#include <string>
33#include <list> 31#include <list>
32#include <map>
34#include <set> 33#include <set>
34#include <string>
35#include <type_traits> 35#include <type_traits>
36#include <utility>
37#include <vector>
36 38
39#include "common/assert.h"
37#include "common/common_types.h" 40#include "common/common_types.h"
38#include "common/file_util.h"
39#include "common/logging/log.h" 41#include "common/logging/log.h"
40 42
41template <class T> 43template <class T>
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 91b74c6bc..c4fb3d9cc 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -5,15 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include "common_types.h" 7#include "common_types.h"
8#include <cstdlib>
9
10
11#define b2(x) ( (x) | ( (x) >> 1) )
12#define b4(x) ( b2(x) | ( b2(x) >> 2) )
13#define b8(x) ( b4(x) | ( b4(x) >> 4) )
14#define b16(x) ( b8(x) | ( b8(x) >> 8) )
15#define b32(x) (b16(x) | (b16(x) >>16) )
16#define ROUND_UP_POW2(x) (b32(x - 1) + 1)
17 8
18#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 9#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
19 10
@@ -43,8 +34,6 @@
43 34
44#ifndef _MSC_VER 35#ifndef _MSC_VER
45 36
46#include <errno.h>
47
48#if defined(__x86_64__) || defined(_M_X64) 37#if defined(__x86_64__) || defined(_M_X64)
49#define Crash() __asm__ __volatile__("int $3") 38#define Crash() __asm__ __volatile__("int $3")
50#elif defined(_M_ARM) 39#elif defined(_M_ARM)
diff --git a/src/common/common_types.h b/src/common/common_types.h
index c4f1d7ba4..fa3e0b8d6 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -24,9 +24,7 @@
24 24
25#pragma once 25#pragma once
26 26
27#include <cmath>
28#include <cstdint> 27#include <cstdint>
29#include <cstdlib>
30 28
31#ifdef _MSC_VER 29#ifdef _MSC_VER
32#ifndef __func__ 30#ifndef __func__
diff --git a/src/common/emu_window.cpp b/src/common/emu_window.cpp
index 43facb85c..b69b05cb9 100644
--- a/src/common/emu_window.cpp
+++ b/src/common/emu_window.cpp
@@ -2,6 +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 <algorithm>
6#include <cmath>
7
8#include "common/assert.h"
9#include "common/key_map.h"
10
5#include "emu_window.h" 11#include "emu_window.h"
6#include "video_core/video_core.h" 12#include "video_core/video_core.h"
7 13
diff --git a/src/common/emu_window.h b/src/common/emu_window.h
index 8eca6b5d5..a0ae4c9fa 100644
--- a/src/common/emu_window.h
+++ b/src/common/emu_window.h
@@ -4,11 +4,17 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <tuple>
8#include <utility>
9
7#include "common/common_types.h" 10#include "common/common_types.h"
8#include "common/key_map.h"
9#include "common/math_util.h" 11#include "common/math_util.h"
10#include "common/scm_rev.h" 12
11#include "common/string_util.h" 13#include "core/hle/service/hid/hid.h"
14
15namespace KeyMap {
16struct HostDeviceKey;
17}
12 18
13/** 19/**
14 * Abstraction class used to provide an interface between emulation code and the frontend 20 * Abstraction class used to provide an interface between emulation code and the frontend
diff --git a/src/common/fifo_queue.h b/src/common/fifo_queue.h
deleted file mode 100644
index b426e6596..000000000
--- a/src/common/fifo_queue.h
+++ /dev/null
@@ -1,111 +0,0 @@
1#pragma once
2
3// a simple lockless thread-safe,
4// single reader, single writer queue
5
6#include "common/atomic.h"
7
8namespace Common
9{
10
11template <typename T>
12class FifoQueue
13{
14public:
15 FifoQueue() : m_size(0)
16 {
17 m_write_ptr = m_read_ptr = new ElementPtr();
18 }
19
20 ~FifoQueue()
21 {
22 // this will empty out the whole queue
23 delete m_read_ptr;
24 }
25
26 u32 Size() const
27 {
28 return m_size;
29 }
30
31 bool Empty() const
32 {
33 //return (m_read_ptr == m_write_ptr);
34 return (0 == m_size);
35 }
36
37 T& Front() const
38 {
39 return *m_read_ptr->current;
40 }
41
42 template <typename Arg>
43 void Push(Arg&& t)
44 {
45 // create the element, add it to the queue
46 m_write_ptr->current = new T(std::forward<Arg>(t));
47 // set the next pointer to a new element ptr
48 // then advance the write pointer
49 m_write_ptr = m_write_ptr->next = new ElementPtr();
50 Common::AtomicIncrement(m_size);
51 }
52
53 void Pop()
54 {
55 Common::AtomicDecrement(m_size);
56 ElementPtr *const tmpptr = m_read_ptr;
57 // advance the read pointer
58 m_read_ptr = m_read_ptr->next;
59 // set the next element to NULL to stop the recursive deletion
60 tmpptr->next = nullptr;
61 delete tmpptr; // this also deletes the element
62 }
63
64 bool Pop(T& t)
65 {
66 if (Empty())
67 return false;
68
69 t = std::move(Front());
70 Pop();
71
72 return true;
73 }
74
75 // not thread-safe
76 void Clear()
77 {
78 m_size = 0;
79 delete m_read_ptr;
80 m_write_ptr = m_read_ptr = new ElementPtr();
81 }
82
83private:
84 // stores a pointer to element
85 // and a pointer to the next ElementPtr
86 class ElementPtr
87 {
88 public:
89 ElementPtr() : current(nullptr), next(nullptr) {}
90
91 ~ElementPtr()
92 {
93 if (current)
94 {
95 delete current;
96 // recusion ftw
97 if (next)
98 delete next;
99 }
100 }
101
102 T *volatile current;
103 ElementPtr *volatile next;
104 };
105
106 ElementPtr *volatile m_write_ptr;
107 ElementPtr *volatile m_read_ptr;
108 volatile u32 m_size;
109};
110
111}
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 24648ea33..836b58d52 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -17,6 +17,8 @@
17 #include <direct.h> // getcwd 17 #include <direct.h> // getcwd
18 #include <tchar.h> 18 #include <tchar.h>
19 19
20 #include "common/string_util.h"
21
20 // 64 bit offsets for windows 22 // 64 bit offsets for windows
21 #define fseeko _fseeki64 23 #define fseeko _fseeki64
22 #define ftello _ftelli64 24 #define ftello _ftelli64
@@ -25,8 +27,13 @@
25 #define fstat64 _fstat64 27 #define fstat64 _fstat64
26 #define fileno _fileno 28 #define fileno _fileno
27#else 29#else
28 #include <sys/param.h> 30 #ifdef __APPLE__
29 #include <sys/types.h> 31 #include <sys/param.h>
32 #endif
33 #include <cctype>
34 #include <cerrno>
35 #include <cstdlib>
36 #include <cstring>
30 #include <dirent.h> 37 #include <dirent.h>
31 #include <pwd.h> 38 #include <pwd.h>
32 #include <unistd.h> 39 #include <unistd.h>
diff --git a/src/common/file_util.h b/src/common/file_util.h
index b65829291..8fe772aee 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -6,13 +6,12 @@
6 6
7#include <array> 7#include <array>
8#include <fstream> 8#include <fstream>
9#include <cstddef>
9#include <cstdio> 10#include <cstdio>
10#include <cstring>
11#include <string> 11#include <string>
12#include <vector> 12#include <vector>
13 13
14#include "common/common_types.h" 14#include "common/common_types.h"
15#include "common/string_util.h"
16 15
17// User directory indices for GetUserPath 16// User directory indices for GetUserPath
18enum { 17enum {
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index 0b71ea3b2..a2b4eca43 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -5,6 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <cstddef>
8#include <string> 9#include <string>
9 10
10#include "common/logging/log.h" 11#include "common/logging/log.h"
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 5b3a731e9..e16dde7fc 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -4,10 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <cassert>
8#include <chrono>
9#include <string>
10
11#include "common/common_types.h" 7#include "common/common_types.h"
12 8
13namespace Log { 9namespace Log {
diff --git a/src/common/make_unique.h b/src/common/make_unique.h
index 2a7b76412..f6e7f017c 100644
--- a/src/common/make_unique.h
+++ b/src/common/make_unique.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm>
7#include <memory> 8#include <memory>
8 9
9namespace Common { 10namespace Common {
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index 20b791a10..2b3ace528 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -3,14 +3,17 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5 5
6#include "common/common_funcs.h"
7#include "common/logging/log.h" 6#include "common/logging/log.h"
8#include "common/memory_util.h" 7#include "common/memory_util.h"
9#include "common/string_util.h"
10 8
11#ifdef _WIN32 9#ifdef _WIN32
12#include <windows.h> 10 #include <windows.h>
13#include <psapi.h> 11 #include <psapi.h>
12 #include "common/common_funcs.h"
13 #include "common/string_util.h"
14#else
15 #include <cstdlib>
16 #include <sys/mman.h>
14#endif 17#endif
15 18
16#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT) 19#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
diff --git a/src/common/memory_util.h b/src/common/memory_util.h
index 9fdbf1f12..9bf37c44f 100644
--- a/src/common/memory_util.h
+++ b/src/common/memory_util.h
@@ -4,9 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#ifndef _WIN32 7#include <cstddef>
8#include <sys/mman.h>
9#endif
10#include <string> 8#include <string>
11 9
12void* AllocateExecutableMemory(size_t size, bool low = true); 10void* AllocateExecutableMemory(size_t size, bool low = true);
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 53cacf37c..d2a049b63 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.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 "common/common_funcs.h" 5#include <cstddef>
6 6
7#ifdef _WIN32 7#ifdef _WIN32
8#include <windows.h> 8#include <windows.h>
9#else 9#else
10#include <string.h> 10#include <cerrno>
11#include <cstring>
11#endif 12#endif
12 13
13// Neither Android nor OS X support TLS 14// Neither Android nor OS X support TLS
diff --git a/src/common/platform.h b/src/common/platform.h
index df780ac6f..0a912dda3 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -24,66 +24,11 @@
24 24
25#pragma once 25#pragma once
26 26
27#include "common/common_types.h"
28
29////////////////////////////////////////////////////////////////////////////////////////////////////
30// Platform definitions
31
32/// Enumeration for defining the supported platforms
33#define PLATFORM_NULL 0
34#define PLATFORM_WINDOWS 1
35#define PLATFORM_MACOSX 2
36#define PLATFORM_LINUX 3
37#define PLATFORM_ANDROID 4
38
39//////////////////////////////////////////////////////////////////////////////////////////////////// 27////////////////////////////////////////////////////////////////////////////////////////////////////
40// Platform detection 28// Platform detection
41 29
42#ifndef EMU_PLATFORM
43
44#if defined( __WIN32__ ) || defined( _WIN32 )
45#define EMU_PLATFORM PLATFORM_WINDOWS
46
47#elif defined( __APPLE__ ) || defined( __APPLE_CC__ )
48#define EMU_PLATFORM PLATFORM_MACOSX
49
50#elif defined(__linux__)
51#define EMU_PLATFORM PLATFORM_LINUX
52
53#else // Assume linux otherwise
54#define EMU_PLATFORM PLATFORM_LINUX
55
56#endif
57
58#endif
59
60#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) 30#if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__)
61 #define EMU_ARCH_BITS 64 31 #define EMU_ARCH_BITS 64
62#elif defined(__i386) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) 32#elif defined(__i386) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM)
63 #define EMU_ARCH_BITS 32 33 #define EMU_ARCH_BITS 32
64#endif 34#endif
65
66////////////////////////////////////////////////////////////////////////////////////////////////////
67// Feature detection
68
69#if defined _M_GENERIC
70# define _M_SSE 0x0
71#elif defined __GNUC__
72# if defined __SSE4_2__
73# define _M_SSE 0x402
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
83#endif
84
85////////////////////////////////////////////////////////////////////////////////////////////////////
86// Compiler-Specific Definitions
87
88#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \
89 (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
diff --git a/src/common/profiler.cpp b/src/common/profiler.cpp
index cf6b6b258..7792edd2f 100644
--- a/src/common/profiler.cpp
+++ b/src/common/profiler.cpp
@@ -2,13 +2,18 @@
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 <algorithm>
6#include <cstddef>
7#include <vector>
8
9#include "common/assert.h"
5#include "common/profiler.h" 10#include "common/profiler.h"
6#include "common/profiler_reporting.h" 11#include "common/profiler_reporting.h"
7#include "common/assert.h" 12#include "common/synchronized_wrapper.h"
8 13
9#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013. 14#if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013.
10#define WIN32_LEAN_AND_MEAN 15 #define WIN32_LEAN_AND_MEAN
11#include <Windows.h> // For QueryPerformanceCounter/Frequency 16 #include <Windows.h> // For QueryPerformanceCounter/Frequency
12#endif 17#endif
13 18
14namespace Common { 19namespace Common {
diff --git a/src/common/profiler_reporting.h b/src/common/profiler_reporting.h
index 3abb73315..df98e05b7 100644
--- a/src/common/profiler_reporting.h
+++ b/src/common/profiler_reporting.h
@@ -4,10 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <cstddef>
8#include <chrono>
9#include <mutex>
10#include <utility>
11#include <vector> 8#include <vector>
12 9
13#include "common/profiler.h" 10#include "common/profiler.h"
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 7dc0ba7ba..2e80809ab 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -2,9 +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 <boost/range/algorithm.hpp> 5#include <cctype>
6#include <cerrno>
7#include <cstdio>
8#include <cstdlib>
9#include <cstring>
10#include <boost/range/algorithm/transform.hpp>
6 11
7#include "common/common_funcs.h"
8#include "common/common_paths.h" 12#include "common/common_paths.h"
9#include "common/logging/log.h" 13#include "common/logging/log.h"
10#include "common/string_util.h" 14#include "common/string_util.h"
@@ -12,6 +16,7 @@
12#ifdef _MSC_VER 16#ifdef _MSC_VER
13 #include <Windows.h> 17 #include <Windows.h>
14 #include <codecvt> 18 #include <codecvt>
19 #include "common/common_funcs.h"
15#else 20#else
16 #include <iconv.h> 21 #include <iconv.h>
17#endif 22#endif
diff --git a/src/common/string_util.h b/src/common/string_util.h
index fdc410499..c5c474c6f 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -5,9 +5,10 @@
5#pragma once 5#pragma once
6 6
7#include <cstdarg> 7#include <cstdarg>
8#include <cstddef>
8#include <iomanip> 9#include <iomanip>
9#include <string>
10#include <sstream> 10#include <sstream>
11#include <string>
11#include <vector> 12#include <vector>
12 13
13#include "common/common_types.h" 14#include "common/common_types.h"
diff --git a/src/common/swap.h b/src/common/swap.h
index 588cebc70..b92e5bfa4 100644
--- a/src/common/swap.h
+++ b/src/common/swap.h
@@ -17,12 +17,16 @@
17 17
18#pragma once 18#pragma once
19 19
20#if defined(__linux__) 20#if defined(_MSC_VER)
21#include <byteswap.h> 21 #include <cstdlib>
22#elif defined(__linux__)
23 #include <byteswap.h>
22#elif defined(__FreeBSD__) 24#elif defined(__FreeBSD__)
23#include <sys/endian.h> 25 #include <sys/endian.h>
24#endif 26#endif
25 27
28#include "common/common_types.h"
29
26// GCC 4.6+ 30// GCC 4.6+
27#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) 31#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
28 32
diff --git a/src/common/synchronized_wrapper.h b/src/common/synchronized_wrapper.h
index 946252b8c..ae5e8b1ed 100644
--- a/src/common/synchronized_wrapper.h
+++ b/src/common/synchronized_wrapper.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <algorithm>
7#include <mutex> 8#include <mutex>
8 9
9namespace Common { 10namespace Common {
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index 8bf005857..7bbf080bc 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -5,11 +5,20 @@
5#include "common/thread.h" 5#include "common/thread.h"
6 6
7#ifdef __APPLE__ 7#ifdef __APPLE__
8#include <mach/mach.h> 8 #include <mach/mach.h>
9#elif defined(BSD4_4) || defined(__OpenBSD__)
10#include <pthread_np.h>
11#elif defined(_WIN32) 9#elif defined(_WIN32)
12#include <Windows.h> 10 #include <Windows.h>
11#else
12 #if defined(BSD4_4) || defined(__OpenBSD__)
13 #include <pthread_np.h>
14 #else
15 #include <pthread.h>
16 #endif
17 #include <sched.h>
18#endif
19
20#ifndef _WIN32
21 #include <unistd.h>
13#endif 22#endif
14 23
15namespace Common 24namespace Common
diff --git a/src/common/thread.h b/src/common/thread.h
index 7bc419497..8255ee6d3 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -4,24 +4,12 @@
4 4
5#pragma once 5#pragma once
6 6
7#include "common/common_types.h" 7#include <cstddef>
8#include <cstdio>
9#include <cstring>
10#include <thread> 8#include <thread>
11#include <condition_variable> 9#include <condition_variable>
12#include <mutex> 10#include <mutex>
13 11
14// This may not be defined outside _WIN32 12#include "common/common_types.h"
15#ifndef _WIN32
16#ifndef INFINITE
17#define INFINITE 0xffffffff
18#endif
19
20//for gettimeofday and struct time(spec|val)
21#include <time.h>
22#include <sys/time.h>
23#include <unistd.h>
24#endif
25 13
26// Support for C++11's thread_local keyword was surprisingly spotty in compilers until very 14// Support for C++11's thread_local keyword was surprisingly spotty in compilers until very
27// recently. Fortunately, thread local variables have been well supported for compilers for a while, 15// recently. Fortunately, thread local variables have been well supported for compilers for a while,
diff --git a/src/common/thunk.h b/src/common/thunk.h
deleted file mode 100644
index 533480056..000000000
--- a/src/common/thunk.h
+++ /dev/null
@@ -1,42 +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#include <map>
8
9#include "common/common_types.h"
10
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
13// call functions from generated code, without inflicting the performance hit and increase
14// of complexity that it means to protect the generated code from this problem.
15
16// This process is called thunking.
17
18// There will only ever be one level of thunking on the stack, plus,
19// we don't want to pollute the stack, so we store away regs somewhere global.
20// NOT THREAD SAFE. This may only be used from the CPU thread.
21// Any other thread using this stuff will be FATAL.
22
23class ThunkManager : public Gen::XCodeBlock
24{
25 std::map<void *, const u8 *> thunks;
26
27 const u8 *save_regs;
28 const u8 *load_regs;
29
30public:
31 ThunkManager() {
32 Init();
33 }
34 ~ThunkManager() {
35 Shutdown();
36 }
37 void *ProtectFunction(void *function, int num_params);
38private:
39 void Init();
40 void Shutdown();
41 void Reset();
42};