mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-21 23:56:18 +04:00
update Rust nightly to 2020-04-06
This commit is contained in:
parent
a2a5bd6079
commit
139544f946
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@ -7,11 +7,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: rm rust-toolchain
|
|
||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly
|
toolchain: nightly-2020-04-06
|
||||||
override: true
|
override: true
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- name: Check code format
|
- name: Check code format
|
||||||
@ -30,7 +29,7 @@ jobs:
|
|||||||
- uses: actions-rs/toolchain@v1
|
- uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: nightly-2020-03-23
|
toolchain: nightly-2020-04-06
|
||||||
components: rust-src, llvm-tools-preview
|
components: rust-src, llvm-tools-preview
|
||||||
|
|
||||||
- name: Cache QEMU
|
- name: Cache QEMU
|
||||||
|
12
kernel/Cargo.lock
generated
12
kernel/Cargo.lock
generated
@ -107,7 +107,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "buddy_system_allocator"
|
name = "buddy_system_allocator"
|
||||||
version = "0.3.8"
|
version = "0.3.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustversion 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustversion 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -331,7 +331,7 @@ name = "rboot"
|
|||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"uefi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"uefi 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"x86_64 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"x86_64 0.9.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"xmas-elf 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"xmas-elf 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
@ -349,7 +349,7 @@ dependencies = [
|
|||||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)",
|
"bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)",
|
||||||
"bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"buddy_system_allocator 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
"buddy_system_allocator 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"compression 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"compression 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"device_tree 1.0.3 (git+https://github.com/rcore-os/device_tree-rs)",
|
"device_tree 1.0.3 (git+https://github.com/rcore-os/device_tree-rs)",
|
||||||
@ -580,7 +580,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uefi"
|
name = "uefi"
|
||||||
version = "0.4.3"
|
version = "0.4.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -728,7 +728,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||||
"checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>"
|
"checksum bitmap-allocator 0.1.0 (git+https://github.com/rcore-os/bitmap-allocator)" = "<none>"
|
||||||
"checksum bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fe4300c1d7a9ea6f3e3f39c10b39862bb79e1175c0572b6b49539a30e5562f5"
|
"checksum bitvec 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fe4300c1d7a9ea6f3e3f39c10b39862bb79e1175c0572b6b49539a30e5562f5"
|
||||||
"checksum buddy_system_allocator 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "09072aa89a810228c822e132e4639ff17bab014ba5b2dce5270a6331ff1963ca"
|
"checksum buddy_system_allocator 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9e953b958d83e13a44b1ead5b6aaa2a5f854bd5170239a66b606e030a14d018f"
|
||||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
||||||
"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
|
"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0"
|
||||||
"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
||||||
@ -780,7 +780,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
|
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
|
||||||
"checksum uart_16550 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc0bc8ff1beb1436e8c4ce9c4b47f6f6c1376b56fb91505fabeef13743eb33"
|
"checksum uart_16550 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc0bc8ff1beb1436e8c4ce9c4b47f6f6c1376b56fb91505fabeef13743eb33"
|
||||||
"checksum ucs2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85061f4e43545a613c0da6b87725bf23f8da8613cf2473719c4f71a270c4ce8a"
|
"checksum ucs2 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85061f4e43545a613c0da6b87725bf23f8da8613cf2473719c4f71a270c4ce8a"
|
||||||
"checksum uefi 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "36c63ddfef80d9e7f1318917f6c05135b3b98027e973a9e9f0a6aebe87b95934"
|
"checksum uefi 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5cec6a2850639f588cc8042140b5deaa2f2170c23db5adb08f4316fa04cdb4a0"
|
||||||
"checksum uefi-macros 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7d4a1b0215dc72e83d8d501b3275eb59477d3b595be8861abfb8ab110180955"
|
"checksum uefi-macros 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7d4a1b0215dc72e83d8d501b3275eb59477d3b595be8861abfb8ab110180955"
|
||||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
||||||
"checksum usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5"
|
"checksum usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5"
|
||||||
|
@ -55,7 +55,7 @@ bitflags = "1.2"
|
|||||||
bit_field = "0.10"
|
bit_field = "0.10"
|
||||||
volatile = "0.2"
|
volatile = "0.2"
|
||||||
bitvec = { version = "0.17", default-features = false, features = ["alloc"] }
|
bitvec = { version = "0.17", default-features = false, features = ["alloc"] }
|
||||||
buddy_system_allocator = "0.3"
|
buddy_system_allocator = "0.3.9"
|
||||||
pci = { git = "https://github.com/rcore-os/pci-rs" }
|
pci = { git = "https://github.com/rcore-os/pci-rs" }
|
||||||
device_tree = { git = "https://github.com/rcore-os/device_tree-rs" }
|
device_tree = { git = "https://github.com/rcore-os/device_tree-rs" }
|
||||||
isomorphic_drivers = { git = "https://github.com/rcore-os/isomorphic_drivers", features = ["log"] }
|
isomorphic_drivers = { git = "https://github.com/rcore-os/isomorphic_drivers", features = ["log"] }
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
//! 完全照搬`std::sync::Semaphore`,std中已经废弃。
|
//! 完全照搬`std::sync::Semaphore`,std中已经废弃。
|
||||||
//! 貌似在Rust中并不常用,一般都用`Mutex`。
|
//! 貌似在Rust中并不常用,一般都用`Mutex`。
|
||||||
//!
|
//!
|
||||||
//! * `mpsc`: 消息传递通道。
|
|
||||||
//! 多生产者-单消费者的FIFO队列。用于在线程间传递数据。
|
|
||||||
//!
|
|
||||||
//! * `test`: 测试。
|
//! * `test`: 测试。
|
||||||
//! 目前分别用`Mutex`和`Condvar`(Monitor)实现了哲学家就餐问题。
|
//! 目前分别用`Mutex`和`Condvar`(Monitor)实现了哲学家就餐问题。
|
||||||
//!
|
//!
|
||||||
@ -55,7 +52,6 @@ pub use self::mutex::*;
|
|||||||
pub use self::semaphore::*;
|
pub use self::semaphore::*;
|
||||||
|
|
||||||
mod condvar;
|
mod condvar;
|
||||||
pub mod mpsc;
|
|
||||||
mod mutex;
|
mod mutex;
|
||||||
mod semaphore;
|
mod semaphore;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
@ -1,145 +0,0 @@
|
|||||||
use super::Condvar;
|
|
||||||
use super::SpinLock as Mutex;
|
|
||||||
use alloc::{collections::VecDeque, sync::Arc, sync::Weak};
|
|
||||||
|
|
||||||
struct Channel<T> {
|
|
||||||
deque: Mutex<VecDeque<T>>,
|
|
||||||
pushed: Condvar,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Default for Channel<T> {
|
|
||||||
fn default() -> Self {
|
|
||||||
Channel {
|
|
||||||
deque: Mutex::<_>::default(),
|
|
||||||
pushed: Condvar::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The receiving half of Rust's channel (or sync_channel) type.
|
|
||||||
/// This half can only be owned by one thread.
|
|
||||||
///
|
|
||||||
/// Messages sent to the channel can be retrieved using recv.
|
|
||||||
pub struct Receiver<T> {
|
|
||||||
inner: Arc<Channel<T>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<T: Send> Send for Receiver<T> {}
|
|
||||||
|
|
||||||
impl<T> !Sync for Receiver<T> {}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct RecvError;
|
|
||||||
|
|
||||||
impl<T> Receiver<T> {
|
|
||||||
/// Attempts to wait for a value on this receiver,
|
|
||||||
/// returning an error if the corresponding channel has hung up.
|
|
||||||
pub fn recv(&self) -> Result<T, RecvError> {
|
|
||||||
let mut deque = self.inner.deque.lock();
|
|
||||||
while deque.is_empty() {
|
|
||||||
deque = self.inner.pushed.wait(deque);
|
|
||||||
}
|
|
||||||
Ok(deque.pop_front().unwrap())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The sending-half of Rust's asynchronous channel type.
|
|
||||||
/// This half can only be owned by one thread, but it can be cloned to send to other threads.
|
|
||||||
///
|
|
||||||
/// Messages can be sent through this channel with send.
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct Sender<T> {
|
|
||||||
inner: Weak<Channel<T>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<T: Send> Send for Sender<T> {}
|
|
||||||
|
|
||||||
impl<T> !Sync for Sender<T> {}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct SendError<T>(pub T);
|
|
||||||
|
|
||||||
impl<T> Sender<T> {
|
|
||||||
/// Attempts to send a value on this channel,
|
|
||||||
/// returning it back if it could not be sent.
|
|
||||||
pub fn send(&self, t: T) -> Result<(), SendError<T>> {
|
|
||||||
match self.inner.upgrade() {
|
|
||||||
None => Err(SendError(t)),
|
|
||||||
Some(inner) => {
|
|
||||||
let mut deque = inner.deque.lock();
|
|
||||||
deque.push_back(t);
|
|
||||||
inner.pushed.notify_one();
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new asynchronous channel, returning the sender/receiver halves.
|
|
||||||
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
|
|
||||||
let channel = Arc::new(Channel::<T>::default());
|
|
||||||
let sender = Sender {
|
|
||||||
inner: Arc::downgrade(&channel),
|
|
||||||
};
|
|
||||||
let receiver = Receiver { inner: channel };
|
|
||||||
(sender, receiver)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub mod test {
|
|
||||||
//! Copied from std::mpsc::test
|
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use crate::thread;
|
|
||||||
use alloc::boxed::Box;
|
|
||||||
|
|
||||||
fn smoke() {
|
|
||||||
let (tx, rx) = channel::<i32>();
|
|
||||||
tx.send(1).unwrap();
|
|
||||||
assert_eq!(rx.recv().unwrap(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn drop_full() {
|
|
||||||
let (tx, _rx) = channel::<Box<isize>>();
|
|
||||||
tx.send(Box::new(1)).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn drop_full_shared() {
|
|
||||||
let (tx, _rx) = channel::<Box<isize>>();
|
|
||||||
drop(tx.clone());
|
|
||||||
drop(tx.clone());
|
|
||||||
tx.send(Box::new(1)).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn smoke_shared() {
|
|
||||||
let (tx, rx) = channel::<i32>();
|
|
||||||
tx.send(1).unwrap();
|
|
||||||
assert_eq!(rx.recv().unwrap(), 1);
|
|
||||||
let tx = tx.clone();
|
|
||||||
tx.send(1).unwrap();
|
|
||||||
assert_eq!(rx.recv().unwrap(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn smoke_threads() {
|
|
||||||
let (tx, rx) = channel::<i32>();
|
|
||||||
let _t = thread::spawn(move || {
|
|
||||||
tx.send(1).unwrap();
|
|
||||||
});
|
|
||||||
assert_eq!(rx.recv().unwrap(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn smoke_port_gone() {
|
|
||||||
let (tx, rx) = channel::<i32>();
|
|
||||||
drop(rx);
|
|
||||||
assert!(tx.send(1).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn test_all() {
|
|
||||||
smoke();
|
|
||||||
drop_full();
|
|
||||||
drop_full_shared();
|
|
||||||
smoke_shared();
|
|
||||||
smoke_threads();
|
|
||||||
smoke_port_gone();
|
|
||||||
println!("mpsc test end");
|
|
||||||
}
|
|
||||||
}
|
|
2
rboot
2
rboot
@ -1 +1 @@
|
|||||||
Subproject commit 33a2d215957b704a26dab52484d75d47dbb49bdb
|
Subproject commit 048fa09b6b9614ceee52f8d7a8e4587ae3ca61e8
|
@ -1 +1 @@
|
|||||||
nightly-2020-03-23
|
nightly-2020-04-06
|
||||||
|
Loading…
Reference in New Issue
Block a user