[Base] Add user-literals for several memory sizes
Rather than using `n * 1024 * 1024`, this adds a convenient `_MiB`/`_KiB` user-literal to the new `literals.h` header to concisely describe units of memory in a much more readable way. Any other useful literals can be added to this header. These literals exist in the `xe::literals` namespace so they are opt-in, similar to `std::chrono` literals, and require a `using namespace xe::literals` statement to utilize it within the current scope. I've done a pass through the codebase to replace trivial instances of `1024 * 1024 * ...` expressions being used but avoided anything that added additional casting complexity from `size_t` to `uint32_t` and such to keep this commit concise.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/debugging.h"
|
||||
#include "xenia/base/exception_handler.h"
|
||||
#include "xenia/base/literals.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/mapped_memory.h"
|
||||
#include "xenia/base/profiling.h"
|
||||
@@ -60,6 +61,8 @@ DEFINE_string(
|
||||
|
||||
namespace xe {
|
||||
|
||||
using namespace xe::literals;
|
||||
|
||||
Emulator::Emulator(const std::filesystem::path& command_line,
|
||||
const std::filesystem::path& storage_root,
|
||||
const std::filesystem::path& content_root,
|
||||
@@ -415,8 +418,7 @@ bool Emulator::SaveToFile(const std::filesystem::path& path) {
|
||||
Pause();
|
||||
|
||||
filesystem::CreateFile(path);
|
||||
auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite, 0,
|
||||
1024ull * 1024ull * 1024ull * 2ull);
|
||||
auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite, 0, 2_GiB);
|
||||
if (!map) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user