Update rust
This commit is contained in:
parent
f9530fc348
commit
8c632d572f
|
@ -2,3 +2,6 @@
|
||||||
name = "compiler_builtins"
|
name = "compiler_builtins"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "../../rust/src/libcompiler_builtins/lib.rs"
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
#![no_std]
|
|
||||||
|
|
||||||
/// Memcpy
|
|
||||||
///
|
|
||||||
/// Copy N bytes of memory from one location to another.
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern fn memcpy(dest: *mut u8, src: *const u8,
|
|
||||||
n: usize) -> *mut u8 {
|
|
||||||
let mut i = 0;
|
|
||||||
while i < n {
|
|
||||||
*((dest as usize + i) as *mut u8) = *((src as usize + i) as *const u8);
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Memmove
|
|
||||||
///
|
|
||||||
/// Copy N bytes of memory from src to dest. The memory areas may overlap.
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern fn memmove(dest: *mut u8, src: *const u8,
|
|
||||||
n: usize) -> *mut u8 {
|
|
||||||
if src < dest as *const u8 {
|
|
||||||
let mut i = n;
|
|
||||||
while i != 0 {
|
|
||||||
i -= 1;
|
|
||||||
*((dest as usize + i) as *mut u8) = *((src as usize + i) as *const u8);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
let mut i = 0;
|
|
||||||
while i < n {
|
|
||||||
*((dest as usize + i) as *mut u8) = *((src as usize + i) as *const u8);
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dest
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Memset
|
|
||||||
///
|
|
||||||
/// Fill a block of memory with a specified value.
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern fn memset(dest: *mut u8, c: i32, n: usize) -> *mut u8 {
|
|
||||||
let mut i = 0;
|
|
||||||
while i < n {
|
|
||||||
*((dest as usize + i) as *mut u8) = c as u8;
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
dest
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Memcmp
|
|
||||||
///
|
|
||||||
/// Compare two blocks of memory.
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
|
|
||||||
let mut i = 0;
|
|
||||||
|
|
||||||
while i < n {
|
|
||||||
let a = *((s1 as usize + i) as *const u8);
|
|
||||||
let b = *((s2 as usize + i) as *const u8);
|
|
||||||
if a != b {
|
|
||||||
return a as i32 - b as i32
|
|
||||||
}
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
0
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![feature(asm)]
|
#![feature(asm)]
|
||||||
#![feature(const_fn)]
|
#![feature(const_fn)]
|
||||||
#![feature(naked_functions)]
|
|
||||||
#![feature(thread_local)]
|
#![feature(thread_local)]
|
||||||
|
|
||||||
#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute, cfg_target_vendor))]
|
#![cfg_attr(stdbuild, feature(no_std, core, core_slice_ext, staged_api, custom_attribute, cfg_target_vendor))]
|
||||||
|
@ -15,14 +14,11 @@
|
||||||
|
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
pub use funcs::*;
|
pub use funcs::*;
|
||||||
pub use start::*;
|
|
||||||
pub use syscall::*;
|
pub use syscall::*;
|
||||||
|
|
||||||
/// Basic types (not usually system specific)
|
/// Basic types (not usually system specific)
|
||||||
mod types;
|
mod types;
|
||||||
/// Basic functions (not system specific)
|
/// Basic functions (not system specific)
|
||||||
mod funcs;
|
mod funcs;
|
||||||
/// Start function and call in to libstd
|
|
||||||
mod start;
|
|
||||||
/// Conversion for syscall library (specific to Redox)
|
/// Conversion for syscall library (specific to Redox)
|
||||||
mod syscall;
|
mod syscall;
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
use super::exit;
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
#[naked]
|
|
||||||
#[cfg(target_arch = "x86")]
|
|
||||||
pub unsafe fn _start() {
|
|
||||||
asm!("push esp
|
|
||||||
call _start_stack
|
|
||||||
pop esp"
|
|
||||||
:
|
|
||||||
:
|
|
||||||
: "memory"
|
|
||||||
: "intel", "volatile");
|
|
||||||
let _ = exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
#[naked]
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
pub unsafe fn _start() {
|
|
||||||
asm!("mov rdi, rsp
|
|
||||||
and rsp, 0xFFFFFFFFFFFFFFF0
|
|
||||||
call _start_stack"
|
|
||||||
:
|
|
||||||
:
|
|
||||||
: "memory"
|
|
||||||
: "intel", "volatile");
|
|
||||||
let _ = exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub unsafe extern "C" fn _start_stack(stack: *const usize){
|
|
||||||
extern "C" {
|
|
||||||
fn main(argc: usize, argv: *const *const u8) -> usize;
|
|
||||||
}
|
|
||||||
|
|
||||||
let argc = *stack as usize;
|
|
||||||
let argv = stack.offset(1) as *const *const u8;
|
|
||||||
let _ = exit(main(argc, argv));
|
|
||||||
}
|
|
2
rust
2
rust
|
@ -1 +1 @@
|
||||||
Subproject commit 833b03ad52f1d5381d65ad866ab79cb9a68b0e7f
|
Subproject commit ffad2453768fe8756a91c2c6a19d1441a83b4b0a
|
Loading…
Reference in a new issue