diff options
author | bunnei <bunneidev@gmail.com> | 2021-06-25 04:09:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 04:09:12 +0200 |
commit | b9c2732121e2594a64d1141807c7d5bd0f317d0f (patch) | |
tree | 700ab748e15d1e7d5cf7f58f2cbac133b7a84915 /src/common | |
parent | Merge pull request #6522 from Morph1984/pragma (diff) | |
parent | common: Replace common_sizes into user-literals (diff) | |
download | yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.gz yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.bz2 yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.lz yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.xz yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.tar.zst yuzu-b9c2732121e2594a64d1141807c7d5bd0f317d0f.zip |
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/common/common_sizes.h | 44 | ||||
-rw-r--r-- | src/common/literals.h | 31 | ||||
-rw-r--r-- | src/common/logging/backend.cpp | 11 |
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 cityhash.cpp cityhash.h common_funcs.h - common_sizes.h common_types.h concepts.h div_ceil.h @@ -134,6 +133,7 @@ add_library(common STATIC host_memory.cpp host_memory.h intrusive_red_black_tree.h + literals.h logging/backend.cpp logging/backend.h 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 @@ -// 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_512_MB = 512ULL * 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/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 @@ +// Copyright 2021 yuzu emulator team +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "common/common_types.h" + +namespace Common::Literals { + +constexpr u64 operator""_KiB(unsigned long long int x) { + return 1024ULL * x; +} + +constexpr u64 operator""_MiB(unsigned long long int x) { + return 1024_KiB * x; +} + +constexpr u64 operator""_GiB(unsigned long long int x) { + return 1024_MiB * x; +} + +constexpr u64 operator""_TiB(unsigned long long int x) { + return 1024_GiB * x; +} + +constexpr u64 operator""_PiB(unsigned long long int x) { + return 1024_TiB * x; +} + +} // 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 @@ #include "common/assert.h" #include "common/fs/file.h" #include "common/fs/fs.h" +#include "common/literals.h" + #include "common/logging/backend.h" #include "common/logging/log.h" #include "common/logging/text_formatter.h" @@ -98,8 +100,8 @@ private: write_logs(entry); } - // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case - // where a system is repeatedly spamming logs even on close. + // Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a + // case where a system is repeatedly spamming logs even on close. const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100; int logs_written = 0; while (logs_written++ < MAX_LOGS_TO_WRITE && message_queue.Pop(entry)) { @@ -169,10 +171,11 @@ FileBackend::FileBackend(const std::filesystem::path& filename) { FileBackend::~FileBackend() = default; void FileBackend::Write(const Entry& entry) { + using namespace Common::Literals; // prevent logs from going over the maximum size (in case its spamming and the user doesn't // know) - constexpr std::size_t MAX_BYTES_WRITTEN = 100 * 1024 * 1024; - constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1024 * 1024 * 1024; + constexpr std::size_t MAX_BYTES_WRITTEN = 100_MiB; + constexpr std::size_t MAX_BYTES_WRITTEN_EXTENDED = 1_GiB; if (!file->IsOpen()) { return; |