1 #![allow(dead_code)]
2 use core::ptr::{read_volatile, write_volatile};
3 
4 use crate::include::bindings::bindings::atomic_t;
5 
6 /// @brief 原子的读取指定的原子变量的值
7 #[inline]
atomic_read(ato: *const atomic_t) -> i648 pub fn atomic_read(ato: *const atomic_t) -> i64 {
9     unsafe {
10         return read_volatile(&(*ato).value);
11     }
12 }
13 
14 /// @brief 原子的设置原子变量的值
15 #[inline]
atomic_set(ato: *mut atomic_t, value:i64)16 pub fn atomic_set(ato: *mut atomic_t, value:i64) {
17     unsafe{
18         write_volatile(&mut (*ato).value, value);
19     }
20 }
21 
22 impl Default for atomic_t {
default() -> Self23     fn default() -> Self {
24         Self { value: 0 }
25     }
26 }
27