1use std::sync::atomic::{AtomicU64, Ordering};
2
3pub(crate) const WATERMARK: u64 = 0xFFFF_FFFF_1111_1111;
4pub(crate) const CLOSE: u64 = 0xFFFF_FFFF_FFFF_FFFF;
5pub(crate) const U64_SIZE: usize = std::mem::size_of::<u64>(); pub(crate) const REC_HEADER_LEN: u32 = 8; pub(crate) const FOOTER_LEN: u32 = 32; const REC_ALIGNMENT: u32 = U64_SIZE as u32; #[inline]
12pub(crate) const fn align(value: u32) -> u32 {
13 (value + (REC_ALIGNMENT - 1)) & !(REC_ALIGNMENT - 1)
14}
15
16#[inline]
17pub(crate) const fn is_aligned(val: u32) -> bool {
18 val & (REC_ALIGNMENT - 1) == 0
19}
20
21#[inline]
22pub(crate) fn store_atomic_u64(pos_ptr: *mut u64, value: u64, order: Ordering) {
23 let store_pos = unsafe { &*(pos_ptr as *const AtomicU64) };
24 store_pos.store(value, order);
25}
26
27#[inline]
28pub(crate) fn load_atomic_u64(pos_ptr: *mut u64, order: Ordering) -> u64 {
29 let store_pos = unsafe { &*(pos_ptr as *const AtomicU64) };
30 store_pos.load(order)
31}