From 45f1594d91ec39b4467f91683177acf9ba4f83ee Mon Sep 17 00:00:00 2001 From: ownedbywuigi Date: Mon, 16 Jun 2025 13:09:31 -0400 Subject: [PATCH] waiter! waiter! more imports please!!! --- core/fs/bis_factory.cpp | 6 +-- core/fs/bis_factory.h | 4 +- core/fs/card_image.cpp | 20 +++++----- import/common/fs/common_types.h | 53 ++++++++++++++++++++++++++ import/common/logging/log.h | 67 +++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 15 deletions(-) create mode 100644 import/common/fs/common_types.h create mode 100644 import/common/logging/log.h diff --git a/core/fs/bis_factory.cpp b/core/fs/bis_factory.cpp index 0649ba8..0f2c5b7 100644 --- a/core/fs/bis_factory.cpp +++ b/core/fs/bis_factory.cpp @@ -3,9 +3,9 @@ #include //can't find that yet (ownedbywuigi) #include "import/common/fs/path_util.h" -#include "core/file_sys/bis_factory.h" -#include "core/file_sys/registered_cache.h" -#include "core/file_sys/vfs/vfs.h" +#include "core/fs/bis_factory.h" +#include "core/fs/registered_cache.h" +#include "core/fs/vfs/vfs.h" namespace FileSys { diff --git a/core/fs/bis_factory.h b/core/fs/bis_factory.h index 23680b6..1b6cbd2 100644 --- a/core/fs/bis_factory.h +++ b/core/fs/bis_factory.h @@ -5,8 +5,8 @@ #include -#include "common/common_types.h" -#include "core/file_sys/vfs/vfs_types.h" +#include "import/common/common_types.h" +#include "core/fs/vfs/vfs_types.h" namespace FileSys { diff --git a/core/fs/card_image.cpp b/core/fs/card_image.cpp index 0bcf40c..784c558 100644 --- a/core/fs/card_image.cpp +++ b/core/fs/card_image.cpp @@ -4,17 +4,17 @@ #include #include -#include +#include //can't find that yet (ownedbywuigi) -#include "common/logging/log.h" -#include "core/crypto/key_manager.h" -#include "core/file_sys/card_image.h" -#include "core/file_sys/content_archive.h" -#include "core/file_sys/nca_metadata.h" -#include "core/file_sys/partition_filesystem.h" -#include "core/file_sys/submission_package.h" -#include "core/file_sys/vfs/vfs_offset.h" -#include "core/file_sys/vfs/vfs_vector.h" +#include "import/common/logging/log.h" +#include "import/core/crypto/key_manager.h" +#include "core/fs/card_image.h" +#include "core/fs/content_archive.h" +#include "core/fs/nca_metadata.h" +#include "core/fs/partition_filesystem.h" +#include "core/fs/submission_package.h" +#include "core/fs/vfs/vfs_offset.h" +#include "core/fs/vfs/vfs_vector.h" #include "core/loader/loader.h" namespace FileSys { diff --git a/import/common/fs/common_types.h b/import/common/fs/common_types.h new file mode 100644 index 0000000..ae04c4d --- /dev/null +++ b/import/common/fs/common_types.h @@ -0,0 +1,53 @@ +// SPDX-FileCopyrightText: 2012 Gekko Emulator +// SPDX-FileContributor: ShizZy +// SPDX-License-Identifier: GPL-2.0-or-later + +/** + * Copyright (C) 2005-2012 Gekko Emulator + * + * @file common_types.h + * @author ShizZy + * @date 2012-02-11 + * @brief Common types used throughout the project + * + * @section LICENSE + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details at + * http://www.gnu.org/copyleft/gpl.html + * + * Official project repository can be found at: + * http://code.google.com/p/gekko-gc-emu/ + */ + +#pragma once + +#include +#include + +using u8 = std::uint8_t; ///< 8-bit unsigned byte +using u16 = std::uint16_t; ///< 16-bit unsigned short +using u32 = std::uint32_t; ///< 32-bit unsigned word +using u64 = std::uint64_t; ///< 64-bit unsigned int + +using s8 = std::int8_t; ///< 8-bit signed byte +using s16 = std::int16_t; ///< 16-bit signed short +using s32 = std::int32_t; ///< 32-bit signed word +using s64 = std::int64_t; ///< 64-bit signed int + +using f32 = float; ///< 32-bit floating point +using f64 = double; ///< 64-bit floating point + +using VAddr = u64; ///< Represents a pointer in the userspace virtual address space. +using DAddr = u64; ///< Represents a pointer in the device specific virtual address space. +using PAddr = u64; ///< Represents a pointer in the ARM11 physical address space. +using GPUVAddr = u64; ///< Represents a pointer in the GPU virtual address space. + +using u128 = std::array; +static_assert(sizeof(u128) == 16, "u128 must be 128 bits wide"); diff --git a/import/common/logging/log.h b/import/common/logging/log.h new file mode 100644 index 0000000..c00c01a --- /dev/null +++ b/import/common/logging/log.h @@ -0,0 +1,67 @@ +// SPDX-FileCopyrightText: 2014 Citra Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include + +#include + +#include "common/logging/formatter.h" +#include "common/logging/types.h" + +namespace Common::Log { + +// trims up to and including the last of ../, ..\, src/, src\ in a string +constexpr const char* TrimSourcePath(std::string_view source) { + const auto rfind = [source](const std::string_view match) { + return source.rfind(match) == source.npos ? 0 : (source.rfind(match) + match.size()); + }; + auto idx = std::max({rfind("src/"), rfind("src\\"), rfind("../"), rfind("..\\")}); + return source.data() + idx; +} + +/// Logs a message to the global logger, using fmt +void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, + unsigned int line_num, const char* function, const char* format, + const fmt::format_args& args); + +template +void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsigned int line_num, + const char* function, const char* format, const Args&... args) { + FmtLogMessageImpl(log_class, log_level, filename, line_num, function, format, + fmt::make_format_args(args...)); +} + +} // namespace Common::Log + +#ifdef _DEBUG +#define LOG_TRACE(log_class, ...) \ + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Trace, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) +#else +#define LOG_TRACE(log_class, fmt, ...) (void(0)) +#endif + +#define LOG_DEBUG(log_class, ...) \ + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Debug, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) +#define LOG_INFO(log_class, ...) \ + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Info, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) +#define LOG_WARNING(log_class, ...) \ + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Warning, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) +#define LOG_ERROR(log_class, ...) \ + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Error, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__) +#define LOG_CRITICAL(log_class, ...) \ + Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Critical, \ + Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \ + __VA_ARGS__)