Maufeat
6 months ago
committed by
crueter
No known key found for this signature in database
GPG Key ID: 425ACD2D4830EBC6
2 changed files with
8 additions and
29 deletions
-
src/core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.cpp
-
src/core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.cpp
|
|
|
@ -5,22 +5,9 @@ |
|
|
|
#include "common/scope_exit.h"
|
|
|
|
#include "core/file_sys/fssystem/fssystem_hierarchical_sha256_storage.h"
|
|
|
|
|
|
|
|
namespace FileSys { |
|
|
|
|
|
|
|
namespace { |
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
s32 Log2(s32 value) { |
|
|
|
ASSERT(value > 0); |
|
|
|
ASSERT(Common::IsPowerOfTwo(value)); |
|
|
|
|
|
|
|
s32 log = 0; |
|
|
|
while ((value >>= 1) > 0) { |
|
|
|
++log; |
|
|
|
} |
|
|
|
return log; |
|
|
|
} |
|
|
|
|
|
|
|
} // namespace
|
|
|
|
namespace FileSys { |
|
|
|
|
|
|
|
Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 layer_count, |
|
|
|
size_t htbs, void* hash_buf, size_t hash_buf_size) { |
|
|
|
@ -31,7 +18,8 @@ Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 lay |
|
|
|
|
|
|
|
// Set size tracking members.
|
|
|
|
m_hash_target_block_size = static_cast<s32>(htbs); |
|
|
|
m_log_size_ratio = Log2(m_hash_target_block_size / HashSize); |
|
|
|
m_log_size_ratio = |
|
|
|
static_cast<s32>(std::log2(static_cast<double>(m_hash_target_block_size) / HashSize)); |
|
|
|
|
|
|
|
// Get the base storage size.
|
|
|
|
m_base_storage_size = base_storages[2]->GetSize(); |
|
|
|
|
|
|
|
@ -5,19 +5,9 @@ |
|
|
|
#include "common/scope_exit.h"
|
|
|
|
#include "core/file_sys/fssystem/fssystem_hierarchical_sha3_storage.h"
|
|
|
|
|
|
|
|
namespace FileSys { |
|
|
|
#include <cmath>
|
|
|
|
|
|
|
|
namespace { |
|
|
|
s32 Log2(s32 value) { |
|
|
|
ASSERT(value > 0); |
|
|
|
ASSERT(Common::IsPowerOfTwo(value)); |
|
|
|
s32 log = 0; |
|
|
|
while ((value >>= 1) > 0) { |
|
|
|
++log; |
|
|
|
} |
|
|
|
return log; |
|
|
|
} |
|
|
|
} // namespace
|
|
|
|
namespace FileSys { |
|
|
|
|
|
|
|
Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer_count, size_t htbs, |
|
|
|
void* hash_buf, size_t hash_buf_size) { |
|
|
|
@ -26,7 +16,8 @@ Result HierarchicalSha3Storage::Initialize(VirtualFile* base_storages, s32 layer |
|
|
|
ASSERT(hash_buf != nullptr); |
|
|
|
|
|
|
|
m_hash_target_block_size = static_cast<s32>(htbs); |
|
|
|
m_log_size_ratio = Log2(m_hash_target_block_size / HashSize); |
|
|
|
m_log_size_ratio = |
|
|
|
static_cast<s32>(std::log2(static_cast<double>(m_hash_target_block_size) / HashSize)); |
|
|
|
|
|
|
|
m_base_storage_size = base_storages[2]->GetSize(); |
|
|
|
{ |
|
|
|
|