diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/common/alignment.h | 22 | ||||
-rw-r--r-- | src/common/common_types.h | 6 | ||||
-rw-r--r-- | src/common/logging/backend.cpp | 1 | ||||
-rw-r--r-- | src/common/logging/log.h | 1 |
5 files changed, 28 insertions, 3 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 959084cdf..1c9be718f 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -22,6 +22,7 @@ set(SRCS ) set(HEADERS + alignment.h assert.h bit_field.h bit_set.h diff --git a/src/common/alignment.h b/src/common/alignment.h new file mode 100644 index 000000000..b77da4a92 --- /dev/null +++ b/src/common/alignment.h @@ -0,0 +1,22 @@ +// This file is under the public domain. + +#pragma once + +#include <cstddef> +#include <type_traits> + +namespace Common { + +template <typename T> +constexpr T AlignUp(T value, size_t size) { + static_assert(std::is_unsigned<T>::value, "T must be an unsigned value."); + return static_cast<T>(value + (size - value % size) % size); +} + +template <typename T> +constexpr T AlignDown(T value, size_t size) { + static_assert(std::is_unsigned<T>::value, "T must be an unsigned value."); + return static_cast<T>(value - value % size); +} + +} // namespace Common diff --git a/src/common/common_types.h b/src/common/common_types.h index fa3e0b8d6..9f51dff18 100644 --- a/src/common/common_types.h +++ b/src/common/common_types.h @@ -53,9 +53,9 @@ typedef u32 PAddr; ///< Represents a pointer in the ARM11 physical address space // An inheritable class to disallow the copy constructor and operator= functions class NonCopyable { protected: - NonCopyable() = default; + constexpr NonCopyable() = default; ~NonCopyable() = default; - NonCopyable(NonCopyable&) = delete; - NonCopyable& operator=(NonCopyable&) = delete; + NonCopyable(const NonCopyable&) = delete; + NonCopyable& operator=(const NonCopyable&) = delete; }; diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 54291429a..4c86151ab 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -42,6 +42,7 @@ namespace Log { SUB(Service, AM) \ SUB(Service, PTM) \ SUB(Service, LDR) \ + SUB(Service, NDM) \ SUB(Service, NIM) \ SUB(Service, NWM) \ SUB(Service, CAM) \ diff --git a/src/common/logging/log.h b/src/common/logging/log.h index 4b01805ae..e4c39c308 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -57,6 +57,7 @@ enum class Class : ClassType { Service_AM, ///< The AM (Application manager) service Service_PTM, ///< The PTM (Power status & misc.) service Service_LDR, ///< The LDR (3ds dll loader) service + Service_NDM, ///< The NDM (Network daemon manager) service Service_NIM, ///< The NIM (Network interface manager) service Service_NWM, ///< The NWM (Network wlan manager) service Service_CAM, ///< The CAM (Camera) service |