diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/alignment.h | 8 | ||||
| -rw-r--r-- | src/common/lz4_compression.cpp | 2 | ||||
| -rw-r--r-- | src/common/lz4_compression.h | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h index 0057052af..fc5c26898 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h | |||
| @@ -12,7 +12,9 @@ namespace Common { | |||
| 12 | 12 | ||
| 13 | template <typename T> | 13 | template <typename T> |
| 14 | requires std::is_integral_v<T> | 14 | requires std::is_integral_v<T> |
| 15 | [[nodiscard]] constexpr T AlignUp(T value, size_t size) { | 15 | [[nodiscard]] constexpr T AlignUp(T value_, size_t size) { |
| 16 | using U = typename std::make_unsigned_t<T>; | ||
| 17 | auto value{static_cast<U>(value_)}; | ||
| 16 | auto mod{static_cast<T>(value % size)}; | 18 | auto mod{static_cast<T>(value % size)}; |
| 17 | value -= mod; | 19 | value -= mod; |
| 18 | return static_cast<T>(mod == T{0} ? value : value + size); | 20 | return static_cast<T>(mod == T{0} ? value : value + size); |
| @@ -26,7 +28,9 @@ template <typename T> | |||
| 26 | 28 | ||
| 27 | template <typename T> | 29 | template <typename T> |
| 28 | requires std::is_integral_v<T> | 30 | requires std::is_integral_v<T> |
| 29 | [[nodiscard]] constexpr T AlignDown(T value, size_t size) { | 31 | [[nodiscard]] constexpr T AlignDown(T value_, size_t size) { |
| 32 | using U = typename std::make_unsigned_t<T>; | ||
| 33 | const auto value{static_cast<U>(value_)}; | ||
| 30 | return static_cast<T>(value - value % size); | 34 | return static_cast<T>(value - value % size); |
| 31 | } | 35 | } |
| 32 | 36 | ||
diff --git a/src/common/lz4_compression.cpp b/src/common/lz4_compression.cpp index 6867c03c4..d85ab1742 100644 --- a/src/common/lz4_compression.cpp +++ b/src/common/lz4_compression.cpp | |||
| @@ -71,7 +71,7 @@ std::vector<u8> DecompressDataLZ4(std::span<const u8> compressed, std::size_t un | |||
| 71 | return uncompressed; | 71 | return uncompressed; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | int DecompressLZ4(void* dst, size_t dst_size, const void* src, size_t src_size) { | 74 | int DecompressDataLZ4(void* dst, size_t dst_size, const void* src, size_t src_size) { |
| 75 | // This is just a thin wrapper around LZ4. | 75 | // This is just a thin wrapper around LZ4. |
| 76 | return LZ4_decompress_safe(reinterpret_cast<const char*>(src), reinterpret_cast<char*>(dst), | 76 | return LZ4_decompress_safe(reinterpret_cast<const char*>(src), reinterpret_cast<char*>(dst), |
| 77 | static_cast<int>(src_size), static_cast<int>(dst_size)); | 77 | static_cast<int>(src_size), static_cast<int>(dst_size)); |
diff --git a/src/common/lz4_compression.h b/src/common/lz4_compression.h index 7200e0f22..3ae17c2bb 100644 --- a/src/common/lz4_compression.h +++ b/src/common/lz4_compression.h | |||
| @@ -56,6 +56,6 @@ namespace Common::Compression { | |||
| 56 | [[nodiscard]] std::vector<u8> DecompressDataLZ4(std::span<const u8> compressed, | 56 | [[nodiscard]] std::vector<u8> DecompressDataLZ4(std::span<const u8> compressed, |
| 57 | std::size_t uncompressed_size); | 57 | std::size_t uncompressed_size); |
| 58 | 58 | ||
| 59 | int DecompressLZ4(void* dst, size_t dst_size, const void* src, size_t src_size); | 59 | [[nodiscard]] int DecompressDataLZ4(void* dst, size_t dst_size, const void* src, size_t src_size); |
| 60 | 60 | ||
| 61 | } // namespace Common::Compression | 61 | } // namespace Common::Compression |