浏览代码

Merge branch 'YdrMaster-main'

luojia65 2 年之前
父节点
当前提交
cc059bbebc
共有 2 个文件被更改,包括 3 次插入2 次删除
  1. 2 0
      src/lib.rs
  2. 1 2
      src/util.rs

+ 2 - 0
src/lib.rs

@@ -190,6 +190,8 @@
 #![feature(ptr_metadata)]
 #![deny(warnings)] // cancel this line for developing
 
+extern crate alloc;
+
 #[cfg(feature = "legacy")]
 #[doc(hidden)]
 #[macro_use]

+ 1 - 2
src/util.rs

@@ -1,7 +1,6 @@
 //! useful structures
 
 use core::{arch::asm, cell::UnsafeCell, marker::PhantomData, mem::MaybeUninit, ptr::Pointee};
-
 /// 只使用 AMO 指令的一次初始化引用存储。
 pub struct AmoOnceRef<'a, T: ?Sized> {
     /// As atomic bool, to check if it is the first time to set `ptr`.
@@ -61,6 +60,7 @@ impl<'a, T: ?Sized> AmoOnceRef<'a, T> {
                     dst = in(reg) self.ptr.get(),
                 );
             }
+
             true
         } else {
             // 未取得锁,对象已被初始化过
@@ -116,7 +116,6 @@ impl<'a, T: ?Sized> AmoOnceRef<'a, T> {
         }
     }
 
-    #[inline]
     unsafe fn build_ref_unchecked(&self, ptr: *const ()) -> &T {
         &*core::ptr::from_raw_parts(ptr, (*self.meta.get()).assume_init())
     }