Move alignment related consts from append_vec.rs to accounts_file.rs (#30782)
#### Problem As we start supporting new storage formats, alignment-related constants and macros defined in append_vec.rs aren't only specific to AppendVec. #### Summary of Changes Move alignment-related constants/macros from append_vec.rs to accounts_file.rs
This commit is contained in:
parent
9ad77485ce
commit
72c6099ea0
|
@ -5,8 +5,8 @@
|
|||
use {
|
||||
crate::{
|
||||
accounts_db::AppendVecId,
|
||||
accounts_file::ALIGN_BOUNDARY_OFFSET,
|
||||
accounts_index::{IsCached, ZeroLamport},
|
||||
append_vec::ALIGN_BOUNDARY_OFFSET,
|
||||
},
|
||||
modular_bitfield::prelude::*,
|
||||
};
|
||||
|
|
|
@ -9,11 +9,21 @@ use {
|
|||
solana_sdk::{account::ReadableAccount, clock::Slot, hash::Hash, pubkey::Pubkey},
|
||||
std::{
|
||||
borrow::Borrow,
|
||||
io,
|
||||
io, mem,
|
||||
path::{Path, PathBuf},
|
||||
},
|
||||
};
|
||||
|
||||
// Data placement should be aligned at the next boundary. Without alignment accessing the memory may
|
||||
// crash on some architectures.
|
||||
pub const ALIGN_BOUNDARY_OFFSET: usize = mem::size_of::<u64>();
|
||||
#[macro_export]
|
||||
macro_rules! u64_align {
|
||||
($addr: expr) => {
|
||||
($addr + (ALIGN_BOUNDARY_OFFSET - 1)) & !(ALIGN_BOUNDARY_OFFSET - 1)
|
||||
};
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// An enum for accessing an accounts file which can be implemented
|
||||
/// under different formats.
|
||||
|
|
|
@ -10,7 +10,9 @@ use {
|
|||
AccountMeta, StorableAccountsWithHashesAndWriteVersions, StoredAccountInfo,
|
||||
StoredAccountMeta, StoredMeta, StoredMetaWriteVersion,
|
||||
},
|
||||
accounts_file::ALIGN_BOUNDARY_OFFSET,
|
||||
storable_accounts::StorableAccounts,
|
||||
u64_align,
|
||||
},
|
||||
log::*,
|
||||
memmap2::MmapMut,
|
||||
|
@ -38,15 +40,6 @@ use {
|
|||
|
||||
pub mod test_utils;
|
||||
|
||||
// Data placement should be aligned at the next boundary. Without alignment accessing the memory may
|
||||
// crash on some architectures.
|
||||
pub const ALIGN_BOUNDARY_OFFSET: usize = mem::size_of::<u64>();
|
||||
macro_rules! u64_align {
|
||||
($addr: expr) => {
|
||||
($addr + (ALIGN_BOUNDARY_OFFSET - 1)) & !(ALIGN_BOUNDARY_OFFSET - 1)
|
||||
};
|
||||
}
|
||||
|
||||
/// size of the fixed sized fields in an append vec
|
||||
/// we need to add data len and align it to get the actual stored size
|
||||
pub const STORE_META_OVERHEAD: usize = 136;
|
||||
|
|
Loading…
Reference in New Issue