From fc56cf9806ebcde82707b9cbeee11b621d10bbda Mon Sep 17 00:00:00 2001 From: shuaihu Date: Fri, 22 Jul 2022 11:22:53 +0000 Subject: [PATCH 1/2] commit test --- build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.rs b/build.rs index fa3a283..379b25f 100644 --- a/build.rs +++ b/build.rs @@ -27,7 +27,9 @@ fn main() { write!(fcfg, "pub const CPU_CORE_NUMBERS: usize = {}usize;", cpus).unwrap(); } + println!("cargo:rerun-if-changed=build.rs"); + println!( "cargo:rerun-if-changed={}", top_path.join(".cargo/config.toml").to_str().unwrap() -- Gitee From 1c1488d53768d1687b67bd26752a3b730dfdc752 Mon Sep 17 00:00:00 2001 From: "hongwei.li" Date: Wed, 10 Aug 2022 14:05:16 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=89=88=E6=9D=83?= =?UTF-8?q?=E5=A3=B0=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/liteos/mod.rs | 3 +++ examples/liteos/mutex.rs | 3 +++ examples/liteos/parker.rs | 3 +++ examples/test_liteos.rs | 3 +++ src/anyhow.rs | 3 +++ src/no_std/collections/mod.rs | 3 +++ src/no_std/collections/objpool.rs | 3 +++ src/no_std/collections/objpool/tests.rs | 3 +++ src/no_std/collections/unbounded.rs | 3 +++ src/no_std/collections/unbounded/tests.rs | 3 +++ src/no_std/error.rs | 3 +++ src/no_std/error/tests.rs | 3 +++ src/no_std/io/error.rs | 3 +++ src/no_std/io/mod.rs | 3 +++ src/no_std/lazy.rs | 3 +++ src/no_std/lazy/tests.rs | 3 +++ src/no_std/mod.rs | 3 +++ src/no_std/sync/condvar.rs | 3 +++ src/no_std/sync/condvar/tests.rs | 3 +++ src/no_std/sync/mod.rs | 3 +++ src/no_std/sync/mutex.rs | 3 +++ src/no_std/sync/mutex/tests.rs | 3 +++ src/no_std/sync/once.rs | 3 +++ src/no_std/sync/once/tests.rs | 3 +++ src/no_std/sync/parker.rs | 3 +++ src/no_std/sync/rwlock.rs | 3 +++ src/no_std/sync/rwlock/tests.rs | 3 +++ src/no_std/sync/spinlock.rs | 3 +++ src/no_std/thread.rs | 3 +++ src/std/io/error.rs | 3 +++ src/std/io/mod.rs | 3 +++ src/std/mod.rs | 3 +++ src/std/sync/condvar.rs | 3 +++ src/std/sync/mod.rs | 3 +++ src/std/sync/mutex.rs | 3 +++ src/std/sync/rwlock.rs | 3 +++ src/std/thread.rs | 3 +++ 37 files changed, 111 insertions(+) diff --git a/examples/liteos/mod.rs b/examples/liteos/mod.rs index 29eca78..a9556e8 100644 --- a/examples/liteos/mod.rs +++ b/examples/liteos/mod.rs @@ -1,4 +1,7 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 mod parker; pub use parker::*; mod mutex; pub use mutex::*; + diff --git a/examples/liteos/mutex.rs b/examples/liteos/mutex.rs index 70124c3..d508391 100644 --- a/examples/liteos/mutex.rs +++ b/examples/liteos/mutex.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use alloc::sync::Arc; use stdlib::sync::Mutex; use stdlib::thread; @@ -16,3 +18,4 @@ pub fn mutex_test() { let mm = mutex.lock(); assert_eq!(*mm, 46); } + diff --git a/examples/liteos/parker.rs b/examples/liteos/parker.rs index a60f2f7..82080b8 100644 --- a/examples/liteos/parker.rs +++ b/examples/liteos/parker.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use stdlib::{println, sync::parker::*, thread}; pub fn park_timeout_unpark_before() { @@ -45,3 +47,4 @@ pub fn parker_driver_led() { u.unpark(); } } + diff --git a/examples/test_liteos.rs b/examples/test_liteos.rs index cd15257..a983706 100644 --- a/examples/test_liteos.rs +++ b/examples/test_liteos.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #![no_std] #![feature(default_alloc_error_handler)] #![feature(panic_info_message)] @@ -42,3 +44,4 @@ unsafe extern "C" fn app_init() { println!("{}", "Test Mutex start..."); mutex_test(); } + diff --git a/src/anyhow.rs b/src/anyhow.rs index 90df121..e112c3e 100644 --- a/src/anyhow.rs +++ b/src/anyhow.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use alloc::{ alloc::dealloc, boxed::Box, @@ -144,3 +146,4 @@ impl Context for result::Result { } pub type Result = result::Result; + diff --git a/src/no_std/collections/mod.rs b/src/no_std/collections/mod.rs index 7af6105..6df7fb9 100644 --- a/src/no_std/collections/mod.rs +++ b/src/no_std/collections/mod.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 pub enum PopError { /// The queue is empty but not closed. Empty, @@ -126,3 +128,4 @@ use core::fmt; use core::sync::atomic::{self, AtomicUsize, Ordering}; mod unbounded; pub use unbounded::Unbounded; + diff --git a/src/no_std/collections/objpool.rs b/src/no_std/collections/objpool.rs index ba21022..ddaa19e 100644 --- a/src/no_std/collections/objpool.rs +++ b/src/no_std/collections/objpool.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test, not(target_os = "none")))] mod tests; use crate::sync::parker::Parker; @@ -350,3 +352,4 @@ impl Drop for ObjPool { } } } + diff --git a/src/no_std/collections/objpool/tests.rs b/src/no_std/collections/objpool/tests.rs index e909de3..64b63a5 100644 --- a/src/no_std/collections/objpool/tests.rs +++ b/src/no_std/collections/objpool/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use super::Obj; use alloc::format; use alloc::sync::Arc; @@ -54,3 +56,4 @@ fn test_new() { } assert_eq!(1, 1); } + diff --git a/src/no_std/collections/unbounded.rs b/src/no_std/collections/unbounded.rs index bf82f33..9d5517e 100644 --- a/src/no_std/collections/unbounded.rs +++ b/src/no_std/collections/unbounded.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test, not(target_os = "none")))] mod tests; use crate::thread; @@ -409,3 +411,4 @@ impl Drop for Unbounded { } } } + diff --git a/src/no_std/collections/unbounded/tests.rs b/src/no_std/collections/unbounded/tests.rs index 4cb52d3..dd0ca31 100644 --- a/src/no_std/collections/unbounded/tests.rs +++ b/src/no_std/collections/unbounded/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use super::Unbounded; #[test] @@ -12,3 +14,4 @@ fn test_push_pop() { assert_eq!(d, 456); } } + diff --git a/src/no_std/error.rs b/src/no_std/error.rs index 13ea387..e960633 100644 --- a/src/no_std/error.rs +++ b/src/no_std/error.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test,not(target_os="none")))] mod tests; @@ -263,3 +265,4 @@ impl dyn Error + Send + Sync { }) } } + diff --git a/src/no_std/error/tests.rs b/src/no_std/error/tests.rs index 64d1f9d..62e4ba7 100644 --- a/src/no_std/error/tests.rs +++ b/src/no_std/error/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 extern crate std; use std::println; @@ -41,3 +43,4 @@ fn test_boxerr() { // Err(e) => assert_eq!(*e.downcast::().unwrap(), A), // } // } + diff --git a/src/no_std/io/error.rs b/src/no_std/io/error.rs index 297671b..0d89ce1 100644 --- a/src/no_std/io/error.rs +++ b/src/no_std/io/error.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test,not(target_os="none")))] mod tests; use core::{ @@ -143,3 +145,4 @@ impl From for Error { Self::from_raw_os_error(v.raw_os_error()) } } + diff --git a/src/no_std/io/mod.rs b/src/no_std/io/mod.rs index 7edf3bf..a5b2395 100644 --- a/src/no_std/io/mod.rs +++ b/src/no_std/io/mod.rs @@ -1,2 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 mod error; pub use error::*; + diff --git a/src/no_std/lazy.rs b/src/no_std/lazy.rs index fd38e90..41d238b 100644 --- a/src/no_std/lazy.rs +++ b/src/no_std/lazy.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 //! Lazy values and one-time initialization of static data. #[cfg(test)] @@ -267,3 +269,4 @@ impl Default for SyncLazy { SyncLazy::new(T::default) } } + diff --git a/src/no_std/lazy/tests.rs b/src/no_std/lazy/tests.rs index 8b13789..290b56e 100644 --- a/src/no_std/lazy/tests.rs +++ b/src/no_std/lazy/tests.rs @@ -1 +1,4 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + diff --git a/src/no_std/mod.rs b/src/no_std/mod.rs index df94624..8e502c5 100644 --- a/src/no_std/mod.rs +++ b/src/no_std/mod.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 pub mod collections; pub mod error; pub mod io; @@ -18,3 +20,4 @@ pub macro println{ unsafe{ $crate::printf(s.as_ptr().cast()) } } } + diff --git a/src/no_std/sync/condvar.rs b/src/no_std/sync/condvar.rs index dca3fc7..280a7be 100644 --- a/src/no_std/sync/condvar.rs +++ b/src/no_std/sync/condvar.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] mod tests; @@ -119,3 +121,4 @@ impl Condvar { self.inner.notify_all() } } + diff --git a/src/no_std/sync/condvar/tests.rs b/src/no_std/sync/condvar/tests.rs index 47df0b8..b0f14ba 100644 --- a/src/no_std/sync/condvar/tests.rs +++ b/src/no_std/sync/condvar/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use core::sync::atomic::{AtomicBool, Ordering}; use crate::{sync::Mutex, thread}; @@ -165,3 +167,4 @@ fn wait_timeout_wake() { // let m = Mutex::new(()); // let _ = c.wait(m.lock()); // } + diff --git a/src/no_std/sync/mod.rs b/src/no_std/sync/mod.rs index 472756d..a8427e2 100644 --- a/src/no_std/sync/mod.rs +++ b/src/no_std/sync/mod.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(unix)] mod condvar; @@ -17,3 +19,4 @@ pub use once::{Once, OnceState}; #[cfg(unix)] pub use rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard}; pub use spinlock::*; + diff --git a/src/no_std/sync/mutex.rs b/src/no_std/sync/mutex.rs index c07e670..007740b 100644 --- a/src/no_std/sync/mutex.rs +++ b/src/no_std/sync/mutex.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test, not(target_os = "none")))] mod tests; use arch::locks::MovableMutex as imp; @@ -114,3 +116,4 @@ impl Drop for MutexGuard<'_, T> { pub(super) fn guard_lock<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a MovableMutex { &guard.lock.inner } + diff --git a/src/no_std/sync/mutex/tests.rs b/src/no_std/sync/mutex/tests.rs index 3aa8041..e32c24c 100644 --- a/src/no_std/sync/mutex/tests.rs +++ b/src/no_std/sync/mutex/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 extern crate std; use crate::sync::mutex::Mutex; use crate::thread; @@ -38,3 +40,4 @@ fn lots_and_lots() { } assert_eq!(*m.lock(), J * K * 2); } + diff --git a/src/no_std/sync/once.rs b/src/no_std/sync/once.rs index ccfe028..16714b6 100644 --- a/src/no_std/sync/once.rs +++ b/src/no_std/sync/once.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test, not(target_os = "none")))] mod tests; @@ -266,3 +268,4 @@ impl OnceState { self.set_state_on_drop_to.set(ptr::invalid_mut(POISONED)); } } + diff --git a/src/no_std/sync/once/tests.rs b/src/no_std/sync/once/tests.rs index bed344c..1811534 100644 --- a/src/no_std/sync/once/tests.rs +++ b/src/no_std/sync/once/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 extern crate std; use super::Once; use crate::thread; @@ -87,3 +89,4 @@ fn wait_for_force_to_finish() { assert!(t1.join()); assert!(t2.join()); } + diff --git a/src/no_std/sync/parker.rs b/src/no_std/sync/parker.rs index fd6927c..978d4a5 100644 --- a/src/no_std/sync/parker.rs +++ b/src/no_std/sync/parker.rs @@ -1 +1,4 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 pub use arch::locks::parker::*; + diff --git a/src/no_std/sync/rwlock.rs b/src/no_std/sync/rwlock.rs index 10f82ad..3b9da7e 100644 --- a/src/no_std/sync/rwlock.rs +++ b/src/no_std/sync/rwlock.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] mod tests; @@ -161,3 +163,4 @@ impl RwLock { self.data.get_mut() } } + diff --git a/src/no_std/sync/rwlock/tests.rs b/src/no_std/sync/rwlock/tests.rs index b3f2a17..756df8b 100644 --- a/src/no_std/sync/rwlock/tests.rs +++ b/src/no_std/sync/rwlock/tests.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use core::mem::{size_of, size_of_val}; use super::RwLock; @@ -37,3 +39,4 @@ fn test_read_lock() { let c = lk.read(); assert_eq!(*c, 256); } + diff --git a/src/no_std/sync/spinlock.rs b/src/no_std/sync/spinlock.rs index 6f16974..5828b70 100644 --- a/src/no_std/sync/spinlock.rs +++ b/src/no_std/sync/spinlock.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 use crate::os::CPU_CORE_NUMBERS; use crate::thread::yield_now; use core::{ @@ -72,3 +74,4 @@ impl<'a, T> Drop for SpinlockGuard<'a, T> { self.lock.store(false, Ordering::SeqCst); } } + diff --git a/src/no_std/thread.rs b/src/no_std/thread.rs index 9bc8ba7..07a4eda 100644 --- a/src/no_std/thread.rs +++ b/src/no_std/thread.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(all(test, not(target_os = "none")))] mod tests; use crate::io::Result; @@ -143,3 +145,4 @@ impl JoinHandle { Arc::strong_count(&self.0.packet) == 1 } } + diff --git a/src/std/io/error.rs b/src/std/io/error.rs index d84763a..6c001df 100644 --- a/src/std/io/error.rs +++ b/src/std/io/error.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] #[path = "../../no_std/io/error/tests.rs"] mod tests; @@ -65,3 +67,4 @@ impl From for imp { e.into_raw() } } + diff --git a/src/std/io/mod.rs b/src/std/io/mod.rs index 7edf3bf..a5b2395 100644 --- a/src/std/io/mod.rs +++ b/src/std/io/mod.rs @@ -1,2 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 mod error; pub use error::*; + diff --git a/src/std/mod.rs b/src/std/mod.rs index 1e66ca5..b9d5a0f 100644 --- a/src/std/mod.rs +++ b/src/std/mod.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[macro_export] macro_rules! println { () => { @@ -31,3 +33,4 @@ pub mod sync; pub mod thread; pub use std::error; pub use std::lazy; + diff --git a/src/std/sync/condvar.rs b/src/std/sync/condvar.rs index b22a1e5..36bea6f 100644 --- a/src/std/sync/condvar.rs +++ b/src/std/sync/condvar.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] #[path = "../../no_std/sync/condvar/tests.rs"] mod tests; @@ -68,3 +70,4 @@ impl Condvar { self.0.notify_all(); } } + diff --git a/src/std/sync/mod.rs b/src/std/sync/mod.rs index 00d0b9c..ab1f355 100644 --- a/src/std/sync/mod.rs +++ b/src/std/sync/mod.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 mod condvar; mod mutex; pub use condvar::*; @@ -9,3 +11,4 @@ mod spinlock; pub use spinlock::*; pub mod parker; pub use std::sync::{Once, OnceState}; + diff --git a/src/std/sync/mutex.rs b/src/std/sync/mutex.rs index 346e6c6..d74836e 100644 --- a/src/std/sync/mutex.rs +++ b/src/std/sync/mutex.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] #[path = "../../no_std/sync/mutex/tests.rs"] mod tests; @@ -35,3 +37,4 @@ impl Mutex { unsafe { self.0.get_mut().unwrap_unchecked() } } } + diff --git a/src/std/sync/rwlock.rs b/src/std/sync/rwlock.rs index 8068848..0c93001 100644 --- a/src/std/sync/rwlock.rs +++ b/src/std/sync/rwlock.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] #[path = "../../no_std/sync/rwlock/tests.rs"] mod tests; @@ -38,3 +40,4 @@ impl RwLock { unsafe { self.0.get_mut().unwrap_unchecked() } } } + diff --git a/src/std/thread.rs b/src/std/thread.rs index 7091f1d..63b0cdc 100644 --- a/src/std/thread.rs +++ b/src/std/thread.rs @@ -1,3 +1,5 @@ +// Copyright (C) 2022-2022 Agilor Co.,Ltd. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 #[cfg(test)] #[path = "../no_std/thread/tests.rs"] mod tests; @@ -80,3 +82,4 @@ impl Builder { core::mem::transmute(rtn) } } + -- Gitee