I've got the following:
#[repr(transparent)]
pub struct AtomicBitmap64(AtomicU64);
impl AtomicBitmap64 {
pub const fn new() -> Self {
AtomicBitmap64(AtomicU64::new(0))
}
pub fn set_bit(&self, n: u8) -> bool {
let b: u64 = 1 << (n as u64);
self.0.fetch_or(b, Ordering::AcqRel) & b != 0
}
pub fn clear_bit(&self, n: u8) -> bool {
let b: u64 = 1 << (n as u64);
self.0.fetch_and(!b, Ordering::AcqRel) & b != 0
}
pub fn invert_bit(&self, n: u8) -> bool {
let b: u64 = 1 << (n as u64);
self.0.fetch_xor(b, Ordering::AcqRel) & b != 0
}
}
Then, somewhere in code, I have a static variable initialized:
static MY_BITMAP: AtomicBitmap64 = AtomicBitmap64::new();
When I disassemble the resulting image, I see the static in .bss section, but it is never initialized to 0 in code. Am I doing anything wrong? Do I need to initialize the whole .bss section manually? (If yes, then how to do it properly)?