Merge branch 'master' into 'master'
# Conflicts: # src/stdio/src/default.rs
This commit is contained in:
+12
-4
@@ -2,8 +2,9 @@
|
||||
|
||||
#![no_std]
|
||||
#![feature(asm)]
|
||||
#![feature(lang_items)]
|
||||
#![feature(linkage)]
|
||||
#![feature(naked_functions)]
|
||||
#![feature(panic_implementation)]
|
||||
|
||||
extern crate platform;
|
||||
|
||||
@@ -59,7 +60,14 @@ pub unsafe extern "C" fn _start_rust(sp: &'static Stack) -> ! {
|
||||
platform::exit(main(argc, argv));
|
||||
}
|
||||
|
||||
#[lang = "panic_fmt"]
|
||||
pub extern "C" fn rust_begin_unwind(_fmt: ::core::fmt::Arguments, _file: &str, _line: u32) -> ! {
|
||||
loop {}
|
||||
#[panic_implementation]
|
||||
#[linkage = "weak"]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
|
||||
use core::fmt::Write;
|
||||
|
||||
let mut w = platform::FileWriter(2);
|
||||
let _ = w.write_fmt(format_args!("RELIBC CRT0 PANIC: {}\n", pi));
|
||||
|
||||
platform::exit(1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
sys_includes = ["sys/types.h"]
|
||||
sys_includes = ["stdint.h", "sys/types.h"]
|
||||
include_guard = "_FENV_H"
|
||||
language = "C"
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "inttypes"
|
||||
version = "0.1.0"
|
||||
authors = ["jD91mZM2 <me@krake.one>"]
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
ctype = { path = "../ctype" }
|
||||
errno = { path = "../errno" }
|
||||
platform = { path = "../platform" }
|
||||
stdlib = { path = "../stdlib" }
|
||||
@@ -0,0 +1,11 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
fs::create_dir_all("../../target/include").expect("failed to create include directory");
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("failed to generate bindings")
|
||||
.write_to_file("../../target/include/inttypes.h");
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
sys_includes = ["stdint.h"]
|
||||
include_guard = "_INTTYPES_H"
|
||||
trailer = "#include <bits/inttypes.h>"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,74 @@
|
||||
#[macro_use] extern crate stdlib;
|
||||
extern crate ctype;
|
||||
extern crate errno;
|
||||
extern crate platform;
|
||||
|
||||
use errno::*;
|
||||
use platform::types::*;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn imaxabs(i: intmax_t) -> intmax_t {
|
||||
i.abs()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[repr(C)]
|
||||
pub struct intmaxdiv_t {
|
||||
quot: intmax_t,
|
||||
rem: intmax_t
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn imaxdiv(i: intmax_t, j: intmax_t) -> intmaxdiv_t {
|
||||
intmaxdiv_t {
|
||||
quot: i / j,
|
||||
rem: i % j
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtoimax(s: *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> intmax_t {
|
||||
use stdlib::*;
|
||||
strto_impl!(
|
||||
intmax_t,
|
||||
false,
|
||||
intmax_t::max_value(),
|
||||
intmax_t::min_value(),
|
||||
s,
|
||||
endptr,
|
||||
base
|
||||
)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtoumax(s: *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> uintmax_t {
|
||||
use stdlib::*;
|
||||
strto_impl!(
|
||||
uintmax_t,
|
||||
false,
|
||||
uintmax_t::max_value(),
|
||||
uintmax_t::min_value(),
|
||||
s,
|
||||
endptr,
|
||||
base
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstoimax(nptr: *const wchar_t, endptr: *mut *mut wchar_t,
|
||||
base: c_int) -> intmax_t {
|
||||
unimplemented!();
|
||||
}
|
||||
#[allow(unused)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstoumax(nptr: *const wchar_t, endptr: *mut *mut wchar_t,
|
||||
base: c_int) -> uintmax_t {
|
||||
unimplemented!();
|
||||
}
|
||||
+32
-8
@@ -1,7 +1,9 @@
|
||||
#![no_std]
|
||||
#![feature(lang_items)]
|
||||
#![feature(linkage)]
|
||||
#![feature(panic_implementation)]
|
||||
|
||||
extern crate compiler_builtins;
|
||||
//extern crate compiler_builtins;
|
||||
extern crate platform;
|
||||
|
||||
pub extern crate ctype;
|
||||
@@ -13,6 +15,8 @@ pub extern crate grp;
|
||||
pub extern crate locale;
|
||||
pub extern crate netinet;
|
||||
pub extern crate semaphore;
|
||||
pub extern crate setjmp;
|
||||
pub extern crate signal;
|
||||
pub extern crate stdio;
|
||||
pub extern crate stdlib;
|
||||
pub extern crate string;
|
||||
@@ -21,27 +25,47 @@ pub extern crate sys_resource;
|
||||
pub extern crate sys_socket;
|
||||
pub extern crate sys_stat;
|
||||
pub extern crate sys_time;
|
||||
pub extern crate sys_utsname;
|
||||
pub extern crate sys_wait;
|
||||
pub extern crate time;
|
||||
pub extern crate unistd;
|
||||
pub extern crate wctype;
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
#[cfg(not(test))]
|
||||
#[panic_implementation]
|
||||
#[linkage = "weak"]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[lang = "panic_fmt"]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn rust_begin_unwind(fmt: ::core::fmt::Arguments, file: &str, line: u32) -> ! {
|
||||
pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
|
||||
use core::fmt::Write;
|
||||
|
||||
let mut w = platform::FileWriter(2);
|
||||
let _ = w.write_fmt(format_args!("{}:{}: {}\n", file, line, fmt));
|
||||
let _ = w.write_fmt(format_args!("RELIBC PANIC: {}\n", pi));
|
||||
|
||||
platform::exit(1);
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[lang = "eh_personality"]
|
||||
#[no_mangle]
|
||||
#[linkage = "weak"]
|
||||
pub extern "C" fn rust_eh_personality() {}
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[lang = "oom"]
|
||||
#[linkage = "weak"]
|
||||
#[no_mangle]
|
||||
pub extern fn rust_oom(layout: ::core::alloc::Layout) -> ! {
|
||||
use core::fmt::Write;
|
||||
|
||||
let mut w = platform::FileWriter(2);
|
||||
let _ = w.write_fmt(format_args!("RELIBC OOM: {} bytes aligned to {} bytes\n", layout.size(), layout.align()));
|
||||
|
||||
platform::exit(1);
|
||||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
#[allow(non_snake_case)]
|
||||
#[linkage = "weak"]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _Unwind_Resume() -> ! {
|
||||
use core::fmt::Write;
|
||||
|
||||
@@ -8,3 +8,6 @@ sc = "0.2"
|
||||
|
||||
[target.'cfg(target_os = "redox")'.dependencies]
|
||||
redox_syscall = "0.1"
|
||||
|
||||
[dependencies]
|
||||
ralloc = { path = "../../ralloc" }
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#![no_std]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![feature(alloc)]
|
||||
#![feature(global_allocator)]
|
||||
//TODO #![feature(thread_local)]
|
||||
|
||||
#[cfg(all(not(feature = "no_std"), target_os = "linux"))]
|
||||
@@ -10,7 +12,7 @@ extern crate sc;
|
||||
|
||||
#[cfg(all(not(feature = "no_std"), target_os = "redox"))]
|
||||
#[macro_use]
|
||||
extern crate syscall;
|
||||
pub extern crate syscall;
|
||||
|
||||
pub use sys::*;
|
||||
|
||||
@@ -22,12 +24,17 @@ mod sys;
|
||||
#[path = "redox/mod.rs"]
|
||||
mod sys;
|
||||
|
||||
extern crate alloc;
|
||||
extern crate ralloc;
|
||||
|
||||
pub mod types;
|
||||
|
||||
use core::fmt;
|
||||
|
||||
use types::*;
|
||||
|
||||
#[global_allocator]
|
||||
static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
|
||||
//TODO #[thread_local]
|
||||
#[allow(non_upper_case_globals)]
|
||||
#[no_mangle]
|
||||
|
||||
@@ -54,6 +54,10 @@ pub fn dup2(fildes: c_int, fildes2: c_int) -> c_int {
|
||||
e(unsafe { syscall!(DUP3, fildes, fildes2, 0) }) as c_int
|
||||
}
|
||||
|
||||
pub fn execve(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int {
|
||||
e(unsafe { syscall!(EXECVE, path, argv, envp) }) as c_int
|
||||
}
|
||||
|
||||
pub fn exit(status: c_int) -> ! {
|
||||
unsafe {
|
||||
syscall!(EXIT, status);
|
||||
@@ -198,6 +202,10 @@ pub fn stat(file: *const c_char, buf: *mut stat) -> c_int {
|
||||
e(unsafe { syscall!(NEWFSTATAT, AT_FDCWD, file, buf, 0) }) as c_int
|
||||
}
|
||||
|
||||
pub fn uname(utsname: usize) -> c_int {
|
||||
e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
|
||||
}
|
||||
|
||||
pub fn unlink(path: *const c_char) -> c_int {
|
||||
e(unsafe { syscall!(UNLINKAT, AT_FDCWD, path, 0) }) as c_int
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use core::ptr;
|
||||
use core::slice;
|
||||
use core::mem;
|
||||
use alloc::Vec;
|
||||
use syscall;
|
||||
use syscall::flag::*;
|
||||
use syscall::data::TimeSpec as redox_timespec;
|
||||
@@ -66,6 +68,58 @@ pub fn dup2(fd1: c_int, fd2: c_int) -> c_int {
|
||||
e(syscall::dup2(fd1 as usize, fd2 as usize, &[])) as c_int
|
||||
}
|
||||
|
||||
pub fn execve(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int {
|
||||
unsafe {
|
||||
let mut env = envp;
|
||||
while !(*env).is_null() {
|
||||
let slice = c_str(*env);
|
||||
// Should always contain a =, but worth checking
|
||||
if let Some(sep) = slice.iter().position(|&c| c == b'=') {
|
||||
// If the environment variable has no name, do not attempt
|
||||
// to add it to the env.
|
||||
if sep > 0 {
|
||||
let mut path = b"env:".to_vec();
|
||||
path.extend_from_slice(&slice[..sep]);
|
||||
match syscall::open(&path, O_WRONLY | O_CREAT) {
|
||||
Ok(fd) => {
|
||||
// If the environment variable has no value, there
|
||||
// is no need to write anything to the env scheme.
|
||||
if sep + 1 < slice.len() {
|
||||
let n = match syscall::write(fd, &slice[sep + 1..]) {
|
||||
Ok(n) => n,
|
||||
err => {
|
||||
return e(err) as c_int;
|
||||
}
|
||||
};
|
||||
}
|
||||
// Cleanup after adding the variable.
|
||||
match syscall::close(fd) {
|
||||
Ok(_) => (),
|
||||
err => {
|
||||
return e(err) as c_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
err => {
|
||||
return e(err) as c_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
env = env.offset(1);
|
||||
}
|
||||
|
||||
let mut args: Vec<[usize; 2]> = Vec::new();
|
||||
let mut arg = argv;
|
||||
while !(*arg).is_null() {
|
||||
args.push([*arg as usize, c_str(*arg).len()]);
|
||||
arg = arg.offset(1);
|
||||
}
|
||||
|
||||
e(syscall::execve(c_str(path), &args)) as c_int
|
||||
}
|
||||
}
|
||||
|
||||
pub fn exit(status: c_int) -> ! {
|
||||
let _ = syscall::exit(status as usize);
|
||||
loop {}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
[package]
|
||||
name = "setjmp"
|
||||
version = "0.1.0"
|
||||
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
|
||||
@@ -0,0 +1,6 @@
|
||||
# setjmp implementation
|
||||
|
||||
All this code belongs to [musl libc](https://www.musl-libc.org/).
|
||||
They own it. All rights go to them.
|
||||
Huge thanks to them for doing this tedious per-arch assembly work!
|
||||
We will reuse this awesome effort :)
|
||||
@@ -0,0 +1,24 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,%function
|
||||
.type longjmp,%function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
// IHI0055B_aapcs64.pdf 5.1.1, 5.1.2 callee saved registers
|
||||
ldp x19, x20, [x0,#0]
|
||||
ldp x21, x22, [x0,#16]
|
||||
ldp x23, x24, [x0,#32]
|
||||
ldp x25, x26, [x0,#48]
|
||||
ldp x27, x28, [x0,#64]
|
||||
ldp x29, x30, [x0,#80]
|
||||
ldr x2, [x0,#104]
|
||||
mov sp, x2
|
||||
ldp d8 , d9, [x0,#112]
|
||||
ldp d10, d11, [x0,#128]
|
||||
ldp d12, d13, [x0,#144]
|
||||
ldp d14, d15, [x0,#160]
|
||||
|
||||
mov x0, x1
|
||||
cbnz x1, 1f
|
||||
mov x0, #1
|
||||
1: br x30
|
||||
@@ -0,0 +1,24 @@
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
// IHI0055B_aapcs64.pdf 5.1.1, 5.1.2 callee saved registers
|
||||
stp x19, x20, [x0,#0]
|
||||
stp x21, x22, [x0,#16]
|
||||
stp x23, x24, [x0,#32]
|
||||
stp x25, x26, [x0,#48]
|
||||
stp x27, x28, [x0,#64]
|
||||
stp x29, x30, [x0,#80]
|
||||
mov x2, sp
|
||||
str x2, [x0,#104]
|
||||
stp d8, d9, [x0,#112]
|
||||
stp d10, d11, [x0,#128]
|
||||
stp d12, d13, [x0,#144]
|
||||
stp d14, d15, [x0,#160]
|
||||
mov x0, #0
|
||||
ret
|
||||
@@ -0,0 +1,43 @@
|
||||
.syntax unified
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,%function
|
||||
.type longjmp,%function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
mov ip,r0
|
||||
movs r0,r1
|
||||
moveq r0,#1
|
||||
ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
|
||||
ldmia ip!, {r2,lr}
|
||||
mov sp,r2
|
||||
|
||||
adr r1,1f
|
||||
ldr r2,1f
|
||||
ldr r1,[r1,r2]
|
||||
|
||||
tst r1,#0x260
|
||||
beq 3f
|
||||
tst r1,#0x20
|
||||
beq 2f
|
||||
ldc p2, cr4, [ip], #48
|
||||
2: tst r1,#0x40
|
||||
beq 2f
|
||||
.fpu vfp
|
||||
vldmia ip!, {d8-d15}
|
||||
.fpu softvfp
|
||||
.eabi_attribute 10, 0
|
||||
.eabi_attribute 27, 0
|
||||
2: tst r1,#0x200
|
||||
beq 3f
|
||||
ldcl p1, cr10, [ip], #8
|
||||
ldcl p1, cr11, [ip], #8
|
||||
ldcl p1, cr12, [ip], #8
|
||||
ldcl p1, cr13, [ip], #8
|
||||
ldcl p1, cr14, [ip], #8
|
||||
ldcl p1, cr15, [ip], #8
|
||||
3: bx lr
|
||||
|
||||
.hidden __hwcap
|
||||
.align 2
|
||||
1: .word __hwcap-1b
|
||||
@@ -0,0 +1,45 @@
|
||||
.syntax unified
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,%function
|
||||
.type _setjmp,%function
|
||||
.type setjmp,%function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
mov ip,r0
|
||||
stmia ip!,{v1,v2,v3,v4,v5,v6,sl,fp}
|
||||
mov r2,sp
|
||||
stmia ip!,{r2,lr}
|
||||
mov r0,#0
|
||||
|
||||
adr r1,1f
|
||||
ldr r2,1f
|
||||
ldr r1,[r1,r2]
|
||||
|
||||
tst r1,#0x260
|
||||
beq 3f
|
||||
tst r1,#0x20
|
||||
beq 2f
|
||||
stc p2, cr4, [ip], #48
|
||||
2: tst r1,#0x40
|
||||
beq 2f
|
||||
.fpu vfp
|
||||
vstmia ip!, {d8-d15}
|
||||
.fpu softvfp
|
||||
.eabi_attribute 10, 0
|
||||
.eabi_attribute 27, 0
|
||||
2: tst r1,#0x200
|
||||
beq 3f
|
||||
stcl p1, cr10, [ip], #8
|
||||
stcl p1, cr11, [ip], #8
|
||||
stcl p1, cr12, [ip], #8
|
||||
stcl p1, cr13, [ip], #8
|
||||
stcl p1, cr14, [ip], #8
|
||||
stcl p1, cr15, [ip], #8
|
||||
3: bx lr
|
||||
|
||||
.hidden __hwcap
|
||||
.align 2
|
||||
1: .word __hwcap-1b
|
||||
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
@@ -0,0 +1,20 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
mov 4(%esp),%edx
|
||||
mov 8(%esp),%eax
|
||||
test %eax,%eax
|
||||
jnz 1f
|
||||
inc %eax
|
||||
1:
|
||||
mov (%edx),%ebx
|
||||
mov 4(%edx),%esi
|
||||
mov 8(%edx),%edi
|
||||
mov 12(%edx),%ebp
|
||||
mov 16(%edx),%ecx
|
||||
mov %ecx,%esp
|
||||
mov 20(%edx),%ecx
|
||||
jmp *%ecx
|
||||
@@ -0,0 +1,23 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
mov 4(%esp), %eax
|
||||
mov %ebx, (%eax)
|
||||
mov %esi, 4(%eax)
|
||||
mov %edi, 8(%eax)
|
||||
mov %ebp, 12(%eax)
|
||||
lea 4(%esp), %ecx
|
||||
mov %ecx, 16(%eax)
|
||||
mov (%esp), %ecx
|
||||
mov %ecx, 20(%eax)
|
||||
xor %eax, %eax
|
||||
ret
|
||||
@@ -0,0 +1,14 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
movea.l 4(%sp),%a0
|
||||
move.l 8(%sp),%d0
|
||||
bne 1f
|
||||
move.l #1,%d0
|
||||
1: movem.l (%a0),%d2-%d7/%a2-%a7
|
||||
fmovem.x 52(%a0),%fp2-%fp7
|
||||
move.l 48(%a0),(%sp)
|
||||
rts
|
||||
@@ -0,0 +1,18 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
movea.l 4(%sp),%a0
|
||||
movem.l %d2-%d7/%a2-%a7,(%a0)
|
||||
move.l (%sp),48(%a0)
|
||||
fmovem.x %fp2-%fp7,52(%a0)
|
||||
clr.l %d0
|
||||
rts
|
||||
@@ -0,0 +1,29 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
addi r3, r6, 0
|
||||
bnei r3, 1f
|
||||
addi r3, r3, 1
|
||||
1: lwi r1, r5, 0
|
||||
lwi r15, r5, 4
|
||||
lwi r2, r5, 8
|
||||
lwi r13, r5, 12
|
||||
lwi r18, r5, 16
|
||||
lwi r19, r5, 20
|
||||
lwi r20, r5, 24
|
||||
lwi r21, r5, 28
|
||||
lwi r22, r5, 32
|
||||
lwi r23, r5, 36
|
||||
lwi r24, r5, 40
|
||||
lwi r25, r5, 44
|
||||
lwi r26, r5, 48
|
||||
lwi r27, r5, 52
|
||||
lwi r28, r5, 56
|
||||
lwi r29, r5, 60
|
||||
lwi r30, r5, 64
|
||||
lwi r31, r5, 68
|
||||
rtsd r15, 8
|
||||
nop
|
||||
@@ -0,0 +1,32 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
swi r1, r5, 0
|
||||
swi r15, r5, 4
|
||||
swi r2, r5, 8
|
||||
swi r13, r5, 12
|
||||
swi r18, r5, 16
|
||||
swi r19, r5, 20
|
||||
swi r20, r5, 24
|
||||
swi r21, r5, 28
|
||||
swi r22, r5, 32
|
||||
swi r23, r5, 36
|
||||
swi r24, r5, 40
|
||||
swi r25, r5, 44
|
||||
swi r26, r5, 48
|
||||
swi r27, r5, 52
|
||||
swi r28, r5, 56
|
||||
swi r29, r5, 60
|
||||
swi r30, r5, 64
|
||||
swi r31, r5, 68
|
||||
rtsd r15, 8
|
||||
ori r3, r0, 0
|
||||
@@ -0,0 +1,40 @@
|
||||
.set noreorder
|
||||
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
move $2, $5
|
||||
bne $2, $0, 1f
|
||||
nop
|
||||
addu $2, $2, 1
|
||||
1:
|
||||
#ifndef __mips_soft_float
|
||||
lwc1 $20, 56($4)
|
||||
lwc1 $21, 60($4)
|
||||
lwc1 $22, 64($4)
|
||||
lwc1 $23, 68($4)
|
||||
lwc1 $24, 72($4)
|
||||
lwc1 $25, 76($4)
|
||||
lwc1 $26, 80($4)
|
||||
lwc1 $27, 84($4)
|
||||
lwc1 $28, 88($4)
|
||||
lwc1 $29, 92($4)
|
||||
lwc1 $30, 96($4)
|
||||
lwc1 $31, 100($4)
|
||||
#endif
|
||||
lw $ra, 0($4)
|
||||
lw $sp, 4($4)
|
||||
lw $16, 8($4)
|
||||
lw $17, 12($4)
|
||||
lw $18, 16($4)
|
||||
lw $19, 20($4)
|
||||
lw $20, 24($4)
|
||||
lw $21, 28($4)
|
||||
lw $22, 32($4)
|
||||
lw $23, 36($4)
|
||||
lw $30, 40($4)
|
||||
jr $ra
|
||||
lw $28, 44($4)
|
||||
@@ -0,0 +1,39 @@
|
||||
.set noreorder
|
||||
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
sw $ra, 0($4)
|
||||
sw $sp, 4($4)
|
||||
sw $16, 8($4)
|
||||
sw $17, 12($4)
|
||||
sw $18, 16($4)
|
||||
sw $19, 20($4)
|
||||
sw $20, 24($4)
|
||||
sw $21, 28($4)
|
||||
sw $22, 32($4)
|
||||
sw $23, 36($4)
|
||||
sw $30, 40($4)
|
||||
sw $28, 44($4)
|
||||
#ifndef __mips_soft_float
|
||||
swc1 $20, 56($4)
|
||||
swc1 $21, 60($4)
|
||||
swc1 $22, 64($4)
|
||||
swc1 $23, 68($4)
|
||||
swc1 $24, 72($4)
|
||||
swc1 $25, 76($4)
|
||||
swc1 $26, 80($4)
|
||||
swc1 $27, 84($4)
|
||||
swc1 $28, 88($4)
|
||||
swc1 $29, 92($4)
|
||||
swc1 $30, 96($4)
|
||||
swc1 $31, 100($4)
|
||||
#endif
|
||||
jr $ra
|
||||
li $2, 0
|
||||
@@ -0,0 +1,37 @@
|
||||
.set noreorder
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
move $2, $5
|
||||
|
||||
bne $2, $0, 1f
|
||||
nop
|
||||
daddu $2, $2, 1
|
||||
1:
|
||||
#ifndef __mips_soft_float
|
||||
ldc1 $24, 96($4)
|
||||
ldc1 $25, 104($4)
|
||||
ldc1 $26, 112($4)
|
||||
ldc1 $27, 120($4)
|
||||
ldc1 $28, 128($4)
|
||||
ldc1 $29, 136($4)
|
||||
ldc1 $30, 144($4)
|
||||
ldc1 $31, 152($4)
|
||||
#endif
|
||||
ld $ra, 0($4)
|
||||
ld $sp, 8($4)
|
||||
ld $gp, 16($4)
|
||||
ld $16, 24($4)
|
||||
ld $17, 32($4)
|
||||
ld $18, 40($4)
|
||||
ld $19, 48($4)
|
||||
ld $20, 56($4)
|
||||
ld $21, 64($4)
|
||||
ld $22, 72($4)
|
||||
ld $23, 80($4)
|
||||
ld $30, 88($4)
|
||||
jr $ra
|
||||
nop
|
||||
@@ -0,0 +1,34 @@
|
||||
.set noreorder
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
sd $ra, 0($4)
|
||||
sd $sp, 8($4)
|
||||
sd $gp, 16($4)
|
||||
sd $16, 24($4)
|
||||
sd $17, 32($4)
|
||||
sd $18, 40($4)
|
||||
sd $19, 48($4)
|
||||
sd $20, 56($4)
|
||||
sd $21, 64($4)
|
||||
sd $22, 72($4)
|
||||
sd $23, 80($4)
|
||||
sd $30, 88($4)
|
||||
#ifndef __mips_soft_float
|
||||
sdc1 $24, 96($4)
|
||||
sdc1 $25, 104($4)
|
||||
sdc1 $26, 112($4)
|
||||
sdc1 $27, 120($4)
|
||||
sdc1 $28, 128($4)
|
||||
sdc1 $29, 136($4)
|
||||
sdc1 $30, 144($4)
|
||||
sdc1 $31, 152($4)
|
||||
#endif
|
||||
jr $ra
|
||||
li $2, 0
|
||||
@@ -0,0 +1,36 @@
|
||||
.set noreorder
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
move $2, $5
|
||||
bne $2, $0, 1f
|
||||
nop
|
||||
addu $2, $2, 1
|
||||
1:
|
||||
#ifndef __mips_soft_float
|
||||
ldc1 $24, 96($4)
|
||||
ldc1 $25, 104($4)
|
||||
ldc1 $26, 112($4)
|
||||
ldc1 $27, 120($4)
|
||||
ldc1 $28, 128($4)
|
||||
ldc1 $29, 136($4)
|
||||
ldc1 $30, 144($4)
|
||||
ldc1 $31, 152($4)
|
||||
#endif
|
||||
ld $ra, 0($4)
|
||||
ld $sp, 8($4)
|
||||
ld $gp, 16($4)
|
||||
ld $16, 24($4)
|
||||
ld $17, 32($4)
|
||||
ld $18, 40($4)
|
||||
ld $19, 48($4)
|
||||
ld $20, 56($4)
|
||||
ld $21, 64($4)
|
||||
ld $22, 72($4)
|
||||
ld $23, 80($4)
|
||||
ld $30, 88($4)
|
||||
jr $ra
|
||||
nop
|
||||
@@ -0,0 +1,34 @@
|
||||
.set noreorder
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
sd $ra, 0($4)
|
||||
sd $sp, 8($4)
|
||||
sd $gp, 16($4)
|
||||
sd $16, 24($4)
|
||||
sd $17, 32($4)
|
||||
sd $18, 40($4)
|
||||
sd $19, 48($4)
|
||||
sd $20, 56($4)
|
||||
sd $21, 64($4)
|
||||
sd $22, 72($4)
|
||||
sd $23, 80($4)
|
||||
sd $30, 88($4)
|
||||
#ifndef __mips_soft_float
|
||||
sdc1 $24, 96($4)
|
||||
sdc1 $25, 104($4)
|
||||
sdc1 $26, 112($4)
|
||||
sdc1 $27, 120($4)
|
||||
sdc1 $28, 128($4)
|
||||
sdc1 $29, 136($4)
|
||||
sdc1 $30, 144($4)
|
||||
sdc1 $31, 152($4)
|
||||
#endif
|
||||
jr $ra
|
||||
li $2, 0
|
||||
@@ -0,0 +1,25 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
l.sfeqi r4, 0
|
||||
l.bnf 1f
|
||||
l.addi r11, r4,0
|
||||
l.ori r11, r0, 1
|
||||
1: l.lwz r1, 0(r3)
|
||||
l.lwz r2, 4(r3)
|
||||
l.lwz r9, 8(r3)
|
||||
l.lwz r10, 12(r3)
|
||||
l.lwz r14, 16(r3)
|
||||
l.lwz r16, 20(r3)
|
||||
l.lwz r18, 24(r3)
|
||||
l.lwz r20, 28(r3)
|
||||
l.lwz r22, 32(r3)
|
||||
l.lwz r24, 36(r3)
|
||||
l.lwz r26, 40(r3)
|
||||
l.lwz r28, 44(r3)
|
||||
l.lwz r30, 48(r3)
|
||||
l.jr r9
|
||||
l.nop
|
||||
@@ -0,0 +1,27 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
l.sw 0(r3), r1
|
||||
l.sw 4(r3), r2
|
||||
l.sw 8(r3), r9
|
||||
l.sw 12(r3), r10
|
||||
l.sw 16(r3), r14
|
||||
l.sw 20(r3), r16
|
||||
l.sw 24(r3), r18
|
||||
l.sw 28(r3), r20
|
||||
l.sw 32(r3), r22
|
||||
l.sw 36(r3), r24
|
||||
l.sw 40(r3), r26
|
||||
l.sw 44(r3), r28
|
||||
l.sw 48(r3), r30
|
||||
l.jr r9
|
||||
l.ori r11,r0,0
|
||||
@@ -0,0 +1,69 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
/*
|
||||
* void longjmp(jmp_buf env, int val);
|
||||
* put val into return register and restore the env saved in setjmp
|
||||
* if val(r4) is 0, put 1 there.
|
||||
*/
|
||||
/* 0) move old return address into r0 */
|
||||
lwz 0, 0(3)
|
||||
/* 1) put it into link reg */
|
||||
mtlr 0
|
||||
/* 2 ) restore stack ptr */
|
||||
lwz 1, 4(3)
|
||||
/* 3) restore control reg */
|
||||
lwz 0, 8(3)
|
||||
mtcr 0
|
||||
/* 4) restore r14-r31 */
|
||||
lwz 14, 12(3)
|
||||
lwz 15, 16(3)
|
||||
lwz 16, 20(3)
|
||||
lwz 17, 24(3)
|
||||
lwz 18, 28(3)
|
||||
lwz 19, 32(3)
|
||||
lwz 20, 36(3)
|
||||
lwz 21, 40(3)
|
||||
lwz 22, 44(3)
|
||||
lwz 23, 48(3)
|
||||
lwz 24, 52(3)
|
||||
lwz 25, 56(3)
|
||||
lwz 26, 60(3)
|
||||
lwz 27, 64(3)
|
||||
lwz 28, 68(3)
|
||||
lwz 29, 72(3)
|
||||
lwz 30, 76(3)
|
||||
lwz 31, 80(3)
|
||||
#ifndef _SOFT_FLOAT
|
||||
lfd 14,88(3)
|
||||
lfd 15,96(3)
|
||||
lfd 16,104(3)
|
||||
lfd 17,112(3)
|
||||
lfd 18,120(3)
|
||||
lfd 19,128(3)
|
||||
lfd 20,136(3)
|
||||
lfd 21,144(3)
|
||||
lfd 22,152(3)
|
||||
lfd 23,160(3)
|
||||
lfd 24,168(3)
|
||||
lfd 25,176(3)
|
||||
lfd 26,184(3)
|
||||
lfd 27,192(3)
|
||||
lfd 28,200(3)
|
||||
lfd 29,208(3)
|
||||
lfd 30,216(3)
|
||||
lfd 31,224(3)
|
||||
#endif
|
||||
/* 5) put val into return reg r3 */
|
||||
mr 3, 4
|
||||
|
||||
/* 6) check if return value is 0, make it 1 in that case */
|
||||
cmpwi cr7, 4, 0
|
||||
bne cr7, 1f
|
||||
li 3, 1
|
||||
1:
|
||||
blr
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
/* 0) store IP int 0, then into the jmpbuf pointed to by r3 (first arg) */
|
||||
mflr 0
|
||||
stw 0, 0(3)
|
||||
/* 1) store reg1 (SP) */
|
||||
stw 1, 4(3)
|
||||
/* 2) store cr */
|
||||
mfcr 0
|
||||
stw 0, 8(3)
|
||||
/* 3) store r14-31 */
|
||||
stw 14, 12(3)
|
||||
stw 15, 16(3)
|
||||
stw 16, 20(3)
|
||||
stw 17, 24(3)
|
||||
stw 18, 28(3)
|
||||
stw 19, 32(3)
|
||||
stw 20, 36(3)
|
||||
stw 21, 40(3)
|
||||
stw 22, 44(3)
|
||||
stw 23, 48(3)
|
||||
stw 24, 52(3)
|
||||
stw 25, 56(3)
|
||||
stw 26, 60(3)
|
||||
stw 27, 64(3)
|
||||
stw 28, 68(3)
|
||||
stw 29, 72(3)
|
||||
stw 30, 76(3)
|
||||
stw 31, 80(3)
|
||||
#ifndef _SOFT_FLOAT
|
||||
stfd 14,88(3)
|
||||
stfd 15,96(3)
|
||||
stfd 16,104(3)
|
||||
stfd 17,112(3)
|
||||
stfd 18,120(3)
|
||||
stfd 19,128(3)
|
||||
stfd 20,136(3)
|
||||
stfd 21,144(3)
|
||||
stfd 22,152(3)
|
||||
stfd 23,160(3)
|
||||
stfd 24,168(3)
|
||||
stfd 25,176(3)
|
||||
stfd 26,184(3)
|
||||
stfd 27,192(3)
|
||||
stfd 28,200(3)
|
||||
stfd 29,208(3)
|
||||
stfd 30,216(3)
|
||||
stfd 31,224(3)
|
||||
#endif
|
||||
/* 4) set return value to 0 */
|
||||
li 3, 0
|
||||
/* 5) return */
|
||||
blr
|
||||
@@ -0,0 +1,81 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
# 0) move old return address into the link register
|
||||
ld 0, 0*8(3)
|
||||
mtlr 0
|
||||
# 1) restore cr
|
||||
ld 0, 1*8(3)
|
||||
mtcr 0
|
||||
# 2) restore SP
|
||||
ld 1, 2*8(3)
|
||||
# 3) restore TOC into both r2 and the caller's stack.
|
||||
# Which location is required depends on whether setjmp was called
|
||||
# locally or non-locally, but it's always safe to restore to both.
|
||||
ld 2, 3*8(3)
|
||||
std 2, 24(1)
|
||||
# 4) restore r14-r31
|
||||
ld 14, 4*8(3)
|
||||
ld 15, 5*8(3)
|
||||
ld 16, 6*8(3)
|
||||
ld 17, 7*8(3)
|
||||
ld 18, 8*8(3)
|
||||
ld 19, 9*8(3)
|
||||
ld 20, 10*8(3)
|
||||
ld 21, 11*8(3)
|
||||
ld 22, 12*8(3)
|
||||
ld 23, 13*8(3)
|
||||
ld 24, 14*8(3)
|
||||
ld 25, 15*8(3)
|
||||
ld 26, 16*8(3)
|
||||
ld 27, 17*8(3)
|
||||
ld 28, 18*8(3)
|
||||
ld 29, 19*8(3)
|
||||
ld 30, 20*8(3)
|
||||
ld 31, 21*8(3)
|
||||
# 5) restore floating point registers f14-f31
|
||||
lfd 14, 22*8(3)
|
||||
lfd 15, 23*8(3)
|
||||
lfd 16, 24*8(3)
|
||||
lfd 17, 25*8(3)
|
||||
lfd 18, 26*8(3)
|
||||
lfd 19, 27*8(3)
|
||||
lfd 20, 28*8(3)
|
||||
lfd 21, 29*8(3)
|
||||
lfd 22, 30*8(3)
|
||||
lfd 23, 31*8(3)
|
||||
lfd 24, 32*8(3)
|
||||
lfd 25, 33*8(3)
|
||||
lfd 26, 34*8(3)
|
||||
lfd 27, 35*8(3)
|
||||
lfd 28, 36*8(3)
|
||||
lfd 29, 37*8(3)
|
||||
lfd 30, 38*8(3)
|
||||
lfd 31, 39*8(3)
|
||||
|
||||
# 6) restore vector registers v20-v31
|
||||
addi 3, 3, 40*8
|
||||
lvx 20, 0, 3 ; addi 3, 3, 16
|
||||
lvx 21, 0, 3 ; addi 3, 3, 16
|
||||
lvx 22, 0, 3 ; addi 3, 3, 16
|
||||
lvx 23, 0, 3 ; addi 3, 3, 16
|
||||
lvx 24, 0, 3 ; addi 3, 3, 16
|
||||
lvx 25, 0, 3 ; addi 3, 3, 16
|
||||
lvx 26, 0, 3 ; addi 3, 3, 16
|
||||
lvx 27, 0, 3 ; addi 3, 3, 16
|
||||
lvx 28, 0, 3 ; addi 3, 3, 16
|
||||
lvx 29, 0, 3 ; addi 3, 3, 16
|
||||
lvx 30, 0, 3 ; addi 3, 3, 16
|
||||
lvx 31, 0, 3
|
||||
|
||||
# 7) return r4 ? r4 : 1
|
||||
mr 3, 4
|
||||
cmpwi cr7, 4, 0
|
||||
bne cr7, 1f
|
||||
li 3, 1
|
||||
1:
|
||||
blr
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
ld 5, 24(1) # load from the TOC slot in the caller's stack frame
|
||||
b __setjmp_toc
|
||||
|
||||
.localentry __setjmp,.-__setjmp
|
||||
.localentry _setjmp,.-_setjmp
|
||||
.localentry setjmp,.-setjmp
|
||||
mr 5, 2
|
||||
|
||||
.global __setjmp_toc
|
||||
.hidden __setjmp_toc
|
||||
# same as normal setjmp, except TOC pointer to save is provided in r5.
|
||||
# r4 would normally be the 2nd parameter, but we're using r5 to simplify calling from sigsetjmp.
|
||||
# solves the problem of knowing whether to save the TOC pointer from r2 or the caller's stack frame.
|
||||
__setjmp_toc:
|
||||
# 0) store IP into 0, then into the jmpbuf pointed to by r3 (first arg)
|
||||
mflr 0
|
||||
std 0, 0*8(3)
|
||||
# 1) store cr
|
||||
mfcr 0
|
||||
std 0, 1*8(3)
|
||||
# 2) store SP and TOC
|
||||
std 1, 2*8(3)
|
||||
std 5, 3*8(3)
|
||||
# 3) store r14-31
|
||||
std 14, 4*8(3)
|
||||
std 15, 5*8(3)
|
||||
std 16, 6*8(3)
|
||||
std 17, 7*8(3)
|
||||
std 18, 8*8(3)
|
||||
std 19, 9*8(3)
|
||||
std 20, 10*8(3)
|
||||
std 21, 11*8(3)
|
||||
std 22, 12*8(3)
|
||||
std 23, 13*8(3)
|
||||
std 24, 14*8(3)
|
||||
std 25, 15*8(3)
|
||||
std 26, 16*8(3)
|
||||
std 27, 17*8(3)
|
||||
std 28, 18*8(3)
|
||||
std 29, 19*8(3)
|
||||
std 30, 20*8(3)
|
||||
std 31, 21*8(3)
|
||||
# 4) store floating point registers f14-f31
|
||||
stfd 14, 22*8(3)
|
||||
stfd 15, 23*8(3)
|
||||
stfd 16, 24*8(3)
|
||||
stfd 17, 25*8(3)
|
||||
stfd 18, 26*8(3)
|
||||
stfd 19, 27*8(3)
|
||||
stfd 20, 28*8(3)
|
||||
stfd 21, 29*8(3)
|
||||
stfd 22, 30*8(3)
|
||||
stfd 23, 31*8(3)
|
||||
stfd 24, 32*8(3)
|
||||
stfd 25, 33*8(3)
|
||||
stfd 26, 34*8(3)
|
||||
stfd 27, 35*8(3)
|
||||
stfd 28, 36*8(3)
|
||||
stfd 29, 37*8(3)
|
||||
stfd 30, 38*8(3)
|
||||
stfd 31, 39*8(3)
|
||||
|
||||
# 5) store vector registers v20-v31
|
||||
addi 3, 3, 40*8
|
||||
stvx 20, 0, 3 ; addi 3, 3, 16
|
||||
stvx 21, 0, 3 ; addi 3, 3, 16
|
||||
stvx 22, 0, 3 ; addi 3, 3, 16
|
||||
stvx 23, 0, 3 ; addi 3, 3, 16
|
||||
stvx 24, 0, 3 ; addi 3, 3, 16
|
||||
stvx 25, 0, 3 ; addi 3, 3, 16
|
||||
stvx 26, 0, 3 ; addi 3, 3, 16
|
||||
stvx 27, 0, 3 ; addi 3, 3, 16
|
||||
stvx 28, 0, 3 ; addi 3, 3, 16
|
||||
stvx 29, 0, 3 ; addi 3, 3, 16
|
||||
stvx 30, 0, 3 ; addi 3, 3, 16
|
||||
stvx 31, 0, 3
|
||||
|
||||
# 6) return 0
|
||||
li 3, 0
|
||||
blr
|
||||
@@ -0,0 +1,23 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
|
||||
1:
|
||||
lmg %r6, %r15, 0(%r2)
|
||||
|
||||
ld %f8, 10*8(%r2)
|
||||
ld %f9, 11*8(%r2)
|
||||
ld %f10, 12*8(%r2)
|
||||
ld %f11, 13*8(%r2)
|
||||
ld %f12, 14*8(%r2)
|
||||
ld %f13, 15*8(%r2)
|
||||
ld %f14, 16*8(%r2)
|
||||
ld %f15, 17*8(%r2)
|
||||
|
||||
ltgr %r2, %r3
|
||||
bnzr %r14
|
||||
lhi %r2, 1
|
||||
br %r14
|
||||
@@ -0,0 +1,25 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
stmg %r6, %r15, 0(%r2)
|
||||
|
||||
std %f8, 10*8(%r2)
|
||||
std %f9, 11*8(%r2)
|
||||
std %f10, 12*8(%r2)
|
||||
std %f11, 13*8(%r2)
|
||||
std %f12, 14*8(%r2)
|
||||
std %f13, 15*8(%r2)
|
||||
std %f14, 16*8(%r2)
|
||||
std %f15, 17*8(%r2)
|
||||
|
||||
lghi %r2, 0
|
||||
br %r14
|
||||
@@ -0,0 +1,28 @@
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp, @function
|
||||
.type longjmp, @function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
mov.l @r4+, r8
|
||||
mov.l @r4+, r9
|
||||
mov.l @r4+, r10
|
||||
mov.l @r4+, r11
|
||||
mov.l @r4+, r12
|
||||
mov.l @r4+, r13
|
||||
mov.l @r4+, r14
|
||||
mov.l @r4+, r15
|
||||
lds.l @r4+, pr
|
||||
#if __SH_FPU_ANY__ || __SH4__
|
||||
fmov.s @r4+, fr12
|
||||
fmov.s @r4+, fr13
|
||||
fmov.s @r4+, fr14
|
||||
fmov.s @r4+, fr15
|
||||
#endif
|
||||
|
||||
tst r5, r5
|
||||
movt r0
|
||||
add r5, r0
|
||||
|
||||
rts
|
||||
nop
|
||||
@@ -0,0 +1,32 @@
|
||||
.global ___setjmp
|
||||
.hidden ___setjmp
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp, @function
|
||||
.type _setjmp, @function
|
||||
.type setjmp, @function
|
||||
___setjmp:
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
#if __SH_FPU_ANY__ || __SH4__
|
||||
add #52, r4
|
||||
fmov.s fr15, @-r4
|
||||
fmov.s fr14, @-r4
|
||||
fmov.s fr13, @-r4
|
||||
fmov.s fr12, @-r4
|
||||
#else
|
||||
add #36, r4
|
||||
#endif
|
||||
sts.l pr, @-r4
|
||||
mov.l r15, @-r4
|
||||
mov.l r14, @-r4
|
||||
mov.l r13, @-r4
|
||||
mov.l r12, @-r4
|
||||
mov.l r11, @-r4
|
||||
mov.l r10, @-r4
|
||||
mov.l r9, @-r4
|
||||
mov.l r8, @-r4
|
||||
rts
|
||||
mov #0, r0
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
mov %rsi,%rax /* val will be longjmp return */
|
||||
test %rax,%rax
|
||||
jnz 1f
|
||||
inc %rax /* if val==0, val=1 per longjmp semantics */
|
||||
1:
|
||||
mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */
|
||||
mov 8(%rdi),%rbp
|
||||
mov 16(%rdi),%r12
|
||||
mov 24(%rdi),%r13
|
||||
mov 32(%rdi),%r14
|
||||
mov 40(%rdi),%r15
|
||||
mov 48(%rdi),%rdx /* this ends up being the stack pointer */
|
||||
mov %rdx,%rsp
|
||||
mov 56(%rdi),%rdx /* this is the instruction pointer */
|
||||
jmp *%rdx /* goto saved address without altering rsp */
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
mov %rbx,(%rdi) /* rdi is jmp_buf, move registers onto it */
|
||||
mov %rbp,8(%rdi)
|
||||
mov %r12,16(%rdi)
|
||||
mov %r13,24(%rdi)
|
||||
mov %r14,32(%rdi)
|
||||
mov %r15,40(%rdi)
|
||||
lea 8(%rsp),%rdx /* this is our rsp WITHOUT current ret addr */
|
||||
mov %rdx,48(%rdi)
|
||||
mov (%rsp),%rdx /* save return addr ptr for new rip */
|
||||
mov %rdx,56(%rdi)
|
||||
xor %rax,%rax /* always return 0 */
|
||||
ret
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
|
||||
.global _longjmp
|
||||
.global longjmp
|
||||
.type _longjmp,@function
|
||||
.type longjmp,@function
|
||||
_longjmp:
|
||||
longjmp:
|
||||
mov %rsi,%rax /* val will be longjmp return */
|
||||
test %rax,%rax
|
||||
jnz 1f
|
||||
inc %rax /* if val==0, val=1 per longjmp semantics */
|
||||
1:
|
||||
mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */
|
||||
mov 8(%rdi),%rbp
|
||||
mov 16(%rdi),%r12
|
||||
mov 24(%rdi),%r13
|
||||
mov 32(%rdi),%r14
|
||||
mov 40(%rdi),%r15
|
||||
mov 48(%rdi),%rdx /* this ends up being the stack pointer */
|
||||
mov %rdx,%rsp
|
||||
mov 56(%rdi),%rdx /* this is the instruction pointer */
|
||||
jmp *%rdx /* goto saved address without altering rsp */
|
||||
@@ -0,0 +1,22 @@
|
||||
/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
|
||||
.global __setjmp
|
||||
.global _setjmp
|
||||
.global setjmp
|
||||
.type __setjmp,@function
|
||||
.type _setjmp,@function
|
||||
.type setjmp,@function
|
||||
__setjmp:
|
||||
_setjmp:
|
||||
setjmp:
|
||||
mov %rbx,(%rdi) /* rdi is jmp_buf, move registers onto it */
|
||||
mov %rbp,8(%rdi)
|
||||
mov %r12,16(%rdi)
|
||||
mov %r13,24(%rdi)
|
||||
mov %r14,32(%rdi)
|
||||
mov %r15,40(%rdi)
|
||||
lea 8(%rsp),%rdx /* this is our rsp WITHOUT current ret addr */
|
||||
mov %rdx,48(%rdi)
|
||||
mov (%rsp),%rdx /* save return addr ptr for new rip */
|
||||
mov %rdx,56(%rdi)
|
||||
xor %rax,%rax /* always return 0 */
|
||||
ret
|
||||
@@ -0,0 +1,33 @@
|
||||
//! setjmp implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/setjmp.h.html
|
||||
|
||||
#![no_std]
|
||||
#![feature(global_asm)]
|
||||
|
||||
macro_rules! platform_specific {
|
||||
($($arch:expr,$ext:expr;)+) => {
|
||||
$(
|
||||
#[cfg(target_arch = $arch)]
|
||||
global_asm!(include_str!(concat!("impl/", $arch, "/setjmp.", $ext)));
|
||||
#[cfg(target_arch = $arch)]
|
||||
global_asm!(include_str!(concat!("impl/", $arch, "/longjmp.", $ext)));
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
||||
platform_specific! {
|
||||
"aarch64","s";
|
||||
"arm","s";
|
||||
"i386","s";
|
||||
"m68k","s";
|
||||
"microblaze","s";
|
||||
"mips","S";
|
||||
"mips64","S";
|
||||
"mipsn32","S";
|
||||
"or1k","s";
|
||||
"powerpc","S";
|
||||
"powerpc64","s";
|
||||
"s390x","s";
|
||||
"sh","S";
|
||||
"x32","s";
|
||||
"x86_64","s";
|
||||
}
|
||||
@@ -12,6 +12,10 @@ pub mod sys;
|
||||
#[path = "redox.rs"]
|
||||
pub mod sys;
|
||||
|
||||
pub const SIG_BLOCK: c_int = 0;
|
||||
pub const SIG_UNBLOCK: c_int = 1;
|
||||
pub const SIG_SETMASK: c_int = 2;
|
||||
|
||||
pub use sys::*;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
+59
-15
@@ -1,32 +1,76 @@
|
||||
use core::cell::UnsafeCell;
|
||||
use core::sync::atomic::AtomicBool;
|
||||
use super::{constants, BUFSIZ, FILE, UNGET};
|
||||
|
||||
struct GlobalFile(UnsafeCell<FILE>);
|
||||
impl GlobalFile {
|
||||
const fn new(file: FILE) -> Self {
|
||||
GlobalFile(UnsafeCell::new(file))
|
||||
}
|
||||
fn get(&self) -> *mut FILE {
|
||||
self.0.get()
|
||||
}
|
||||
}
|
||||
// statics need to be Sync
|
||||
unsafe impl Sync for GlobalFile {}
|
||||
#[allow(non_upper_case_globals)]
|
||||
static mut default_stdin_buf: [u8; BUFSIZ as usize + UNGET] = [0; BUFSIZ as usize + UNGET];
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
static mut default_stdin: FILE = FILE {
|
||||
flags: constants::F_PERM | constants::F_NOWR | constants::F_BADJ,
|
||||
rpos: ptr::null_mut(),
|
||||
rend: ptr::null_mut(),
|
||||
wend: ptr::null_mut(),
|
||||
wpos: ptr::null_mut(),
|
||||
wbase: ptr::null_mut(),
|
||||
fd: 0,
|
||||
buf: unsafe { &mut default_stdin_buf as *mut [u8] as *mut u8 },
|
||||
buf_size: BUFSIZ as usize,
|
||||
buf_char: -1,
|
||||
unget: UNGET,
|
||||
lock: AtomicBool::new(false),
|
||||
};
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
static mut default_stdout_buf: [u8; BUFSIZ as usize] = [0; BUFSIZ as usize];
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
static mut default_stdout: FILE = FILE {
|
||||
flags: constants::F_PERM | constants::F_NORD | constants::F_BADJ,
|
||||
rpos: ptr::null_mut(),
|
||||
rend: ptr::null_mut(),
|
||||
wend: ptr::null_mut(),
|
||||
wpos: ptr::null_mut(),
|
||||
wbase: ptr::null_mut(),
|
||||
fd: 1,
|
||||
buf: unsafe { &mut default_stdout_buf } as *mut [u8] as *mut u8,
|
||||
buf_size: BUFSIZ as usize,
|
||||
buf_char: b'\n' as i8,
|
||||
unget: 0,
|
||||
lock: AtomicBool::new(false),
|
||||
};
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
static mut default_stderr_buf: [u8; BUFSIZ as usize] = [0; BUFSIZ as usize];
|
||||
|
||||
#[allow(non_upper_case_globals)]
|
||||
static mut default_stderr: FILE = FILE {
|
||||
flags: constants::F_PERM | constants::F_NORD | constants::F_BADJ,
|
||||
rpos: ptr::null_mut(),
|
||||
rend: ptr::null_mut(),
|
||||
wend: ptr::null_mut(),
|
||||
wpos: ptr::null_mut(),
|
||||
wbase: ptr::null_mut(),
|
||||
fd: 2,
|
||||
buf: unsafe { &mut default_stderr_buf } as *mut [u8] as *mut u8,
|
||||
buf_size: BUFSIZ as usize,
|
||||
buf_char: -1,
|
||||
unget: 0,
|
||||
lock: AtomicBool::new(false),
|
||||
};
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __stdin() -> *mut FILE {
|
||||
unsafe { default_stdin.get() }
|
||||
unsafe { &mut default_stdin }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __stdout() -> *mut FILE {
|
||||
unsafe { default_stdout.get() }
|
||||
unsafe { &mut default_stdout }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __stderr() -> *mut FILE {
|
||||
unsafe { default_stderr.get() }
|
||||
unsafe { &mut default_stderr }
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
|
||||
@@ -12,4 +12,5 @@ platform = { path = "../platform" }
|
||||
ralloc = { path = "../../ralloc", default-features = false }
|
||||
ctype = { path = "../ctype" }
|
||||
errno = { path = "../errno" }
|
||||
rand = { git = "https://github.com/rust-lang-nursery/rand/", default-features = false }
|
||||
rand = { version = "0.5.2", default-features = false }
|
||||
time = { path = "../time" }
|
||||
|
||||
+77
-13
@@ -2,16 +2,19 @@
|
||||
|
||||
#![no_std]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(global_allocator)]
|
||||
|
||||
extern crate ctype;
|
||||
extern crate errno;
|
||||
extern crate platform;
|
||||
extern crate ralloc;
|
||||
extern crate rand;
|
||||
extern crate time;
|
||||
|
||||
use core::{ptr, str};
|
||||
use rand::{Rng, SeedableRng, XorShiftRng};
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand::rngs::JitterRng;
|
||||
use rand::prng::XorShiftRng;
|
||||
use rand::distributions::Alphanumeric;
|
||||
|
||||
use errno::*;
|
||||
use platform::types::*;
|
||||
@@ -364,9 +367,65 @@ pub extern "C" fn mbtowc(pwc: *mut wchar_t, s: *const c_char, n: size_t) -> c_in
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mktemp(name: *mut c_char) -> *mut c_char {
|
||||
unimplemented!();
|
||||
use core::slice;
|
||||
use core::iter;
|
||||
use core::mem;
|
||||
extern "C" {
|
||||
fn strlen(s: *const c_char) -> size_t;
|
||||
}
|
||||
let len = unsafe { strlen(name) };
|
||||
if len < 6 {
|
||||
unsafe { platform::errno = errno::EINVAL };
|
||||
unsafe { *name = 0 };
|
||||
return name;
|
||||
}
|
||||
for i in len-6..len {
|
||||
if unsafe { *name.offset(i as isize) } != b'X' as c_char {
|
||||
unsafe { platform::errno = errno::EINVAL };
|
||||
unsafe { *name = 0 };
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
let mut rng = JitterRng::new_with_timer(get_nstime);
|
||||
rng.test_timer();
|
||||
|
||||
let mut retries = 100;
|
||||
loop {
|
||||
let mut char_iter = iter::repeat(())
|
||||
.map(|()| rng.sample(Alphanumeric))
|
||||
.take(6);
|
||||
unsafe {
|
||||
for (i,c) in char_iter.enumerate() {
|
||||
*name.offset(len as isize - i as isize - 1) = c as c_char
|
||||
}
|
||||
}
|
||||
|
||||
unsafe {
|
||||
let mut st: stat = mem::uninitialized();
|
||||
if platform::stat(name, &mut st) != 0 {
|
||||
if platform::errno != ENOENT { *name = 0; }
|
||||
return name;
|
||||
}
|
||||
mem::forget(st);
|
||||
}
|
||||
retries = retries -1;
|
||||
if retries == 0 { break; }
|
||||
}
|
||||
unsafe { platform::errno = EEXIST };
|
||||
unsafe { *name = 0 };
|
||||
name
|
||||
}
|
||||
|
||||
fn get_nstime() -> u64 {
|
||||
use core::mem;
|
||||
use time::constants::CLOCK_MONOTONIC;
|
||||
let mut ts: timespec = unsafe { mem::uninitialized() };
|
||||
platform::clock_gettime(CLOCK_MONOTONIC, &mut ts);
|
||||
unsafe { ts.tv_nsec as u64 }
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mkstemp(name: *mut c_char) -> c_int {
|
||||
unimplemented!();
|
||||
@@ -412,10 +471,10 @@ pub extern "C" fn qsort(
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn rand() -> c_int {
|
||||
match RNG {
|
||||
Some(ref mut rng) => rng.gen_range::<c_int>(0, RAND_MAX),
|
||||
Some(ref mut rng) => rng.gen_range(0, RAND_MAX),
|
||||
None => {
|
||||
let mut rng = XorShiftRng::from_seed([1; 16]);
|
||||
let ret = rng.gen_range::<c_int>(0, RAND_MAX);
|
||||
let ret = rng.gen_range(0, RAND_MAX);
|
||||
RNG = Some(rng);
|
||||
ret
|
||||
}
|
||||
@@ -498,7 +557,7 @@ pub unsafe extern "C" fn strtod(s: *const c_char, endptr: *mut *mut c_char) -> c
|
||||
}
|
||||
}
|
||||
|
||||
fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
pub fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
match ch {
|
||||
0 => None,
|
||||
ch if ch == b'+' as c_char => Some((true, 1)),
|
||||
@@ -507,7 +566,7 @@ fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
}
|
||||
}
|
||||
|
||||
fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
pub fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
let first = unsafe { *s } as u8;
|
||||
match first {
|
||||
0 => None,
|
||||
@@ -526,7 +585,7 @@ fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
pub unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
if *s != 0 && *s == b'0' as c_char {
|
||||
if let Some((val, idx, overflow)) = convert_integer(s.offset(1), 8) {
|
||||
Some((val, idx + 1, overflow))
|
||||
@@ -539,7 +598,7 @@ unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
pub unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
if (*s != 0 && *s == b'0' as c_char)
|
||||
&& (*s.offset(1) != 0 && (*s.offset(1) == b'x' as c_char || *s.offset(1) == b'X' as c_char))
|
||||
{
|
||||
@@ -549,7 +608,7 @@ unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
|
||||
pub fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
|
||||
// -1 means the character is invalid
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
const LOOKUP_TABLE: [c_long; 256] = [
|
||||
@@ -603,6 +662,7 @@ fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, boo
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! strto_impl {
|
||||
(
|
||||
$rettype:ty,
|
||||
@@ -620,7 +680,11 @@ macro_rules! strto_impl {
|
||||
|
||||
let set_endptr = |idx: isize| {
|
||||
if !$endptr.is_null() {
|
||||
*$endptr = $s.offset(idx);
|
||||
// This is stupid, but apparently strto* functions want
|
||||
// const input but mut output, yet the man page says
|
||||
// "stores the address of the first invalid character in *endptr"
|
||||
// so obviously it doesn't want us to clone it.
|
||||
*$endptr = $s.offset(idx) as *mut _;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -712,7 +776,7 @@ macro_rules! strto_impl {
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtoul(s: *const c_char,
|
||||
endptr: *mut *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> c_ulong {
|
||||
strto_impl!(
|
||||
@@ -728,7 +792,7 @@ pub unsafe extern "C" fn strtoul(s: *const c_char,
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn strtol(s: *const c_char,
|
||||
endptr: *mut *const c_char,
|
||||
endptr: *mut *mut c_char,
|
||||
base: c_int)
|
||||
-> c_long {
|
||||
strto_impl!(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
sys_includes = ["sys/types.h"]
|
||||
include_guard = "_SYS_STAT_H"
|
||||
trailer = "#include <bits/sys/stat.h>"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
|
||||
|
||||
+25
-25
@@ -6,31 +6,31 @@ extern crate platform;
|
||||
|
||||
use platform::types::*;
|
||||
|
||||
pub const S_IFMT: c_int = 00170000;
|
||||
pub const S_IFBLK: c_int = 0060000;
|
||||
pub const S_IFCHR: c_int = 0020000;
|
||||
pub const S_IFIFO: c_int = 0010000;
|
||||
pub const S_IFREG: c_int = 0100000;
|
||||
pub const S_IFDIR: c_int = 0040000;
|
||||
pub const S_IFLNK: c_int = 0120000;
|
||||
pub const S_IFMT: c_int = 0o0170000;
|
||||
pub const S_IFBLK: c_int = 0o060000;
|
||||
pub const S_IFCHR: c_int = 0o020000;
|
||||
pub const S_IFIFO: c_int = 0o010000;
|
||||
pub const S_IFREG: c_int = 0o100000;
|
||||
pub const S_IFDIR: c_int = 0o040000;
|
||||
pub const S_IFLNK: c_int = 0o120000;
|
||||
|
||||
pub const S_IRWXU: c_int = 00700;
|
||||
pub const S_IRUSR: c_int = 00400;
|
||||
pub const S_IWUSR: c_int = 00200;
|
||||
pub const S_IXUSR: c_int = 00100;
|
||||
pub const S_IRWXU: c_int = 0o0700;
|
||||
pub const S_IRUSR: c_int = 0o0400;
|
||||
pub const S_IWUSR: c_int = 0o0200;
|
||||
pub const S_IXUSR: c_int = 0o0100;
|
||||
|
||||
pub const S_IRWXG: c_int = 00070;
|
||||
pub const S_IRGRP: c_int = 00040;
|
||||
pub const S_IWGRP: c_int = 00020;
|
||||
pub const S_IXGRP: c_int = 00010;
|
||||
pub const S_IRWXG: c_int = 0o0070;
|
||||
pub const S_IRGRP: c_int = 0o0040;
|
||||
pub const S_IWGRP: c_int = 0o0020;
|
||||
pub const S_IXGRP: c_int = 0o0010;
|
||||
|
||||
pub const S_IRWXO: c_int = 00007;
|
||||
pub const S_IROTH: c_int = 00004;
|
||||
pub const S_IWOTH: c_int = 00002;
|
||||
pub const S_IXOTH: c_int = 00001;
|
||||
pub const S_ISUID: c_int = 04000;
|
||||
pub const S_ISGID: c_int = 02000;
|
||||
pub const S_ISVTX: c_int = 01000;
|
||||
pub const S_IRWXO: c_int = 0o0007;
|
||||
pub const S_IROTH: c_int = 0o0004;
|
||||
pub const S_IWOTH: c_int = 0o0002;
|
||||
pub const S_IXOTH: c_int = 0o0001;
|
||||
pub const S_ISUID: c_int = 0o4000;
|
||||
pub const S_ISGID: c_int = 0o2000;
|
||||
pub const S_ISVTX: c_int = 0o1000;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct stat {
|
||||
@@ -43,9 +43,9 @@ pub struct stat {
|
||||
pub st_rdev: dev_t,
|
||||
pub st_size: off_t,
|
||||
pub st_blksize: blksize_t,
|
||||
pub st_atim: time_t,
|
||||
pub st_mtim: time_t,
|
||||
pub st_ctim: time_t,
|
||||
pub st_atime: time_t,
|
||||
pub st_mtime: time_t,
|
||||
pub st_ctime: time_t,
|
||||
pub st_blocks: blkcnt_t,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
sys_includes = ["sys/types.h"]
|
||||
include_guard = "_SYS_TIME_H"
|
||||
language = "C"
|
||||
style = "Both"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "sys_utsname"
|
||||
version = "0.1.0"
|
||||
authors = ["jD91mZM2 <me@krake.one>"]
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { path = "../../cbindgen" }
|
||||
|
||||
[dependencies]
|
||||
platform = { path = "../platform" }
|
||||
@@ -0,0 +1,11 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
|
||||
fs::create_dir_all("../../target/include").expect("failed to create include directory");
|
||||
cbindgen::generate(crate_dir)
|
||||
.expect("failed to generate bindings")
|
||||
.write_to_file("../../target/include/sys/utsname.h");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
include_guard = "_SYS_UTSNAME_H"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
@@ -0,0 +1,28 @@
|
||||
//! sys/utsname implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
|
||||
|
||||
#![no_std]
|
||||
#![cfg(target_os = "linux")]
|
||||
|
||||
extern crate platform;
|
||||
|
||||
use core::ptr;
|
||||
use platform::types::*;
|
||||
|
||||
const LENGTH: usize = 65;
|
||||
|
||||
#[allow(non_camel_case)]
|
||||
#[no_mangle]
|
||||
#[repr(C)]
|
||||
pub struct utsname {
|
||||
pub sysname: [c_char; LENGTH],
|
||||
pub nodename: [c_char; LENGTH],
|
||||
pub release: [c_char; LENGTH],
|
||||
pub version: [c_char; LENGTH],
|
||||
pub machine: [c_char; LENGTH],
|
||||
pub domainname: [c_char; LENGTH]
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn uname(uts: *mut utsname) -> c_int {
|
||||
platform::uname(uts as usize)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ pub(crate) const MON_NAMES: [&str; 12] = [
|
||||
];
|
||||
|
||||
pub(crate) const CLOCK_REALTIME: clockid_t = 0;
|
||||
pub(crate) const CLOCK_MONOTONIC: clockid_t = 1;
|
||||
pub const CLOCK_MONOTONIC: clockid_t = 1;
|
||||
pub(crate) const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
|
||||
pub(crate) const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
|
||||
|
||||
|
||||
@@ -11,3 +11,4 @@ cbindgen = { path = "../../cbindgen" }
|
||||
platform = { path = "../platform" }
|
||||
stdio = { path = "../stdio" }
|
||||
string = { path = "../string" }
|
||||
sys_utsname = { path = "../sys_utsname" }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
sys_includes = ["stddef.h", "stdint.h", "sys/types.h"]
|
||||
sys_includes = ["stddef.h", "stdint.h", "sys/types.h", "stdarg.h", "bits/exec.h"]
|
||||
include_guard = "_UNISTD_H"
|
||||
trailer = "#include <bits/fcntl.h>"
|
||||
language = "C"
|
||||
|
||||
[enum]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! getopt implementation for Redox, following http://pubs.opengroup.org/onlinepubs/009695399/functions/getopt.html
|
||||
|
||||
use super::platform::types::*;
|
||||
use super::platform;
|
||||
use super::stdio;
|
||||
use super::string;
|
||||
use core::ptr;
|
||||
|
||||
+66
-9
@@ -5,9 +5,11 @@
|
||||
extern crate platform;
|
||||
extern crate stdio;
|
||||
extern crate string;
|
||||
extern crate sys_utsname;
|
||||
|
||||
pub use platform::types::*;
|
||||
pub use getopt::*;
|
||||
|
||||
use core::ptr;
|
||||
|
||||
mod getopt;
|
||||
@@ -30,6 +32,9 @@ pub const STDIN_FILENO: c_int = 0;
|
||||
pub const STDOUT_FILENO: c_int = 1;
|
||||
pub const STDERR_FILENO: c_int = 2;
|
||||
|
||||
#[no_mangle]
|
||||
pub static mut environ: *const *mut c_char = 0 as *const *mut c_char;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _exit(status: c_int) {
|
||||
platform::exit(status)
|
||||
@@ -96,23 +101,27 @@ pub extern "C" fn encrypt(block: [c_char; 64], edflag: c_int) {
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn execl(path: *const c_char, arg0: *const c_char /* TODO: , mut args: ... */) -> c_int {
|
||||
// pub extern "C" fn execl(path: *const c_char, args: *const *mut c_char) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
//
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn execle(path: *const c_char, arg0: *const c_char /* TODO: , mut args: ... */) -> c_int {
|
||||
// pub extern "C" fn execle(
|
||||
// path: *const c_char,
|
||||
// args: *const *mut c_char,
|
||||
// envp: *const *mut c_char,
|
||||
// ) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
//
|
||||
|
||||
// #[no_mangle]
|
||||
// pub extern "C" fn execlp(file: *const c_char, arg0: *const c_char /* TODO: , mut args: ... */) -> c_int {
|
||||
// pub extern "C" fn execlp(file: *const c_char, args: *const *mut c_char) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn execv(path: *const c_char, argv: *const *mut c_char) -> c_int {
|
||||
unimplemented!();
|
||||
unsafe { execve(path, argv, environ) }
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -121,7 +130,7 @@ pub extern "C" fn execve(
|
||||
argv: *const *mut c_char,
|
||||
envp: *const *mut c_char,
|
||||
) -> c_int {
|
||||
unimplemented!();
|
||||
platform::execve(path, argv, envp)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -199,6 +208,54 @@ pub extern "C" fn gethostid() -> c_long {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn gethostname(mut name: *mut c_char, len: size_t) -> c_int {
|
||||
#[cfg(target_os = "linux")] {
|
||||
use core::mem;
|
||||
|
||||
// len only needs to be mutable on linux
|
||||
let mut len = len;
|
||||
|
||||
let mut uts: sys_utsname::utsname = mem::uninitialized();
|
||||
let err = sys_utsname::uname(&mut uts);
|
||||
if err < 0 {
|
||||
mem::forget(uts);
|
||||
return err;
|
||||
}
|
||||
for c in uts.nodename.iter() {
|
||||
if len == 0 { break; }
|
||||
len -= 1;
|
||||
|
||||
*name = *c;
|
||||
|
||||
if *name == 0 {
|
||||
// We do want to copy the zero also, so we check this after the copying.
|
||||
break;
|
||||
}
|
||||
|
||||
name = name.offset(1);
|
||||
}
|
||||
0
|
||||
}
|
||||
#[cfg(target_os = "redox")] {
|
||||
use platform::{FileReader, Read};
|
||||
use platform::syscall::flag::*;
|
||||
|
||||
let fd = platform::open("/etc/hostname\0",as_ptr(), 0, O_RDONLY);
|
||||
if fd < 0 {
|
||||
return fd;
|
||||
}
|
||||
let reader = FileReader(fd);
|
||||
for _ in 0..len {
|
||||
if !reader.read_u8(&mut *name) {
|
||||
*name = 0;
|
||||
break;
|
||||
}
|
||||
name = name.offset(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn getlogin() -> *mut c_char {
|
||||
unimplemented!();
|
||||
@@ -347,7 +404,7 @@ pub extern "C" fn sbrk(incr: intptr_t) -> *mut c_void {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn setgid(gid: gid_t) -> c_int {
|
||||
unimplemented!();
|
||||
platform::setregid(gid, gid)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -377,7 +434,7 @@ pub extern "C" fn setsid() -> pid_t {
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn setuid(uid: uid_t) -> c_int {
|
||||
unimplemented!();
|
||||
platform::setreuid(uid, uid)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
||||
@@ -0,0 +1,394 @@
|
||||
//! wchar implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/string.h.html
|
||||
|
||||
#![no_std]
|
||||
|
||||
extern crate errno;
|
||||
extern crate platform;
|
||||
extern crate stdlib;
|
||||
extern crate string;
|
||||
extern crate time;
|
||||
|
||||
use platform::types::*;
|
||||
use errno::*;
|
||||
use time::*;
|
||||
use core::cmp;
|
||||
use core::usize;
|
||||
use core::ptr;
|
||||
use core::mem;
|
||||
use string::*;
|
||||
|
||||
pub type wint_t = i32;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct mbstate_t {
|
||||
pub mbs_count: c_int,
|
||||
pub mbs_length: c_int,
|
||||
pub mbs_wch: wint_t,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn btowc(c: c_int) -> wint_t {
|
||||
//Check for EOF
|
||||
if c == -1 {
|
||||
return -1;
|
||||
}
|
||||
|
||||
let uc = c as u8;
|
||||
let c = uc as c_char;
|
||||
let mut ps: mbstate_t = mbstate_t {
|
||||
mbs_count: 0,
|
||||
mbs_length: 0,
|
||||
mbs_wch: 0,
|
||||
};
|
||||
let mut wc: wchar_t = 0;
|
||||
let saved_errno = platform::errno;
|
||||
let status = mbrtowc(&mut wc, &c as (*const c_char), 1, &mut ps);
|
||||
if status == usize::max_value() || status == usize::max_value() - 1 {
|
||||
platform::errno = saved_errno;
|
||||
return platform::errno;
|
||||
}
|
||||
return wc as wint_t;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn getwchar() -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn mbsinit(ps: *const mbstate_t) -> c_int {
|
||||
if ps.is_null() || (*ps).mbs_count == 0 {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn mbrlen(s: *const c_char, n: usize, ps: *mut mbstate_t) -> usize {
|
||||
static mut internal: mbstate_t = mbstate_t {
|
||||
mbs_count: 0,
|
||||
mbs_length: 0,
|
||||
mbs_wch: 0,
|
||||
};
|
||||
return mbrtowc(ptr::null_mut(), s, n, &mut internal);
|
||||
}
|
||||
|
||||
//Only works for utf8!
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn mbrtowc(
|
||||
pwc: *mut wchar_t,
|
||||
s: *const c_char,
|
||||
n: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
static mut internal: mbstate_t = mbstate_t {
|
||||
mbs_count: 0,
|
||||
mbs_length: 0,
|
||||
mbs_wch: 0,
|
||||
};
|
||||
|
||||
if ps.is_null() {
|
||||
let ps = &mut internal;
|
||||
}
|
||||
if s.is_null() {
|
||||
let xs: [c_char; 1] = [0];
|
||||
utf8_mbrtowc(pwc, &xs[0] as *const c_char, 1, ps);
|
||||
}
|
||||
|
||||
return utf8_mbrtowc(pwc, s, n, ps);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
unsafe extern "C" fn utf8_mbrtowc(
|
||||
pwc: *mut wchar_t,
|
||||
s: *const c_char,
|
||||
n: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
let mut i: usize = 0;
|
||||
|
||||
while !(i > 0 && (*ps).mbs_count == 0) {
|
||||
if (n <= i) {
|
||||
return -2isize as usize;
|
||||
}
|
||||
let c = s.offset(i as isize);
|
||||
let uc = c as u8;
|
||||
|
||||
if (*ps).mbs_count == 0 {
|
||||
//1 byte sequence - 00–7F
|
||||
if (uc & 0b10000000) == 0b00000000 {
|
||||
(*ps).mbs_count = 0;
|
||||
(*ps).mbs_length = 1;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b1111111) as wint_t;
|
||||
}
|
||||
//2 byte sequence - C2–DF
|
||||
else if (uc & 0b11100000) == 0b11000000 {
|
||||
(*ps).mbs_count = 1;
|
||||
(*ps).mbs_length = 2;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b11111) as wint_t;
|
||||
}
|
||||
//3 byte sequence - E0–EF
|
||||
else if (uc & 0b11110000) == 0b11100000 {
|
||||
(*ps).mbs_count = 2;
|
||||
(*ps).mbs_length = 3;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b1111) as wint_t;
|
||||
}
|
||||
//4 byte sequence - F0–F4
|
||||
else if (uc & 0b11111000) == 0b11110000 {
|
||||
(*ps).mbs_count = 3;
|
||||
(*ps).mbs_length = 4;
|
||||
(*ps).mbs_wch = (uc as wchar_t & 0b111) as wint_t;
|
||||
} else {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
} else {
|
||||
if (uc & 0b11000000) != 0b10000000 {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
|
||||
(*ps).mbs_wch = (*ps).mbs_wch << 6 | (uc & 0b00111111) as wint_t;
|
||||
(*ps).mbs_count -= 1;
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Reject the character if it was produced with an overly long sequence.
|
||||
if (*ps).mbs_length == 1 && 1 << 7 <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
if (*ps).mbs_length == 2 && 1 << (5 + 1 * 6) <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
if (*ps).mbs_length == 3 && 1 << (5 + 2 * 6) <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
if (*ps).mbs_length == 4 && 1 << (5 + 3 * 6) <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
|
||||
// The definition of UTF-8 prohibits encoding character numbers between
|
||||
// U+D800 and U+DFFF, which are reserved for use with the UTF-16 encoding
|
||||
// form (as surrogate pairs) and do not directly represent characters.
|
||||
if 0xD800 <= (*ps).mbs_wch && (*ps).mbs_wch <= 0xDFFF {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
// RFC 3629 limits UTF-8 to 0x0 through 0x10FFFF.
|
||||
if 0x10FFFF <= (*ps).mbs_wch {
|
||||
platform::errno = errno::EILSEQ;
|
||||
return -1isize as usize;
|
||||
}
|
||||
|
||||
let result: wchar_t = (*ps).mbs_wch as wchar_t;
|
||||
|
||||
if !pwc.is_null() {
|
||||
*pwc = result;
|
||||
}
|
||||
|
||||
(*ps).mbs_length = 0;
|
||||
(*ps).mbs_wch = 0;
|
||||
|
||||
return if result != 0 { i } else { 0 };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mbsrtowcs(
|
||||
dst: *mut wchar_t,
|
||||
src: *mut *const c_char,
|
||||
len: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn putwchar(wc: wchar_t) -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn towlower(wc: wint_t) -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn towupper(wc: wint_t) -> wint_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcrtomb(s: *mut c_char, wc: wchar_t, ps: *mut mbstate_t) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscat(ws1: *mut wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcschr(ws1: *const wchar_t, ws2: wchar_t) -> *mut c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscmp(ws1: *const wchar_t, ws2: *const wchar_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscoll(ws1: *const wchar_t, ws2: *const wchar_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscpy(ws1: *mut wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcscspn(ws1: *const wchar_t, ws2: *const wchar_t) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsftime(
|
||||
wcs: *mut wchar_t,
|
||||
maxsize: usize,
|
||||
format: *const wchar_t,
|
||||
timptr: *mut tm,
|
||||
) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcslen(ws: *const wchar_t) -> c_ulong {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsncat(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsncmp(ws1: *const wchar_t, ws2: *const wchar_t, n: usize) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsncpy(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcspbrk(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsrchr(ws1: *const wchar_t, ws2: wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsrtombs(
|
||||
dst: *mut c_char,
|
||||
src: *mut *const wchar_t,
|
||||
len: usize,
|
||||
ps: *mut mbstate_t,
|
||||
) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsspn(ws1: *const wchar_t, ws2: *const wchar_t) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsstr(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstod(nptr: *const wchar_t, endptr: *mut *mut wchar_t) -> f64 {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstok(
|
||||
ws1: *mut wchar_t,
|
||||
ws2: *const wchar_t,
|
||||
ptr: *mut *mut wchar_t,
|
||||
) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstol(nptr: *const wchar_t, endptr: *mut *mut wchar_t, base: c_int) -> c_long {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcstoul(nptr: *const wchar_t, endptr: *mut *mut wchar_t, base: c_int) -> c_ulong {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcswcs(ws1: *const wchar_t, ws2: *const wchar_t) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcswidth(pwcs: *const wchar_t, n: usize) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcsxfrm(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> usize {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wctob(c: wint_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wcwidth(wc: wchar_t) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemchr(ws: *const wchar_t, wc: wchar_t, n: usize) -> *mut c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemcmp(ws1: *const wchar_t, ws2: *const wchar_t, n: usize) -> c_int {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemcpy(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemmove(ws1: *mut wchar_t, ws2: *const wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wmemset(ws1: *mut wchar_t, ws2: wchar_t, n: usize) -> *mut wchar_t {
|
||||
unimplemented!();
|
||||
}
|
||||
Reference in New Issue
Block a user