summaryrefslogtreecommitdiffstats
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.cpp11
-rw-r--r--src/common/assert.h14
-rw-r--r--src/common/common_sizes.h43
-rw-r--r--src/common/logging/backend.cpp1
-rw-r--r--src/common/logging/log.h1
-rw-r--r--src/common/threadsafe_queue.h10
7 files changed, 75 insertions, 7 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 788516ded..9f8dafa3b 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -97,6 +97,7 @@ add_custom_command(OUTPUT scm_rev.cpp
add_library(common STATIC
algorithm.h
alignment.h
+ assert.cpp
assert.h
atomic_ops.h
detached_tasks.cpp
@@ -109,6 +110,7 @@ add_library(common STATIC
cityhash.h
common_funcs.h
common_paths.h
+ common_sizes.h
common_types.h
concepts.h
div_ceil.h
diff --git a/src/common/assert.cpp b/src/common/assert.cpp
new file mode 100644
index 000000000..d7d91b96b
--- /dev/null
+++ b/src/common/assert.cpp
@@ -0,0 +1,11 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "common/assert.h"
+
+#include "common/common_funcs.h"
+
+void assert_handle_failure() {
+ Crash();
+}
diff --git a/src/common/assert.h b/src/common/assert.h
index 06d7b5612..b3ba35c0f 100644
--- a/src/common/assert.h
+++ b/src/common/assert.h
@@ -4,10 +4,13 @@
#pragma once
-#include <cstdlib>
-#include "common/common_funcs.h"
#include "common/logging/log.h"
+// Sometimes we want to try to continue even after hitting an assert.
+// However touching this file yields a global recompilation as this header is included almost
+// everywhere. So let's just move the handling of the failed assert to a single cpp file.
+void assert_handle_failure();
+
// For asserts we'd like to keep all the junk executed when an assert happens away from the
// important code in the function. One way of doing this is to put all the relevant code inside a
// lambda and force the compiler to not inline it. Unfortunately, MSVC seems to have no syntax to
@@ -17,15 +20,14 @@
// enough for our purposes.
template <typename Fn>
#if defined(_MSC_VER)
-[[msvc::noinline, noreturn]]
+[[msvc::noinline]]
#elif defined(__GNUC__)
-[[gnu::cold, gnu::noinline, noreturn]]
+[[gnu::cold, gnu::noinline]]
#endif
static void
assert_noinline_call(const Fn& fn) {
fn();
- Crash();
- exit(1); // Keeps GCC's mouth shut about this actually returning
+ assert_handle_failure();
}
#define ASSERT(_a_) \
diff --git a/src/common/common_sizes.h b/src/common/common_sizes.h
new file mode 100644
index 000000000..7e9fd968b
--- /dev/null
+++ b/src/common/common_sizes.h
@@ -0,0 +1,43 @@
+// Copyright 2021 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <limits>
+
+#include "common/common_types.h"
+
+namespace Common {
+
+enum : u64 {
+ Size_1_KB = 0x400ULL,
+ Size_64_KB = 64ULL * Size_1_KB,
+ Size_128_KB = 128ULL * Size_1_KB,
+ Size_1_MB = 0x100000ULL,
+ Size_2_MB = 2ULL * Size_1_MB,
+ Size_4_MB = 4ULL * Size_1_MB,
+ Size_5_MB = 5ULL * Size_1_MB,
+ Size_14_MB = 14ULL * Size_1_MB,
+ Size_32_MB = 32ULL * Size_1_MB,
+ Size_33_MB = 33ULL * Size_1_MB,
+ Size_128_MB = 128ULL * Size_1_MB,
+ Size_448_MB = 448ULL * Size_1_MB,
+ Size_507_MB = 507ULL * Size_1_MB,
+ Size_562_MB = 562ULL * Size_1_MB,
+ Size_1554_MB = 1554ULL * Size_1_MB,
+ Size_2048_MB = 2048ULL * Size_1_MB,
+ Size_2193_MB = 2193ULL * Size_1_MB,
+ Size_3285_MB = 3285ULL * Size_1_MB,
+ Size_4916_MB = 4916ULL * Size_1_MB,
+ Size_1_GB = 0x40000000ULL,
+ Size_2_GB = 2ULL * Size_1_GB,
+ Size_4_GB = 4ULL * Size_1_GB,
+ Size_6_GB = 6ULL * Size_1_GB,
+ Size_8_GB = 8ULL * Size_1_GB,
+ Size_64_GB = 64ULL * Size_1_GB,
+ Size_512_GB = 512ULL * Size_1_GB,
+ Size_Invalid = std::numeric_limits<u64>::max(),
+};
+
+} // namespace Common
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 2d4d2e9e7..4575df24d 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -212,6 +212,7 @@ void DebuggerBackend::Write(const Entry& entry) {
SUB(Service, ARP) \
SUB(Service, BCAT) \
SUB(Service, BPC) \
+ SUB(Service, BGTC) \
SUB(Service, BTDRV) \
SUB(Service, BTM) \
SUB(Service, Capture) \
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 835894918..3d7b7dab7 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -66,6 +66,7 @@ enum class Class : ClassType {
Service_ARP, ///< The ARP service
Service_Audio, ///< The Audio (Audio control) service
Service_BCAT, ///< The BCAT service
+ Service_BGTC, ///< The BGTC (Background Task Controller) service
Service_BPC, ///< The BPC service
Service_BTDRV, ///< The Bluetooth driver service
Service_BTM, ///< The BTM service
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index a4647314a..ad04df8ca 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -83,11 +83,15 @@ public:
return true;
}
- T PopWait() {
+ void Wait() {
if (Empty()) {
std::unique_lock lock{cv_mutex};
cv.wait(lock, [this]() { return !Empty(); });
}
+ }
+
+ T PopWait() {
+ Wait();
T t;
Pop(t);
return t;
@@ -156,6 +160,10 @@ public:
return spsc_queue.Pop(t);
}
+ void Wait() {
+ spsc_queue.Wait();
+ }
+
T PopWait() {
return spsc_queue.PopWait();
}