|
@@ -1,32 +1,34 @@
|
|
|
|
|
|
|
|
|
+
|
|
|
use crate::unix::platform::pal::{e};
|
|
|
use crate::unix::c_str::CStr;
|
|
|
+use crate::unix::platform::pal::e;
|
|
|
use crate::unix::*;
|
|
|
use dsc::syscall;
|
|
|
|
|
|
pub extern "C" fn utimens(_path: &CStr, _times: *const timespec) -> ::c_int {
|
|
|
- // e(unsafe { syscall!(UTIMENSAT, AT_FDCWD, path.as_ptr(), times, 0) }) as ::c_int
|
|
|
- unimplemented!()
|
|
|
+ // e(unsafe { syscall!(UTIMENSAT, AT_FDCWD, path.as_ptr(), times, 0) }) as ::c_int
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t{
|
|
|
- e(unsafe { syscall!(SYS_WRITE, fd, buf, count) }) as ::ssize_t
|
|
|
+pub extern "C" fn write(fd: ::c_int, buf: *const ::c_void, count: ::size_t) -> ::ssize_t {
|
|
|
+ e(unsafe { syscall!(SYS_WRITE, fd, buf, count) }) as ::ssize_t
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn access(_path: *const ::c_char, _amode: ::c_int) -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn access(_path: *const ::c_char, _amode: ::c_int) -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
-pub extern "C" fn brk(addr: *mut ::c_void) -> *mut ::c_void{
|
|
|
- unsafe { syscall!(SYS_BRK, addr) as *mut ::c_void }
|
|
|
+pub extern "C" fn brk(addr: *mut ::c_void) -> *mut ::c_void {
|
|
|
+ unsafe { syscall!(SYS_BRK, addr) as *mut ::c_void }
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn chdir(dir: *const ::c_char) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_CHDIR, dir) }) as ::c_int
|
|
|
+pub extern "C" fn chdir(dir: *const ::c_char) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_CHDIR, dir) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -45,18 +47,18 @@ pub extern "C" fn clock_gettime(_clk_id: ::clockid_t, _tp: *mut ::timespec) -> :
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn close(fd: ::c_int) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_CLOSE, fd) }) as ::c_int
|
|
|
+pub extern "C" fn close(fd: ::c_int) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_CLOSE, fd) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn dup(fd: ::c_int) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_DUP, fd) }) as ::c_int
|
|
|
+pub extern "C" fn dup(fd: ::c_int) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_DUP, fd) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_DUP2, src, dst) }) as ::c_int
|
|
|
+pub extern "C" fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_DUP2, src, dst) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -64,21 +66,21 @@ pub extern "C" fn execve(
|
|
|
prog: *const ::c_char,
|
|
|
argv_: *const *const ::c_char,
|
|
|
envp: *const *const ::c_char,
|
|
|
-) -> ::c_int{
|
|
|
- e(unsafe{syscall!(SYS_EXECVE, prog, argv_, envp)}) as ::c_int
|
|
|
+) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_EXECVE, prog, argv_, envp) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_FSTAT, fildes, buf) }) as ::c_int
|
|
|
+pub extern "C" fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_FSTAT, fildes, buf) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
//#[no_mangle]
|
|
|
-pub extern "C" fn exit(status: ::c_int) -> !{
|
|
|
- unsafe {
|
|
|
- syscall!(SYS_EXIT, status);
|
|
|
- }
|
|
|
- loop {}
|
|
|
+pub extern "C" fn exit(status: ::c_int) -> ! {
|
|
|
+ unsafe {
|
|
|
+ syscall!(SYS_EXIT, status);
|
|
|
+ }
|
|
|
+ loop {}
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -107,13 +109,13 @@ pub extern "C" fn fstatvfs(_fd: ::c_int, _buf: *mut statvfs) -> ::c_int{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn fcntl(fd: ::c_int, cmd: ::c_int,arg: ::c_int) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_FCNTL, fd, cmd, arg) }) as ::c_int
|
|
|
+pub extern "C" fn fcntl(fd: ::c_int, cmd: ::c_int, arg: ::c_int) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_FCNTL, fd, cmd, arg) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
//#[no_mangle]
|
|
|
-pub extern "C" fn fork() -> ::pid_t{
|
|
|
- e(unsafe { syscall!(SYS_FORK) }) as ::pid_t
|
|
|
+pub extern "C" fn fork() -> ::pid_t {
|
|
|
+ e(unsafe { syscall!(SYS_FORK) }) as ::pid_t
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -127,8 +129,8 @@ pub extern "C" fn fsync(_fd: ::c_int) -> ::c_int{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_FTRUNCATE, fd, length) }) as ::c_int
|
|
|
+pub extern "C" fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_FTRUNCATE, fd, length) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
pub extern "C" fn futex(_addr: *mut ::c_int, _op: ::c_int, _val: ::c_int, _val2: usize) -> ::c_int {
|
|
@@ -178,22 +180,27 @@ pub extern "C" fn getdents(
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getegid() -> gid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn getdents(fd: ::c_int, dirents: *mut dirent, bytes: usize) -> ::c_int {
|
|
|
+ unsafe { syscall!(SYS_GET_DENTS, dirents, bytes) as ::c_int }
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn geteuid() -> uid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn getegid() -> gid_t {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getgid() -> gid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn geteuid() -> uid_t {
|
|
|
+ 0
|
|
|
+}
|
|
|
+
|
|
|
+#[no_mangle]
|
|
|
+pub extern "C" fn getgid() -> gid_t {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
//#[no_mangle]
|
|
|
-pub extern "C" fn getpagesize() -> usize{
|
|
|
+pub extern "C" fn getpagesize() -> usize {
|
|
|
unimplemented!()
|
|
|
}
|
|
|
|
|
@@ -203,13 +210,13 @@ pub extern "C" fn getpgid(_pid: ::pid_t) -> ::pid_t{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getpid() -> ::pid_t{
|
|
|
- e(unsafe { syscall!(SYS_GETPID) }) as ::pid_t
|
|
|
+pub extern "C" fn getpid() -> ::pid_t {
|
|
|
+ e(unsafe { syscall!(SYS_GETPID) }) as ::pid_t
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getppid() -> ::pid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn getppid() -> ::pid_t {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -223,18 +230,18 @@ pub extern "C" fn getsid(_pid: ::pid_t) -> ::pid_t{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn gettid() -> ::pid_t{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn gettid() -> ::pid_t {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
//#[no_mangle]
|
|
|
-pub extern "C" fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_GETTIMEOFDAY, tp, tz) }) as ::c_int
|
|
|
+pub extern "C" fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_GETTIMEOFDAY, tp, tz) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn getuid() -> uid_t{
|
|
|
- 0
|
|
|
+pub extern "C" fn getuid() -> uid_t {
|
|
|
+ 0
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -248,13 +255,13 @@ pub extern "C" fn link(_src: *const ::c_char, _dst: *const ::c_char) -> ::c_int{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t{
|
|
|
- e(unsafe { syscall!(SYS_LSEEK, fd, offset, whence) }) as off_t
|
|
|
+pub extern "C" fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t {
|
|
|
+ e(unsafe { syscall!(SYS_LSEEK, fd, offset, whence) }) as off_t
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn mkdir(path: *const ::c_char, mode: mode_t) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_MKDIR, path, mode) }) as ::c_int
|
|
|
+pub extern "C" fn mkdir(path: *const ::c_char, mode: mode_t) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_MKDIR, path, mode) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -280,13 +287,13 @@ pub extern "C" fn mmap(
|
|
|
flags: ::c_int,
|
|
|
fd: ::c_int,
|
|
|
offset: off_t,
|
|
|
-) -> *mut ::c_void{
|
|
|
- e(unsafe{syscall!(SYS_MMAP, addr, len, prot, flags, fd, offset)}) as *mut ::c_void
|
|
|
+) -> *mut ::c_void {
|
|
|
+ e(unsafe { syscall!(SYS_MMAP, addr, len, prot, flags, fd, offset) }) as *mut ::c_void
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int{
|
|
|
- e(unsafe{syscall!(SYS_MPROTECT, addr, len, prot)}) as ::c_int
|
|
|
+pub extern "C" fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_MPROTECT, addr, len, prot) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -300,32 +307,32 @@ pub extern "C" fn munlock(_addr: *const ::c_void, _len: ::size_t) -> ::c_int{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn munlockall() -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn munlockall() -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int{
|
|
|
- e(unsafe{syscall!(SYS_MUNMAP, addr, len)}) as ::c_int
|
|
|
+pub extern "C" fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_MUNMAP, addr, len) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_NANOSLEEP, rqtp, rmtp) }) as ::c_int
|
|
|
+pub extern "C" fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_NANOSLEEP, rqtp, rmtp) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn open(path: *const ::c_char, oflag: ::c_int, mode: mode_t) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_OPEN, path, oflag, mode) }) as ::c_int
|
|
|
+pub extern "C" fn open(path: *const ::c_char, oflag: ::c_int, mode: mode_t) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_OPEN, path, oflag, mode) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int{
|
|
|
- if flags == 0 {
|
|
|
- e(unsafe { syscall!(SYS_PIPE, fds) }) as ::c_int
|
|
|
- } else {
|
|
|
- unimplemented!()
|
|
|
- }
|
|
|
+pub extern "C" fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int {
|
|
|
+ if flags == 0 {
|
|
|
+ e(unsafe { syscall!(SYS_PIPE, fds) }) as ::c_int
|
|
|
+ } else {
|
|
|
+ unimplemented!()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -334,8 +341,8 @@ pub unsafe extern "C" fn pte_clone(_stack: *mut usize) -> ::pid_t{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t{
|
|
|
- e(unsafe { syscall!(SYS_READ, fd, buf, count) }) as ::ssize_t
|
|
|
+pub extern "C" fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t {
|
|
|
+ e(unsafe { syscall!(SYS_READ, fd, buf, count) }) as ::ssize_t
|
|
|
}
|
|
|
|
|
|
pub extern "C" fn readlink(_path: *const c_char, _buf: *mut c_char, _bufsz: ::size_t) -> ::ssize_t{
|
|
@@ -348,13 +355,13 @@ pub extern "C" fn rename(_oldname: *const ::c_char, _newname: *const ::c_char) -
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn rmdir(path: *const ::c_char) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_UNLINK_AT, 0, path, AT_REMOVEDIR) }) as ::c_int
|
|
|
+pub extern "C" fn rmdir(path: *const ::c_char) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_UNLINK_AT, 0, path, AT_REMOVEDIR) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn sched_yield() -> ::c_int{
|
|
|
- unimplemented!()
|
|
|
+pub extern "C" fn sched_yield() -> ::c_int {
|
|
|
+ unimplemented!()
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
@@ -388,16 +395,16 @@ pub extern "C" fn uname(_buf: *mut ::utsname) -> ::c_int{
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn unlink(c: *const ::c_char) -> ::c_int{
|
|
|
- e(unsafe { syscall!(SYS_UNLINK_AT, AT_FDCWD, c, 0) }) as ::c_int
|
|
|
+pub extern "C" fn unlink(c: *const ::c_char) -> ::c_int {
|
|
|
+ e(unsafe { syscall!(SYS_UNLINK_AT, AT_FDCWD, c, 0) }) as ::c_int
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn waitpid(pid: ::pid_t, status: *mut ::c_int, options: ::c_int) -> ::pid_t{
|
|
|
- e(unsafe { syscall!(SYS_WAIT4, pid, status, options, 0) }) as ::pid_t
|
|
|
+pub extern "C" fn waitpid(pid: ::pid_t, status: *mut ::c_int, options: ::c_int) -> ::pid_t {
|
|
|
+ e(unsafe { syscall!(SYS_WAIT4, pid, status, options, 0) }) as ::pid_t
|
|
|
}
|
|
|
|
|
|
#[no_mangle]
|
|
|
-pub extern "C" fn verify() -> bool{
|
|
|
+pub extern "C" fn verify() -> bool {
|
|
|
return true;
|
|
|
-}
|
|
|
+}
|