update `memory` crate to 2018 edition

master
WangRunji 6 years ago
parent c4935a1477
commit 12457f10cb

@ -2,6 +2,7 @@
name = "ucore-memory"
version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018"
[dependencies]
log = "0.4"

@ -1,9 +1,8 @@
use core::ops::{Add, AddAssign};
use super::paging::*;
use super::memory_set::*;
pub type VirtAddr = usize;
pub type PhysAddr = usize;
pub const PAGE_SIZE: usize = 1 << 12;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
@ -80,13 +79,16 @@ impl Iterator for PageRange {
/// frame for the swapmanager
#[derive(Debug, Copy, Clone, PartialOrd, Ord)]
#[repr(C)]
pub struct Frame {
page_table: usize, // the raw pointer for the frame's memory set's inactive page table
virtaddr: VirtAddr, // the virtual addr for the frame
token: usize, // the token for frame
pub struct Frame {
/// the raw pointer for the frame's memory set's inactive page table
page_table: usize,
/// the virtual addr for the frame
virtaddr: VirtAddr,
/// the token for frame
token: usize,
}
impl Frame{
impl Frame {
pub fn get_page_table(&self) -> usize {
self.page_table
}
@ -95,11 +97,11 @@ impl Frame{
self.virtaddr
}
pub fn get_token(&self) -> usize{
pub fn get_token(&self) -> usize {
self.token
}
pub fn new(pt: usize, addr: VirtAddr, pttoken: usize) -> Self{
pub fn new(pt: usize, addr: VirtAddr, pttoken: usize) -> Self {
Frame {
page_table: pt,
virtaddr: addr,
@ -108,12 +110,10 @@ impl Frame{
}
}
impl PartialEq for Frame{
impl PartialEq for Frame {
fn eq(&self, other: &Frame) -> bool {
self.token == other.token && self.virtaddr == other.virtaddr
}
}
impl Eq for Frame{
}
impl Eq for Frame {}

@ -206,7 +206,6 @@ impl FrameRcMap {
pub mod test {
use super::*;
use alloc::boxed::Box;
#[test]
fn test() {

@ -1,15 +1,11 @@
#![no_std]
#![cfg_attr(not(test), no_std)]
#![feature(alloc)]
#![feature(nll)]
#![feature(extern_crate_item_prelude)]
// import macros from log
use log::*;
extern crate alloc;
#[macro_use]
extern crate log;
// To use `println!` in test
#[cfg(test)]
#[macro_use]
extern crate std;
pub mod paging;
pub mod cow;
@ -17,4 +13,4 @@ pub mod swap;
pub mod memory_set;
mod addr;
pub use addr::*;
pub use crate::addr::*;

@ -4,7 +4,7 @@
use alloc::vec::Vec;
use core::fmt::{Debug, Error, Formatter};
use super::*;
use paging::*;
use crate::paging::*;
/// an inactive page table
/// Note: InactivePageTable is not a PageTable

@ -2,7 +2,7 @@
use alloc::collections::VecDeque;
use super::*;
use paging::Entry;
use crate::paging::Entry;
#[derive(Default)]
pub struct EnhancedClockSwapManager {

@ -10,7 +10,6 @@ use super::*;
use super::paging::*;
use super::memory_set::InactivePageTable;
use super::addr::Frame;
use alloc::rc::Rc;
use core::ops::{Deref, DerefMut};
//pub use self::fifo::FifoSwapManager;

Loading…
Cancel
Save