aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt1
-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
26 files changed, 86 insertions, 236 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index e78f4f14..f025e118 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
diff --git a/src/common/assert.h b/src/common/assert.h
index 7b7d8bf2..6849778b 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 1f3ecf84..6595b5ba 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 dcd80525..8be0b110 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 91b74c6b..c4fb3d9c 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 c4f1d7ba..fa3e0b8d 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 43facb85..b69b05cb 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 8eca6b5d..a0ae4c9f 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 b426e659..00000000
--- 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 24648ea3..836b58d5 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 b6582929..8fe772ae 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 0b71ea3b..a2b4eca4 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 5b3a731e..e16dde7f 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 2a7b7641..f6e7f017 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 20b791a1..2b3ace52 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 9fdbf1f1..9bf37c44 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 53cacf37..d2a049b6 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 df780ac6..0a912dda 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 cf6b6b25..7792edd2 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 3abb7331..df98e05b 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 7dc0ba7b..2e80809a 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 fdc41049..c5c474c6 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 588cebc7..b92e5bfa 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 946252b8..ae5e8b1e 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 8bf00585..7bbf080b 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 7bc41949..8255ee6d 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,