summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt120
-rw-r--r--src/common/bit_set.h2
-rw-r--r--src/common/chunk_file.h5
-rw-r--r--src/common/color.h2
-rw-r--r--src/common/file_util.cpp17
-rw-r--r--src/common/file_util.h2
-rw-r--r--src/common/logging/backend.cpp2
-rw-r--r--src/common/logging/backend.h2
-rw-r--r--src/common/logging/filter.cpp2
-rw-r--r--src/common/logging/filter.h2
-rw-r--r--src/common/logging/text_formatter.cpp2
-rw-r--r--src/common/logging/text_formatter.h2
-rw-r--r--src/common/memory_util.cpp7
-rw-r--r--src/common/quaternion.h2
-rw-r--r--src/common/scm_rev.h2
-rw-r--r--src/common/scope_exit.h2
-rw-r--r--src/common/string_util.cpp4
-rw-r--r--src/common/string_util.h2
-rw-r--r--src/common/telemetry.h4
-rw-r--r--src/common/thread_queue_list.h2
-rw-r--r--src/common/x64/xbyak_abi.h69
21 files changed, 146 insertions, 108 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 26cf9480b..1af80769a 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -24,78 +24,72 @@ if ($ENV{CI})
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp" @ONLY)
-set(SRCS
- break_points.cpp
- file_util.cpp
- hash.cpp
- logging/filter.cpp
- logging/text_formatter.cpp
- logging/backend.cpp
- memory_util.cpp
- microprofile.cpp
- misc.cpp
- param_package.cpp
- scm_rev.cpp
- string_util.cpp
- telemetry.cpp
- thread.cpp
- timer.cpp
- )
-
-set(HEADERS
- alignment.h
- assert.h
- bit_field.h
- bit_set.h
- break_points.h
- chunk_file.h
- code_block.h
- color.h
- common_funcs.h
- common_paths.h
- common_types.h
- file_util.h
- hash.h
- linear_disk_cache.h
- logging/text_formatter.h
- logging/filter.h
- logging/log.h
- logging/backend.h
- math_util.h
- memory_util.h
- microprofile.h
- microprofileui.h
- param_package.h
- platform.h
- quaternion.h
- scm_rev.h
- scope_exit.h
- string_util.h
- swap.h
- synchronized_wrapper.h
- telemetry.h
- thread.h
- thread_queue_list.h
- threadsafe_queue.h
- timer.h
- vector_math.h
- )
+add_library(common STATIC
+ alignment.h
+ assert.h
+ bit_field.h
+ bit_set.h
+ break_points.cpp
+ break_points.h
+ chunk_file.h
+ code_block.h
+ color.h
+ common_funcs.h
+ common_paths.h
+ common_types.h
+ file_util.cpp
+ file_util.h
+ hash.cpp
+ hash.h
+ linear_disk_cache.h
+ logging/backend.cpp
+ logging/backend.h
+ logging/filter.cpp
+ logging/filter.h
+ logging/log.h
+ logging/text_formatter.cpp
+ logging/text_formatter.h
+ math_util.h
+ memory_util.cpp
+ memory_util.h
+ microprofile.cpp
+ microprofile.h
+ microprofileui.h
+ misc.cpp
+ param_package.cpp
+ param_package.h
+ platform.h
+ quaternion.h
+ scm_rev.cpp
+ scm_rev.h
+ scope_exit.h
+ string_util.cpp
+ string_util.h
+ swap.h
+ synchronized_wrapper.h
+ telemetry.cpp
+ telemetry.h
+ thread.cpp
+ thread.h
+ thread_queue_list.h
+ threadsafe_queue.h
+ timer.cpp
+ timer.h
+ vector_math.h
+)
if(ARCHITECTURE_x86_64)
- set(SRCS ${SRCS}
+ target_sources(common
+ PRIVATE
x64/cpu_detect.cpp
- )
-
- set(HEADERS ${HEADERS}
x64/cpu_detect.h
x64/xbyak_abi.h
x64/xbyak_util.h
- )
+ )
endif()
-create_directory_groups(${SRCS} ${HEADERS})
+create_target_directory_groups(common)
-add_library(common STATIC ${SRCS} ${HEADERS})
target_link_libraries(common PUBLIC Boost::boost microprofile)
if (ARCHITECTURE_x86_64)
target_link_libraries(common PRIVATE xbyak)
diff --git a/src/common/bit_set.h b/src/common/bit_set.h
index 9c2e6b28c..84e3cbe58 100644
--- a/src/common/bit_set.h
+++ b/src/common/bit_set.h
@@ -236,7 +236,7 @@ public:
IntTy m_val;
};
-} // Common
+} // namespace Common
typedef Common::BitSet<u8> BitSet8;
typedef Common::BitSet<u16> BitSet16;
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 5145a3657..972ef9039 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -607,8 +607,9 @@ public:
u32 cookie = arbitraryNumber;
Do(cookie);
if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) {
- LOG_ERROR(Common, "After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). "
- "Aborting savestate load...",
+ LOG_ERROR(Common,
+ "After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). "
+ "Aborting savestate load...",
prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
SetError(ERROR_FAILURE);
}
diff --git a/src/common/color.h b/src/common/color.h
index 4ebd4f3d0..24a445dac 100644
--- a/src/common/color.h
+++ b/src/common/color.h
@@ -256,4 +256,4 @@ inline void EncodeX24S8(u8 stencil, u8* bytes) {
bytes[3] = stencil;
}
-} // namespace
+} // namespace Color
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 5ab036b34..4e1d702f7 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -873,20 +873,19 @@ bool IOFile::Flush() {
}
bool IOFile::Resize(u64 size) {
- if (!IsOpen() ||
- 0 !=
+ if (!IsOpen() || 0 !=
#ifdef _WIN32
- // ector: _chsize sucks, not 64-bit safe
- // F|RES: changed to _chsize_s. i think it is 64-bit safe
- _chsize_s(_fileno(m_file), size)
+ // ector: _chsize sucks, not 64-bit safe
+ // F|RES: changed to _chsize_s. i think it is 64-bit safe
+ _chsize_s(_fileno(m_file), size)
#else
- // TODO: handle 64bit and growing
- ftruncate(fileno(m_file), size)
+ // TODO: handle 64bit and growing
+ ftruncate(fileno(m_file), size)
#endif
- )
+ )
m_good = false;
return m_good;
}
-} // namespace
+} // namespace FileUtil
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 94adfcd7e..630232a25 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -253,7 +253,7 @@ private:
bool m_good = true;
};
-} // namespace
+} // namespace FileUtil
// To deal with Windows being dumb at unicode:
template <typename T>
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index ba0acfb72..e136482b6 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -132,4 +132,4 @@ void LogMessage(Class log_class, Level log_level, const char* filename, unsigned
PrintColoredMessage(entry);
}
-}
+} // namespace Log
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index c4fe2acbf..70744e3e5 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -47,4 +47,4 @@ Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsign
const char* function, const char* format, va_list args);
void SetFilter(Filter* filter);
-}
+} // namespace Log
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 12e5bb45d..733247b51 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -94,4 +94,4 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin,
bool Filter::CheckMessage(Class log_class, Level level) const {
return static_cast<u8>(level) >= static_cast<u8>(class_levels[static_cast<size_t>(log_class)]);
}
-}
+} // namespace Log
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index b51df61de..16fa72642 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -50,4 +50,4 @@ public:
private:
std::array<Level, (size_t)Class::Count> class_levels;
};
-}
+} // namespace Log
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index f71e748d1..e7e46c76b 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -129,4 +129,4 @@ void PrintColoredMessage(const Entry& entry) {
#undef ESC
#endif
}
-}
+} // namespace Log
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h
index 749268310..66e86d9ec 100644
--- a/src/common/logging/text_formatter.h
+++ b/src/common/logging/text_formatter.h
@@ -28,4 +28,4 @@ void FormatLogMessage(const Entry& entry, char* out_text, size_t text_len);
void PrintMessage(const Entry& entry);
/// Prints the same message as `PrintMessage`, but colored acoording to the severity level.
void PrintColoredMessage(const Entry& entry);
-}
+} // namespace Log
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index c19729b21..759ad02ca 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -40,11 +40,12 @@ void* AllocateExecutableMemory(size_t size, bool low) {
if (low && (!map_hint))
map_hint = (char*)round_page(512 * 1024 * 1024); /* 0.5 GB rounded up to the next page */
#endif
- void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE
+ void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_ANON | MAP_PRIVATE
#if defined(ARCHITECTURE_X64) && defined(MAP_32BIT)
- | (low ? MAP_32BIT : 0)
+ | (low ? MAP_32BIT : 0)
#endif
- ,
+ ,
-1, 0);
#endif /* defined(_WIN32) */
diff --git a/src/common/quaternion.h b/src/common/quaternion.h
index 77f626bcb..ea39298c1 100644
--- a/src/common/quaternion.h
+++ b/src/common/quaternion.h
@@ -46,4 +46,4 @@ inline Quaternion<float> MakeQuaternion(const Math::Vec3<float>& axis, float ang
return {axis * std::sin(angle / 2), std::cos(angle / 2)};
}
-} // namspace Math
+} // namespace Math
diff --git a/src/common/scm_rev.h b/src/common/scm_rev.h
index 18aaa1735..db0f4a947 100644
--- a/src/common/scm_rev.h
+++ b/src/common/scm_rev.h
@@ -12,4 +12,4 @@ extern const char g_scm_desc[];
extern const char g_build_name[];
extern const char g_build_date[];
-} // namespace
+} // namespace Common
diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h
index 072ab285d..baf1f1c9e 100644
--- a/src/common/scope_exit.h
+++ b/src/common/scope_exit.h
@@ -22,7 +22,7 @@ template <typename Func>
ScopeExitHelper<Func> ScopeExit(Func&& func) {
return ScopeExitHelper<Func>(std::move(func));
}
-}
+} // namespace detail
/**
* This macro allows you to conveniently specify a block of code that will run on scope exit. Handy
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index 6959915fa..e9a2a6b00 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -202,7 +202,7 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _
#ifdef _WIN32
":"
#endif
- );
+ );
if (std::string::npos == dir_end)
dir_end = 0;
else
@@ -462,4 +462,4 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_l
return std::string(buffer, len);
}
-}
+} // namespace Common
diff --git a/src/common/string_util.h b/src/common/string_util.h
index 259360aec..ceb8df48e 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -134,4 +134,4 @@ bool ComparePartialString(InIt begin, InIt end, const char* other) {
* NUL-terminated then the string ends at max_len characters.
*/
std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, size_t max_len);
-}
+} // namespace Common
diff --git a/src/common/telemetry.h b/src/common/telemetry.h
index dd6bbd759..3694c76f2 100644
--- a/src/common/telemetry.h
+++ b/src/common/telemetry.h
@@ -53,10 +53,10 @@ template <typename T>
class Field : public FieldInterface {
public:
Field(FieldType type, std::string name, const T& value)
- : type(type), name(std::move(name)), value(value) {}
+ : name(std::move(name)), type(type), value(value) {}
Field(FieldType type, std::string name, T&& value)
- : type(type), name(std::move(name)), value(std::move(value)) {}
+ : name(std::move(name)), type(type), value(std::move(value)) {}
Field(const Field& other) : Field(other.type, other.name, other.value) {}
diff --git a/src/common/thread_queue_list.h b/src/common/thread_queue_list.h
index edd0e4a3f..38a450d69 100644
--- a/src/common/thread_queue_list.h
+++ b/src/common/thread_queue_list.h
@@ -158,4 +158,4 @@ private:
std::array<Queue, NUM_QUEUES> queues;
};
-} // namespace
+} // namespace Common
diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h
index 6090d93e1..fd3fbdd4b 100644
--- a/src/common/x64/xbyak_abi.h
+++ b/src/common/x64/xbyak_abi.h
@@ -60,20 +60,41 @@ const Xbyak::Reg ABI_PARAM4 = Xbyak::util::r9;
const BitSet32 ABI_ALL_CALLER_SAVED = BuildRegSet({
// GPRs
- Xbyak::util::rcx, Xbyak::util::rdx, Xbyak::util::r8, Xbyak::util::r9, Xbyak::util::r10,
+ Xbyak::util::rcx,
+ Xbyak::util::rdx,
+ Xbyak::util::r8,
+ Xbyak::util::r9,
+ Xbyak::util::r10,
Xbyak::util::r11,
// XMMs
- Xbyak::util::xmm0, Xbyak::util::xmm1, Xbyak::util::xmm2, Xbyak::util::xmm3, Xbyak::util::xmm4,
+ Xbyak::util::xmm0,
+ Xbyak::util::xmm1,
+ Xbyak::util::xmm2,
+ Xbyak::util::xmm3,
+ Xbyak::util::xmm4,
Xbyak::util::xmm5,
});
const BitSet32 ABI_ALL_CALLEE_SAVED = BuildRegSet({
// GPRs
- Xbyak::util::rbx, Xbyak::util::rsi, Xbyak::util::rdi, Xbyak::util::rbp, Xbyak::util::r12,
- Xbyak::util::r13, Xbyak::util::r14, Xbyak::util::r15,
+ Xbyak::util::rbx,
+ Xbyak::util::rsi,
+ Xbyak::util::rdi,
+ Xbyak::util::rbp,
+ Xbyak::util::r12,
+ Xbyak::util::r13,
+ Xbyak::util::r14,
+ Xbyak::util::r15,
// XMMs
- Xbyak::util::xmm6, Xbyak::util::xmm7, Xbyak::util::xmm8, Xbyak::util::xmm9, Xbyak::util::xmm10,
- Xbyak::util::xmm11, Xbyak::util::xmm12, Xbyak::util::xmm13, Xbyak::util::xmm14,
+ Xbyak::util::xmm6,
+ Xbyak::util::xmm7,
+ Xbyak::util::xmm8,
+ Xbyak::util::xmm9,
+ Xbyak::util::xmm10,
+ Xbyak::util::xmm11,
+ Xbyak::util::xmm12,
+ Xbyak::util::xmm13,
+ Xbyak::util::xmm14,
Xbyak::util::xmm15,
});
@@ -90,18 +111,40 @@ const Xbyak::Reg ABI_PARAM4 = Xbyak::util::rcx;
const BitSet32 ABI_ALL_CALLER_SAVED = BuildRegSet({
// GPRs
- Xbyak::util::rcx, Xbyak::util::rdx, Xbyak::util::rdi, Xbyak::util::rsi, Xbyak::util::r8,
- Xbyak::util::r9, Xbyak::util::r10, Xbyak::util::r11,
+ Xbyak::util::rcx,
+ Xbyak::util::rdx,
+ Xbyak::util::rdi,
+ Xbyak::util::rsi,
+ Xbyak::util::r8,
+ Xbyak::util::r9,
+ Xbyak::util::r10,
+ Xbyak::util::r11,
// XMMs
- Xbyak::util::xmm0, Xbyak::util::xmm1, Xbyak::util::xmm2, Xbyak::util::xmm3, Xbyak::util::xmm4,
- Xbyak::util::xmm5, Xbyak::util::xmm6, Xbyak::util::xmm7, Xbyak::util::xmm8, Xbyak::util::xmm9,
- Xbyak::util::xmm10, Xbyak::util::xmm11, Xbyak::util::xmm12, Xbyak::util::xmm13,
- Xbyak::util::xmm14, Xbyak::util::xmm15,
+ Xbyak::util::xmm0,
+ Xbyak::util::xmm1,
+ Xbyak::util::xmm2,
+ Xbyak::util::xmm3,
+ Xbyak::util::xmm4,
+ Xbyak::util::xmm5,
+ Xbyak::util::xmm6,
+ Xbyak::util::xmm7,
+ Xbyak::util::xmm8,
+ Xbyak::util::xmm9,
+ Xbyak::util::xmm10,
+ Xbyak::util::xmm11,
+ Xbyak::util::xmm12,
+ Xbyak::util::xmm13,
+ Xbyak::util::xmm14,
+ Xbyak::util::xmm15,
});
const BitSet32 ABI_ALL_CALLEE_SAVED = BuildRegSet({
// GPRs
- Xbyak::util::rbx, Xbyak::util::rbp, Xbyak::util::r12, Xbyak::util::r13, Xbyak::util::r14,
+ Xbyak::util::rbx,
+ Xbyak::util::rbp,
+ Xbyak::util::r12,
+ Xbyak::util::r13,
+ Xbyak::util::r14,
Xbyak::util::r15,
});