diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/common/assert.h | 1 | ||||
-rw-r--r-- | src/common/bit_field.h | 1 | ||||
-rw-r--r-- | src/common/chunk_file.h | 10 | ||||
-rw-r--r-- | src/common/common_funcs.h | 11 | ||||
-rw-r--r-- | src/common/common_types.h | 2 | ||||
-rw-r--r-- | src/common/emu_window.cpp | 6 | ||||
-rw-r--r-- | src/common/emu_window.h | 12 | ||||
-rw-r--r-- | src/common/fifo_queue.h | 111 | ||||
-rw-r--r-- | src/common/file_util.cpp | 11 | ||||
-rw-r--r-- | src/common/file_util.h | 3 | ||||
-rw-r--r-- | src/common/logging/filter.h | 1 | ||||
-rw-r--r-- | src/common/logging/log.h | 4 | ||||
-rw-r--r-- | src/common/make_unique.h | 1 | ||||
-rw-r--r-- | src/common/memory_util.cpp | 11 | ||||
-rw-r--r-- | src/common/memory_util.h | 4 | ||||
-rw-r--r-- | src/common/misc.cpp | 5 | ||||
-rw-r--r-- | src/common/platform.h | 55 | ||||
-rw-r--r-- | src/common/profiler.cpp | 11 | ||||
-rw-r--r-- | src/common/profiler_reporting.h | 5 | ||||
-rw-r--r-- | src/common/string_util.cpp | 9 | ||||
-rw-r--r-- | src/common/string_util.h | 3 | ||||
-rw-r--r-- | src/common/swap.h | 10 | ||||
-rw-r--r-- | src/common/synchronized_wrapper.h | 1 | ||||
-rw-r--r-- | src/common/thread.cpp | 17 | ||||
-rw-r--r-- | src/common/thread.h | 16 | ||||
-rw-r--r-- | src/common/thunk.h | 42 |
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 cpu_detect.h debug_interface.h emu_window.h - fifo_queue.h file_util.h key_map.h linear_disk_cache.h @@ -53,7 +52,6 @@ set(HEADERS synchronized_wrapper.h thread.h thread_queue_list.h - thunk.h timer.h vector_math.h ) 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 @@ #pragma once -#include <cstdio> #include <cstdlib> #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 @@ #pragma once +#include <cstddef> #include <limits> #include <type_traits> 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 @@ // - Zero backwards/forwards compatibility // - Serialization code for anything complex has to be manually written. -#include <map> -#include <vector> +#include <cstring> #include <deque> -#include <string> #include <list> +#include <map> #include <set> +#include <string> #include <type_traits> +#include <utility> +#include <vector> +#include "common/assert.h" #include "common/common_types.h" -#include "common/file_util.h" #include "common/logging/log.h" template <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 @@ #pragma once #include "common_types.h" -#include <cstdlib> - - -#define b2(x) ( (x) | ( (x) >> 1) ) -#define b4(x) ( b2(x) | ( b2(x) >> 2) ) -#define b8(x) ( b4(x) | ( b4(x) >> 4) ) -#define b16(x) ( b8(x) | ( b8(x) >> 8) ) -#define b32(x) (b16(x) | (b16(x) >>16) ) -#define ROUND_UP_POW2(x) (b32(x - 1) + 1) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) @@ -43,8 +34,6 @@ #ifndef _MSC_VER -#include <errno.h> - #if defined(__x86_64__) || defined(_M_X64) #define Crash() __asm__ __volatile__("int $3") #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 @@ #pragma once -#include <cmath> #include <cstdint> -#include <cstdlib> #ifdef _MSC_VER #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 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <cmath> + +#include "common/assert.h" +#include "common/key_map.h" + #include "emu_window.h" #include "video_core/video_core.h" 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 @@ #pragma once +#include <tuple> +#include <utility> + #include "common/common_types.h" -#include "common/key_map.h" #include "common/math_util.h" -#include "common/scm_rev.h" -#include "common/string_util.h" + +#include "core/hle/service/hid/hid.h" + +namespace KeyMap { +struct HostDeviceKey; +} /** * 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 @@ -#pragma once - -// a simple lockless thread-safe, -// single reader, single writer queue - -#include "common/atomic.h" - -namespace Common -{ - -template <typename T> -class FifoQueue -{ -public: - FifoQueue() : m_size(0) - { - m_write_ptr = m_read_ptr = new ElementPtr(); - } - - ~FifoQueue() - { - // this will empty out the whole queue - delete m_read_ptr; - } - - u32 Size() const - { - return m_size; - } - - bool Empty() const - { - //return (m_read_ptr == m_write_ptr); - return (0 == m_size); - } - - T& Front() const - { - return *m_read_ptr->current; - } - - template <typename Arg> - void Push(Arg&& t) - { - // create the element, add it to the queue - m_write_ptr->current = new T(std::forward<Arg>(t)); - // set the next pointer to a new element ptr - // then advance the write pointer - m_write_ptr = m_write_ptr->next = new ElementPtr(); - Common::AtomicIncrement(m_size); - } - - void Pop() - { - Common::AtomicDecrement(m_size); - ElementPtr *const tmpptr = m_read_ptr; - // advance the read pointer - m_read_ptr = m_read_ptr->next; - // set the next element to NULL to stop the recursive deletion - tmpptr->next = nullptr; - delete tmpptr; // this also deletes the element - } - - bool Pop(T& t) - { - if (Empty()) - return false; - - t = std::move(Front()); - Pop(); - - return true; - } - - // not thread-safe - void Clear() - { - m_size = 0; - delete m_read_ptr; - m_write_ptr = m_read_ptr = new ElementPtr(); - } - -private: - // stores a pointer to element - // and a pointer to the next ElementPtr - class ElementPtr - { - public: - ElementPtr() : current(nullptr), next(nullptr) {} - - ~ElementPtr() - { - if (current) - { - delete current; - // recusion ftw - if (next) - delete next; - } - } - - T *volatile current; - ElementPtr *volatile next; - }; - - ElementPtr *volatile m_write_ptr; - ElementPtr *volatile m_read_ptr; - volatile u32 m_size; -}; - -} 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 @@ #include <direct.h> // getcwd #include <tchar.h> + #include "common/string_util.h" + // 64 bit offsets for windows #define fseeko _fseeki64 #define ftello _ftelli64 @@ -25,8 +27,13 @@ #define fstat64 _fstat64 #define fileno _fileno #else - #include <sys/param.h> - #include <sys/types.h> + #ifdef __APPLE__ + #include <sys/param.h> + #endif + #include <cctype> + #include <cerrno> + #include <cstdlib> + #include <cstring> #include <dirent.h> #include <pwd.h> #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 @@ #include <array> #include <fstream> +#include <cstddef> #include <cstdio> -#include <cstring> #include <string> #include <vector> #include "common/common_types.h" -#include "common/string_util.h" // User directory indices for GetUserPath enum { 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 @@ #pragma once #include <array> +#include <cstddef> #include <string> #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 @@ #pragma once -#include <cassert> -#include <chrono> -#include <string> - #include "common/common_types.h" namespace 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 @@ #pragma once +#include <algorithm> #include <memory> namespace 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 @@ // Refer to the license.txt file included. -#include "common/common_funcs.h" #include "common/logging/log.h" #include "common/memory_util.h" -#include "common/string_util.h" #ifdef _WIN32 -#include <windows.h> -#include <psapi.h> + #include <windows.h> + #include <psapi.h> + #include "common/common_funcs.h" + #include "common/string_util.h" +#else + #include <cstdlib> + #include <sys/mman.h> #endif #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 @@ #pragma once -#ifndef _WIN32 -#include <sys/mman.h> -#endif +#include <cstddef> #include <string> void* 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 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/common_funcs.h" +#include <cstddef> #ifdef _WIN32 #include <windows.h> #else -#include <string.h> +#include <cerrno> +#include <cstring> #endif // 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 @@ #pragma once -#include "common/common_types.h" - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Platform definitions - -/// Enumeration for defining the supported platforms -#define PLATFORM_NULL 0 -#define PLATFORM_WINDOWS 1 -#define PLATFORM_MACOSX 2 -#define PLATFORM_LINUX 3 -#define PLATFORM_ANDROID 4 - //////////////////////////////////////////////////////////////////////////////////////////////////// // Platform detection -#ifndef EMU_PLATFORM - -#if defined( __WIN32__ ) || defined( _WIN32 ) -#define EMU_PLATFORM PLATFORM_WINDOWS - -#elif defined( __APPLE__ ) || defined( __APPLE_CC__ ) -#define EMU_PLATFORM PLATFORM_MACOSX - -#elif defined(__linux__) -#define EMU_PLATFORM PLATFORM_LINUX - -#else // Assume linux otherwise -#define EMU_PLATFORM PLATFORM_LINUX - -#endif - -#endif - #if defined(__x86_64__) || defined(_M_X64) || defined(__aarch64__) #define EMU_ARCH_BITS 64 #elif defined(__i386) || defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) #define EMU_ARCH_BITS 32 #endif - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Feature detection - -#if defined _M_GENERIC -# define _M_SSE 0x0 -#elif defined __GNUC__ -# if defined __SSE4_2__ -# define _M_SSE 0x402 -# elif defined __SSE4_1__ -# define _M_SSE 0x401 -# elif defined __SSSE3__ -# define _M_SSE 0x301 -# elif defined __SSE3__ -# define _M_SSE 0x300 -# endif -#elif (_MSC_VER >= 1500) || __INTEL_COMPILER // Visual Studio 2008 -# define _M_SSE 0x402 -#endif - -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Compiler-Specific Definitions - -#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \ - (__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 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <cstddef> +#include <vector> + +#include "common/assert.h" #include "common/profiler.h" #include "common/profiler_reporting.h" -#include "common/assert.h" +#include "common/synchronized_wrapper.h" #if defined(_MSC_VER) && _MSC_VER <= 1800 // MSVC 2013. -#define WIN32_LEAN_AND_MEAN -#include <Windows.h> // For QueryPerformanceCounter/Frequency + #define WIN32_LEAN_AND_MEAN + #include <Windows.h> // For QueryPerformanceCounter/Frequency #endif namespace 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 @@ #pragma once -#include <array> -#include <chrono> -#include <mutex> -#include <utility> +#include <cstddef> #include <vector> #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 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <boost/range/algorithm.hpp> +#include <cctype> +#include <cerrno> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <boost/range/algorithm/transform.hpp> -#include "common/common_funcs.h" #include "common/common_paths.h" #include "common/logging/log.h" #include "common/string_util.h" @@ -12,6 +16,7 @@ #ifdef _MSC_VER #include <Windows.h> #include <codecvt> + #include "common/common_funcs.h" #else #include <iconv.h> #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 @@ #pragma once #include <cstdarg> +#include <cstddef> #include <iomanip> -#include <string> #include <sstream> +#include <string> #include <vector> #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 @@ #pragma once -#if defined(__linux__) -#include <byteswap.h> +#if defined(_MSC_VER) + #include <cstdlib> +#elif defined(__linux__) + #include <byteswap.h> #elif defined(__FreeBSD__) -#include <sys/endian.h> + #include <sys/endian.h> #endif +#include "common/common_types.h" + // GCC 4.6+ #if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) 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 @@ #pragma once +#include <algorithm> #include <mutex> namespace 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 @@ #include "common/thread.h" #ifdef __APPLE__ -#include <mach/mach.h> -#elif defined(BSD4_4) || defined(__OpenBSD__) -#include <pthread_np.h> + #include <mach/mach.h> #elif defined(_WIN32) -#include <Windows.h> + #include <Windows.h> +#else + #if defined(BSD4_4) || defined(__OpenBSD__) + #include <pthread_np.h> + #else + #include <pthread.h> + #endif + #include <sched.h> +#endif + +#ifndef _WIN32 + #include <unistd.h> #endif namespace 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 @@ #pragma once -#include "common/common_types.h" -#include <cstdio> -#include <cstring> +#include <cstddef> #include <thread> #include <condition_variable> #include <mutex> -// This may not be defined outside _WIN32 -#ifndef _WIN32 -#ifndef INFINITE -#define INFINITE 0xffffffff -#endif - -//for gettimeofday and struct time(spec|val) -#include <time.h> -#include <sys/time.h> -#include <unistd.h> -#endif +#include "common/common_types.h" // Support for C++11's thread_local keyword was surprisingly spotty in compilers until very // 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 @@ -// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include <map> - -#include "common/common_types.h" - -// This simple class creates a wrapper around a C/C++ function that saves all fp state -// before entering it, and restores it upon exit. This is required to be able to selectively -// call functions from generated code, without inflicting the performance hit and increase -// of complexity that it means to protect the generated code from this problem. - -// This process is called thunking. - -// There will only ever be one level of thunking on the stack, plus, -// we don't want to pollute the stack, so we store away regs somewhere global. -// NOT THREAD SAFE. This may only be used from the CPU thread. -// Any other thread using this stuff will be FATAL. - -class ThunkManager : public Gen::XCodeBlock -{ - std::map<void *, const u8 *> thunks; - - const u8 *save_regs; - const u8 *load_regs; - -public: - ThunkManager() { - Init(); - } - ~ThunkManager() { - Shutdown(); - } - void *ProtectFunction(void *function, int num_params); -private: - void Init(); - void Shutdown(); - void Reset(); -}; |