summaryrefslogtreecommitdiff
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/common.h6
-rw-r--r--src/common/console_listener.cpp6
-rw-r--r--src/common/file_search.cpp4
-rw-r--r--src/common/file_util.cpp7
-rw-r--r--src/common/fixed_size_queue.h70
-rw-r--r--src/common/log_manager.cpp1
-rw-r--r--src/common/math_util.cpp3
-rw-r--r--src/common/mem_arena.cpp4
-rw-r--r--src/common/memory_util.cpp3
-rw-r--r--src/common/string_util.cpp15
-rw-r--r--src/common/thread.cpp1
-rw-r--r--src/common/utf8.cpp4
13 files changed, 11 insertions, 114 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 868fda55e..3a82f5b80 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -38,7 +38,6 @@ set(HEADERS
38 fifo_queue.h 38 fifo_queue.h
39 file_search.h 39 file_search.h
40 file_util.h 40 file_util.h
41 fixed_size_queue.h
42 hash.h 41 hash.h
43 linear_disk_cache.h 42 linear_disk_cache.h
44 log.h 43 log.h
diff --git a/src/common/common.h b/src/common/common.h
index cb69eabe4..9f3016d34 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -20,11 +20,6 @@
20 20
21#define STACKALIGN 21#define STACKALIGN
22 22
23#if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__)
24#define HAVE_CXX11_SYNTAX 1
25#endif
26
27#if HAVE_CXX11_SYNTAX
28// An inheritable class to disallow the copy constructor and operator= functions 23// An inheritable class to disallow the copy constructor and operator= functions
29class NonCopyable 24class NonCopyable
30{ 25{
@@ -36,7 +31,6 @@ private:
36 NonCopyable(NonCopyable&); 31 NonCopyable(NonCopyable&);
37 NonCopyable& operator=(NonCopyable& other); 32 NonCopyable& operator=(NonCopyable& other);
38}; 33};
39#endif
40 34
41#include "common/log.h" 35#include "common/log.h"
42#include "common/common_types.h" 36#include "common/common_types.h"
diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp
index 96970ab17..40122224c 100644
--- a/src/common/console_listener.cpp
+++ b/src/common/console_listener.cpp
@@ -3,14 +3,10 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cmath> 6
7#include <cstdio>
8#include <string>
9#ifdef _WIN32 7#ifdef _WIN32
10#include <windows.h> 8#include <windows.h>
11#include <array> 9#include <array>
12#else
13#include <cstdarg>
14#endif 10#endif
15 11
16#include "common/common.h" 12#include "common/common.h"
diff --git a/src/common/file_search.cpp b/src/common/file_search.cpp
index a80a98820..63580f688 100644
--- a/src/common/file_search.cpp
+++ b/src/common/file_search.cpp
@@ -4,15 +4,13 @@
4 4
5 5
6#include "common/common.h" 6#include "common/common.h"
7#include "common/common_paths.h" 7
8#ifndef _WIN32 8#ifndef _WIN32
9#include <sys/types.h>
10#include <dirent.h> 9#include <dirent.h>
11#else 10#else
12#include <windows.h> 11#include <windows.h>
13#endif 12#endif
14 13
15#include <string>
16#include <algorithm> 14#include <algorithm>
17 15
18#include "common/file_search.h" 16#include "common/file_search.h"
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 2fdc7ec01..970041007 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -4,9 +4,7 @@
4 4
5 5
6#include "common/common.h" 6#include "common/common.h"
7#include "common/common_paths.h"
8#include "common/file_util.h" 7#include "common/file_util.h"
9#include "common/string_util.h"
10 8
11#ifdef _WIN32 9#ifdef _WIN32
12#include <windows.h> 10#include <windows.h>
@@ -16,10 +14,7 @@
16#include <io.h> 14#include <io.h>
17#include <direct.h> // getcwd 15#include <direct.h> // getcwd
18#else 16#else
19#include <cerrno>
20#include <cstdlib>
21#include <sys/param.h> 17#include <sys/param.h>
22#include <sys/types.h>
23#include <dirent.h> 18#include <dirent.h>
24#endif 19#endif
25 20
@@ -32,8 +27,6 @@
32#include <algorithm> 27#include <algorithm>
33#include <sys/stat.h> 28#include <sys/stat.h>
34 29
35#include "common/string_util.h"
36
37#ifndef S_ISDIR 30#ifndef S_ISDIR
38#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) 31#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
39#endif 32#endif
diff --git a/src/common/fixed_size_queue.h b/src/common/fixed_size_queue.h
deleted file mode 100644
index 1e3a5dea6..000000000
--- a/src/common/fixed_size_queue.h
+++ /dev/null
@@ -1,70 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project
2// Licensed under GPLv2
3// Refer to the license.txt file included.
4
5#pragma once
6
7// STL-look-a-like interface, but name is mixed case to distinguish it clearly from the
8// real STL classes.
9
10// Not fully featured, no safety checking yet. Add features as needed.
11
12// TODO: "inline" storage?
13
14template <class T, int N>
15class fixed_size_queue.h
16{
17 T *storage;
18 int head;
19 int tail;
20 int count; // sacrifice 4 bytes for a simpler implementation. may optimize away in the future.
21
22 // Make copy constructor private for now.
23 fixed_size_queue.h(fixed_size_queue.h &other) { }
24
25public:
26 fixed_size_queue.h()
27 {
28 storage = new T[N];
29 clear();
30 }
31
32 ~fixed_size_queue.h()
33 {
34 delete [] storage;
35 }
36
37 void clear() {
38 head = 0;
39 tail = 0;
40 count = 0;
41 }
42
43 void push(T t) {
44 storage[tail] = t;
45 tail++;
46 if (tail == N)
47 tail = 0;
48 count++;
49 }
50
51 void pop() {
52 head++;
53 if (head == N)
54 head = 0;
55 count--;
56 }
57
58 T pop_front() {
59 const T &temp = storage[head];
60 pop();
61 return temp;
62 }
63
64 T &front() { return storage[head]; }
65 const T &front() const { return storage[head]; }
66
67 size_t size() const {
68 return count;
69 }
70};
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp
index 9fd019fb3..43346f279 100644
--- a/src/common/log_manager.cpp
+++ b/src/common/log_manager.cpp
@@ -8,7 +8,6 @@
8#include "common/console_listener.h" 8#include "common/console_listener.h"
9#include "common/timer.h" 9#include "common/timer.h"
10#include "common/thread.h" 10#include "common/thread.h"
11#include "common/file_util.h"
12 11
13void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, 12void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
14 const char* function, const char* fmt, ...) 13 const char* function, const char* fmt, ...)
diff --git a/src/common/math_util.cpp b/src/common/math_util.cpp
index 82eceab00..ab0e6b75c 100644
--- a/src/common/math_util.cpp
+++ b/src/common/math_util.cpp
@@ -6,8 +6,7 @@
6#include "common/common.h" 6#include "common/common.h"
7#include "common/math_util.h" 7#include "common/math_util.h"
8 8
9#include <cmath> 9#include <numeric> // Necessary on OS X, but not Linux
10#include <numeric>
11 10
12namespace MathUtil 11namespace MathUtil
13{ 12{
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index d4dd933bf..40d9c03a2 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -22,11 +22,7 @@
22#include "common/string_util.h" 22#include "common/string_util.h"
23 23
24#ifndef _WIN32 24#ifndef _WIN32
25#include <sys/stat.h>
26#include <fcntl.h> 25#include <fcntl.h>
27#include <unistd.h>
28#include <cerrno>
29#include <cstring>
30#ifdef ANDROID 26#ifdef ANDROID
31#include <sys/ioctl.h> 27#include <sys/ioctl.h>
32#include <linux/ashmem.h> 28#include <linux/ashmem.h>
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index 1496002e9..bab7d9f7a 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -10,9 +10,6 @@
10#ifdef _WIN32 10#ifdef _WIN32
11#include <windows.h> 11#include <windows.h>
12#include <psapi.h> 12#include <psapi.h>
13#else
14#include <cerrno>
15#include <cstdio>
16#endif 13#endif
17 14
18#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT) 15#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index bd4c33391..9199e30bc 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -3,17 +3,13 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstdlib>
7#include <cstdio>
8 6
9#include "common/common.h" 7#include "common/common.h"
10#include "common/common_paths.h"
11#include "common/string_util.h" 8#include "common/string_util.h"
12 9
13#ifdef _WIN32 10#ifdef _WIN32
14 #include <Windows.h> 11 #include <Windows.h>
15#else 12#else
16 #include <cerrno>
17 #include <iconv.h> 13 #include <iconv.h>
18#endif 14#endif
19 15
@@ -281,12 +277,17 @@ std::string TabsToSpaces(int tab_size, const std::string &in)
281 277
282std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest) 278std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest)
283{ 279{
284 while(1) 280 size_t pos = 0;
281
282 if (src == dest)
283 return result;
284
285 while ((pos = result.find(src, pos)) != std::string::npos)
285 { 286 {
286 size_t pos = result.find(src);
287 if (pos == std::string::npos) break;
288 result.replace(pos, src.size(), dest); 287 result.replace(pos, src.size(), dest);
288 pos += dest.length();
289 } 289 }
290
290 return result; 291 return result;
291} 292}
292 293
diff --git a/src/common/thread.cpp b/src/common/thread.cpp
index 830795182..60d8ed075 100644
--- a/src/common/thread.cpp
+++ b/src/common/thread.cpp
@@ -3,7 +3,6 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/thread.h" 5#include "common/thread.h"
6#include "common/common.h"
7 6
8#ifdef __APPLE__ 7#ifdef __APPLE__
9#include <mach/mach.h> 8#include <mach/mach.h>
diff --git a/src/common/utf8.cpp b/src/common/utf8.cpp
index c83824d35..be4ebc855 100644
--- a/src/common/utf8.cpp
+++ b/src/common/utf8.cpp
@@ -19,12 +19,8 @@
19#endif 19#endif
20 20
21#include <cstdlib> 21#include <cstdlib>
22#include <cstdio>
23#include <cstring> 22#include <cstring>
24#include <cstdarg>
25
26#include <algorithm> 23#include <algorithm>
27#include <string>
28 24
29#include "common/common_types.h" 25#include "common/common_types.h"
30#include "common/utf8.h" 26#include "common/utf8.h"