Verified Commit df993cc2 authored by jD91mZM2's avatar jD91mZM2

Switch to 2018 edition

parent 9e9f47d2
......@@ -6,6 +6,7 @@ license = "MIT"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
repository = "https://gitlab.redox-os.org/redox-os/syscall"
documentation = "https://docs.rs/redox_syscall"
edition = "2018"
[lib]
name = "syscall"
use core::{mem, ptr};
use core::ops::{Deref, DerefMut};
use Result;
use crate::Result;
struct PhysBox {
address: usize,
......@@ -10,7 +10,7 @@ struct PhysBox {
impl PhysBox {
fn new(size: usize) -> Result<PhysBox> {
let address = unsafe { ::physalloc(size)? };
let address = unsafe { crate::physalloc(size)? };
Ok(PhysBox {
address: address,
size: size
......@@ -20,7 +20,7 @@ impl PhysBox {
impl Drop for PhysBox {
fn drop(&mut self) {
let _ = unsafe { ::physfree(self.address, self.size) };
let _ = unsafe { crate::physfree(self.address, self.size) };
}
}
......@@ -32,7 +32,7 @@ pub struct Dma<T> {
impl<T> Dma<T> {
pub fn new(value: T) -> Result<Dma<T>> {
let phys = PhysBox::new(mem::size_of::<T>())?;
let virt = unsafe { ::physmap(phys.address, phys.size, ::PHYSMAP_WRITE)? } as *mut T;
let virt = unsafe { crate::physmap(phys.address, phys.size, crate::PHYSMAP_WRITE)? } as *mut T;
unsafe { ptr::write(virt, value); }
Ok(Dma {
phys: phys,
......@@ -42,7 +42,7 @@ impl<T> Dma<T> {
pub fn zeroed() -> Result<Dma<T>> {
let phys = PhysBox::new(mem::size_of::<T>())?;
let virt = unsafe { ::physmap(phys.address, phys.size, ::PHYSMAP_WRITE)? } as *mut T;
let virt = unsafe { crate::physmap(phys.address, phys.size, crate::PHYSMAP_WRITE)? } as *mut T;
unsafe { ptr::write_bytes(virt as *mut u8, 0, phys.size); }
Ok(Dma {
phys: phys,
......@@ -71,6 +71,6 @@ impl<T> DerefMut for Dma<T> {
impl<T> Drop for Dma<T> {
fn drop(&mut self) {
unsafe { drop(ptr::read(self.virt)); }
let _ = unsafe { ::physunmap(self.virt as usize) };
let _ = unsafe { crate::physunmap(self.virt as usize) };
}
}
use core::ptr::{read_volatile, write_volatile};
use core::mem::uninitialized;
use core::mem::MaybeUninit;
use core::ops::{BitAnd, BitOr, Not};
use super::io::Io;
#[repr(packed)]
pub struct Mmio<T> {
value: T,
value: MaybeUninit<T>,
}
impl<T> Mmio<T> {
/// Create a new Mmio without initializing
pub fn new() -> Self {
Mmio {
value: unsafe { uninitialized() }
value: MaybeUninit::uninit()
}
}
}
......@@ -22,10 +22,10 @@ impl<T> Io for Mmio<T> where T: Copy + PartialEq + BitAnd<Output = T> + BitOr<Ou
type Value = T;
fn read(&self) -> T {
unsafe { read_volatile(&self.value) }
unsafe { read_volatile(self.value.as_ptr()) }
}
fn write(&mut self, value: T) {
unsafe { write_volatile(&mut self.value, value) };
unsafe { write_volatile(self.value.as_mut_ptr(), value) };
}
}
#![feature(asm)]
#![feature(const_fn)]
#![feature(maybe_uninit)] // remove when Redox updates their rust version
#![cfg_attr(not(test), no_std)]
#[cfg(test)]
......
use core::{mem, slice};
use data::*;
use error::*;
use number::*;
use crate::data::*;
use crate::error::*;
use crate::number::*;
pub trait Scheme {
fn handle(&self, packet: &mut Packet) {
......
use core::{mem, slice};
use data::*;
use error::*;
use number::*;
use crate::data::*;
use crate::error::*;
use crate::number::*;
pub trait SchemeBlock {
fn handle(&self, packet: &Packet) -> Option<usize> {
......
use core::{mem, slice};
use data::*;
use error::*;
use number::*;
use crate::data::*;
use crate::error::*;
use crate::number::*;
pub trait SchemeBlockMut {
fn handle(&mut self, packet: &Packet) -> Option<usize> {
......
use core::{mem, slice};
use data::*;
use error::*;
use number::*;
use crate::data::*;
use crate::error::*;
use crate::number::*;
pub trait SchemeMut {
fn handle(&mut self, packet: &mut Packet) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment