فهرست منبع

解决fork的时候,报空指针的问题(原因是dragonos目前不支持thread local) (#13)

LoGin 1 سال پیش
والد
کامیت
f9f3597d58
2فایلهای تغییر یافته به همراه6 افزوده شده و 0 حذف شده
  1. 1 0
      Cargo.lock
  2. 5 0
      src/header/unistd/mod.rs

+ 1 - 0
Cargo.lock

@@ -111,6 +111,7 @@ version = "0.1.0"
 [[package]]
 name = "dragonos-dsc"
 version = "0.0.1"
+source = "git+https://github.com/DragonOS-Community/dsc.git?rev=f57e668#f57e6686c1c6d10210e2dbb7b073c50f305bebc5"
 
 [[package]]
 name = "errno"

+ 5 - 0
src/header/unistd/mod.rs

@@ -37,9 +37,14 @@ pub const STDIN_FILENO: c_int = 0;
 pub const STDOUT_FILENO: c_int = 1;
 pub const STDERR_FILENO: c_int = 2;
 
+#[cfg(not(target_os = "dragonos"))]
 #[thread_local]
 pub static mut fork_hooks_static: Option<[LinkedList<extern "C" fn()>; 3]> = None;
 
+/// due to dragonos not supporting thread_local, we need to use a static directly
+#[cfg(target_os = "dragonos")]
+pub static mut fork_hooks_static: Option<[LinkedList<extern "C" fn()>; 3]> = None;
+
 unsafe fn init_fork_hooks<'a>() -> &'a mut [LinkedList<extern "C" fn()>; 3] {
     // Transmute the lifetime so we can return here. Should be safe as
     // long as one does not access the original fork_hooks.