Fix memmove, Spawn → SpawnProcess, more terminal options

This commit is contained in:
Mark Poliakov 2023-11-21 14:19:23 +02:00
parent a882ffa028
commit f00ecdb926
2 changed files with 8 additions and 22 deletions

View File

@ -1,10 +1,13 @@
//! Yggdrasil OS application runtime
#![feature(rustc_private)]
#![no_std]
#![deny(missing_docs)]
#![allow(nonstandard_style)]
use core::ffi::{c_char, c_void};
#[cfg(not(feature = "rustc-dep-of-std"))]
extern crate compiler_builtins;
extern crate yggdrasil_abi as abi;
pub use abi::error::Error;
@ -21,7 +24,8 @@ pub mod io {
pub use abi::io::{
DeviceRequest, DirectoryEntry, FileAttr, FileMode, FileType, MountOptions, OpenOptions,
RawFd, SeekFrom, UnmountOptions,
RawFd, SeekFrom, TerminalInputOptions, TerminalLineOptions, TerminalOptions,
TerminalOutputOptions, UnmountOptions,
};
}
@ -80,25 +84,7 @@ unsafe extern "C" fn memcpy(p0: *mut c_void, p1: *const c_void, len: usize) -> *
#[no_mangle]
unsafe extern "C" fn memmove(dst: *mut c_void, src: *const c_void, len: usize) -> *mut c_void {
if dst as usize == src as usize {
return dst;
}
if (src.add(len) as usize) <= (dst as usize) || (dst.add(len) as usize) <= (src as usize) {
return memcpy(dst, src, len);
}
if (dst as usize) < (src as usize) {
let a = src as usize - dst as usize;
memcpy(dst, src, a);
memcpy(src as *mut _, src.add(a), len - a);
} else {
let a = dst as usize - src as usize;
memcpy(dst.add(a), dst, len - a);
memcpy(dst, src, a);
}
dst
compiler_builtins::mem::memmove(dst as _, src as _, len) as _
}
#[no_mangle]

View File

@ -298,8 +298,8 @@ pub unsafe fn seek(fd: RawFd, pos: SeekFrom) -> Result<u64, Error> {
/// # Safety
///
/// Unsafe: direct system call.
pub unsafe fn spawn(options: &SpawnOptions<'_>) -> Result<u32, Error> {
u32::from_syscall_result(syscall!(SyscallFunction::Spawn, argp!(options as *const _)))
pub unsafe fn spawn_process(options: &SpawnOptions<'_>) -> Result<u32, Error> {
u32::from_syscall_result(syscall!(SyscallFunction::SpawnProcess, argp!(options as *const _)))
}
/// System call: wait for a process to finish