diff --git a/Cargo.lock b/Cargo.lock index f099a626ac..64d45f3c7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,7 +96,6 @@ dependencies = [ "goblin", "linked_list_allocator 0.9.1", "log", - "memoffset", "paste", "raw-cpuid", "redox_syscall", @@ -152,15 +151,6 @@ version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - [[package]] name = "paste" version = "1.0.9" diff --git a/Cargo.toml b/Cargo.toml index b2f4b5e9e0..90b8401fdb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,6 @@ bitflags = "1.2.1" bitfield = "0.13.2" linked_list_allocator = "0.9.0" log = "0.4" -memoffset = { version = "0.6", features = ["unstable_const"] } redox_syscall = { path = "syscall" } slab_allocator = { path = "slab_allocator", optional = true } # FIXME: There is some undefined behavior probably in the kernel, which forces us to use spin 0.9.0 and not 0.9.2. diff --git a/src/arch/x86/gdt.rs b/src/arch/x86/gdt.rs index d5c9304691..a1d20ef20f 100644 --- a/src/arch/x86/gdt.rs +++ b/src/arch/x86/gdt.rs @@ -90,7 +90,7 @@ pub struct TssWrapper(pub TaskStateSegment); pub unsafe fn pcr() -> *mut ProcessorControlRegion { let mut ret: *mut ProcessorControlRegion; - core::arch::asm!("mov {}, gs:[{}]", out(reg) ret, const(memoffset::offset_of!(ProcessorControlRegion, self_ref))); + core::arch::asm!("mov {}, gs:[{}]", out(reg) ret, const(core::mem::offset_of!(ProcessorControlRegion, self_ref))); ret } diff --git a/src/arch/x86/interrupt/syscall.rs b/src/arch/x86/interrupt/syscall.rs index 3773a9be04..0267647158 100644 --- a/src/arch/x86/interrupt/syscall.rs +++ b/src/arch/x86/interrupt/syscall.rs @@ -5,7 +5,7 @@ use crate::{ syscall, syscall::flag::{PTRACE_FLAG_IGNORE, PTRACE_STOP_PRE_SYSCALL, PTRACE_STOP_POST_SYSCALL}, }; -use memoffset::offset_of; +use core::mem::offset_of; use x86::{bits32::task::TaskStateSegment, msr, segmentation::SegmentSelector}; pub unsafe fn init() {} diff --git a/src/arch/x86_64/gdt.rs b/src/arch/x86_64/gdt.rs index fa056c72fe..19bb132db8 100644 --- a/src/arch/x86_64/gdt.rs +++ b/src/arch/x86_64/gdt.rs @@ -85,10 +85,10 @@ pub struct ProcessorControlRegion { } const _: () = { - if memoffset::offset_of!(ProcessorControlRegion, tss) % 16 != 0 { + if core::mem::offset_of!(ProcessorControlRegion, tss) % 16 != 0 { panic!("PCR is incorrectly defined, TSS alignment is too small"); } - if memoffset::offset_of!(ProcessorControlRegion, gdt) % 8 != 0 { + if core::mem::offset_of!(ProcessorControlRegion, gdt) % 8 != 0 { panic!("PCR is incorrectly defined, GDT alignment is too small"); } }; @@ -98,7 +98,7 @@ pub unsafe fn pcr() -> *mut ProcessorControlRegion { // obtaining FSBASE/GSBASE using mov gs:[gs_self_ref] is faster than using the (probably // microcoded) instructions. let mut ret: *mut ProcessorControlRegion; - core::arch::asm!("mov {}, gs:[{}]", out(reg) ret, const(memoffset::offset_of!(ProcessorControlRegion, self_ref))); + core::arch::asm!("mov {}, gs:[{}]", out(reg) ret, const(core::mem::offset_of!(ProcessorControlRegion, self_ref))); ret } diff --git a/src/arch/x86_64/interrupt/handler.rs b/src/arch/x86_64/interrupt/handler.rs index b7d4309211..b653395b3a 100644 --- a/src/arch/x86_64/interrupt/handler.rs +++ b/src/arch/x86_64/interrupt/handler.rs @@ -405,7 +405,7 @@ macro_rules! interrupt_stack { inner = sym inner, IA32_GS_BASE = const(x86::msr::IA32_GS_BASE), - PCR_GDT_OFFSET = const(memoffset::offset_of!(crate::gdt::ProcessorControlRegion, gdt)), + PCR_GDT_OFFSET = const(core::mem::offset_of!(crate::gdt::ProcessorControlRegion, gdt)), options(noreturn), diff --git a/src/arch/x86_64/interrupt/syscall.rs b/src/arch/x86_64/interrupt/syscall.rs index 32ecacb1af..5c2c1fb46e 100644 --- a/src/arch/x86_64/interrupt/syscall.rs +++ b/src/arch/x86_64/interrupt/syscall.rs @@ -5,7 +5,7 @@ use crate::{ syscall, syscall::flag::{PTRACE_FLAG_IGNORE, PTRACE_STOP_PRE_SYSCALL, PTRACE_STOP_POST_SYSCALL}, }; -use memoffset::offset_of; +use core::mem::offset_of; use x86::{bits64::{rflags::RFlags, task::TaskStateSegment}, msr, segmentation::SegmentSelector}; pub unsafe fn init() { diff --git a/src/context/arch/aarch64.rs b/src/context/arch/aarch64.rs index fb4727c44a..9f7fe6f70c 100644 --- a/src/context/arch/aarch64.rs +++ b/src/context/arch/aarch64.rs @@ -3,7 +3,7 @@ use core::arch::asm; use core::mem; use core::ptr; use core::sync::atomic::{AtomicBool, Ordering}; -use memoffset::offset_of; +use core::mem::offset_of; use spin::Once; use crate::{push_scratch, pop_scratch}; diff --git a/src/context/arch/x86.rs b/src/context/arch/x86.rs index b8593d3b6f..d5fd31a479 100644 --- a/src/context/arch/x86.rs +++ b/src/context/arch/x86.rs @@ -9,7 +9,7 @@ use crate::interrupt::handler::ScratchRegisters; use crate::paging::{RmmA, RmmArch, TableKind}; use crate::syscall::FloatRegisters; -use memoffset::offset_of; +use core::mem::offset_of; use spin::Once; /// This must be used by the kernel to ensure that context switches are done atomically diff --git a/src/context/arch/x86_64.rs b/src/context/arch/x86_64.rs index ca485c4c69..01e0e6b13f 100644 --- a/src/context/arch/x86_64.rs +++ b/src/context/arch/x86_64.rs @@ -9,7 +9,7 @@ use crate::interrupt::handler::ScratchRegisters; use crate::paging::{RmmA, RmmArch, TableKind}; use crate::syscall::FloatRegisters; -use memoffset::offset_of; +use core::mem::offset_of; use spin::Once; use x86::msr; diff --git a/src/main.rs b/src/main.rs index f2ffd9b542..1af39cb548 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,10 +44,10 @@ #![feature(allocator_api)] #![feature(asm_const)] // TODO: Relax requirements of most asm invocations -#![feature(const_refs_to_cell)] #![feature(int_roundings)] #![feature(let_chains)] #![feature(naked_functions)] +#![feature(offset_of)] #![feature(sync_unsafe_cell)] #![no_std] #![no_main] diff --git a/src/syscall/fs.rs b/src/syscall/fs.rs index 1d623a9bd6..0e0554e60c 100644 --- a/src/syscall/fs.rs +++ b/src/syscall/fs.rs @@ -348,7 +348,7 @@ pub fn fstat(fd: FileHandle, user_buf: UserSliceWo) -> Result<()> { // for retrieving the scheme ID from a file descriptor. // TODO: Less hacky method. let st_dev = scheme_id.get().try_into().map_err(|_| Error::new(EOVERFLOW))?; - user_buf.advance(memoffset::offset_of!(Stat, st_dev)).and_then(|b| b.limit(8)).ok_or(Error::new(EIO))?.copy_from_slice(&u64::to_ne_bytes(st_dev))?; + user_buf.advance(core::mem::offset_of!(Stat, st_dev)).and_then(|b| b.limit(8)).ok_or(Error::new(EIO))?.copy_from_slice(&u64::to_ne_bytes(st_dev))?; Ok(()) })