summaryrefslogtreecommitdiff
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/common_sizes.h44
-rw-r--r--src/common/literals.h31
-rw-r--r--src/common/logging/backend.cpp11
4 files changed, 39 insertions, 49 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 7534eb8f1..a6fa9a85d 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -110,7 +110,6 @@ add_library(common STATIC
110 cityhash.cpp 110 cityhash.cpp
111 cityhash.h 111 cityhash.h
112 common_funcs.h 112 common_funcs.h
113 common_sizes.h
114 common_types.h 113 common_types.h
115 concepts.h 114 concepts.h
116 div_ceil.h 115 div_ceil.h
@@ -134,6 +133,7 @@ add_library(common STATIC
134 host_memory.cpp 133 host_memory.cpp
135 host_memory.h 134 host_memory.h
136 intrusive_red_black_tree.h 135 intrusive_red_black_tree.h
136 literals.h
137 logging/backend.cpp 137 logging/backend.cpp
138 logging/backend.h 138 logging/backend.h
139 logging/filter.cpp 139 logging/filter.cpp
diff --git a/src/common/common_sizes.h b/src/common/common_sizes.h
deleted file mode 100644
index d07b7ee5a..000000000
--- a/src/common/common_sizes.h
+++ /dev/null
@@ -1,44 +0,0 @@
1// Copyright 2021 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <limits>
8
9#include "common/common_types.h"
10
11namespace Common {
12
13enum : u64 {
14 Size_1_KB = 0x400ULL,
15 Size_64_KB = 64ULL * Size_1_KB,
16 Size_128_KB = 128ULL * Size_1_KB,
17 Size_1_MB = 0x100000ULL,
18 Size_2_MB = 2ULL * Size_1_MB,
19 Size_4_MB = 4ULL * Size_1_MB,
20 Size_5_MB = 5ULL * Size_1_MB,
21 Size_14_MB = 14ULL * Size_1_MB,
22 Size_32_MB = 32ULL * Size_1_MB,
23 Size_33_MB = 33ULL * Size_1_MB,
24 Size_128_MB = 128ULL * Size_1_MB,
25 Size_448_MB = 448ULL * Size_1_MB,
26 Size_507_MB = 507ULL * Size_1_MB,
27 Size_512_MB = 512ULL * Size_1_MB,
28 Size_562_MB = 562ULL * Size_1_MB,
29 Size_1554_MB = 1554ULL * Size_1_MB,
30 Size_2048_MB = 2048ULL * Size_1_MB,
31 Size_2193_MB = 2193ULL * Size_1_MB,
32 Size_3285_MB = 3285ULL * Size_1_MB,
33 Size_4916_MB = 4916ULL * Size_1_MB,
34 Size_1_GB = 0x40000000ULL,
35 Size_2_GB = 2ULL * Size_1_GB,
36 Size_4_GB = 4ULL * Size_1_GB,
37 Size_6_GB = 6ULL * Size_1_GB,
38 Size_8_GB = 8ULL * Size_1_GB,
39 Size_64_GB = 64ULL * Size_1_GB,
40 Size_512_GB = 512ULL * Size_1_GB,
41 Size_Invalid = std::numeric_limits<u64>::max(),
42};
43
44} // namespace Common
diff --git a/src/common/literals.h b/src/common/literals.h
new file mode 100644
index 000000000..d55fed40b
--- /dev/null
+++ b/src/common/literals.h
@@ -0,0 +1,31 @@
1// Copyright 2021 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include "common/common_types.h"
8
9namespace Common::Literals {
10
11constexpr u64 operator""_KiB(unsigned long long int x) {
12 return 1024ULL * x;
13}
14
15constexpr u64 operator""_MiB(unsigned long long int x) {
16 return 1024_KiB * x;
17}
18
19constexpr u64 operator""_GiB(unsigned long long int x) {
20 return 1024_MiB * x;
21}
22
23constexpr u64 operator""_TiB(unsigned long long int x) {
24 return 1024_GiB * x;
25}
26
27constexpr u64 operator""_PiB(unsigned long long int x) {
28 return 1024_TiB * x;
29}
30
31} // namespace Common::Literals
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 47ce06478..b6fa4affb 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -19,6 +19,8 @@
19#include "common/assert.h" 19#include "common/assert.h"
20#include "common/fs/file.h" 20#include "common/fs/file.h"
21#include "common/fs/fs.h" 21#include "common/fs/fs.h"
22#include "common/literals.h"
23
22#include "common/logging/backend.h" 24#include "common/logging/backend.h"
23#include "common/logging/log.h" 25#include "common/logging/log.h"
24#include "common/logging/text_formatter.h" 26#include "common/logging/text_formatter.h"
@@ -98,8 +100,8 @@ private:
98 write_logs(entry); 100 write_logs(entry);
99 } 101 }
100 102
101 // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case 103 // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a
102 // where a system is repeatedly spamming logs even on close. 104 // case where a system is repeatedly spamming logs even on close.
103 const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100; 105 const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100;
104 int logs_written = 0; 106 int logs_written = 0;
105 while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) { 107 while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) {
@@ -169,10 +171,11 @@ FileBackend::FileBackend(const std::filesystem::path& filename) {
169FileBackend::~FileBackend() = default; 171FileBackend::~FileBackend() = default;
170 172
171void FileBackend::Write(const Entry& entry) { 173void FileBackend::Write(const Entry& entry) {
174 using namespace Common::Literals;
172 // prevent logs from going over the maximum size (in case its spamming and the user doesn't 175 // prevent logs from going over the maximum size (in case its spamming and the user doesn't
173 // know) 176 // know)
174 constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024; 177 constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB;
175 constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024; 178 constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB;
176 179
177 if (!file->IsOpen()) { 180 if (!file->IsOpen()) {
178 return; 181 return;