浏览代码

target=x86_64-dragonos能通过编译

longjin 2 年之前
父节点
当前提交
ed19381547

+ 2 - 0
.cargo/config.toml

@@ -0,0 +1,2 @@
+[build]
+target = "x86_64-unknown-dragonos"

+ 6 - 6
Makefile

@@ -85,24 +85,24 @@ install-headers: libs
 	cp -v "openlibm/src"/*.h "$(DESTDIR)/include"
 	cp -v "pthreads-emb/"*.h "$(DESTDIR)/include"
 
+# $(BUILD)/release/libc.so
 libs: \
 	$(BUILD)/release/libc.a \
-	$(BUILD)/release/libc.so \
 	$(BUILD)/release/crt0.o \
 	$(BUILD)/release/crti.o \
-	$(BUILD)/release/crtn.o \
-	$(BUILD)/release/ld_so
+	$(BUILD)/release/crtn.o
+#$(BUILD)/release/ld_so
 
 install-libs: libs
 	mkdir -pv "$(DESTDIR)/lib"
 	cp -v "$(BUILD)/release/libc.a" "$(DESTDIR)/lib"
-	cp -v "$(BUILD)/release/libc.so" "$(DESTDIR)/lib"
-	ln -frsv "$(DESTDIR)/lib/libc.so" "$(DESTDIR)/lib/libc.so.6"
+# cp -v "$(BUILD)/release/libc.so" "$(DESTDIR)/lib"
+# ln -frsv "$(DESTDIR)/lib/libc.so" "$(DESTDIR)/lib/libc.so.6"
 	cp -v "$(BUILD)/release/crt0.o" "$(DESTDIR)/lib"
 	ln -frsv "$(DESTDIR)/lib/crt0.o" "$(DESTDIR)/lib/crt1.o"
 	cp -v "$(BUILD)/release/crti.o" "$(DESTDIR)/lib"
 	cp -v "$(BUILD)/release/crtn.o" "$(DESTDIR)/lib"
-	cp -v "$(BUILD)/release/ld_so" "$(DESTDIR)/lib/ld64.so.1"
+# cp -v "$(BUILD)/release/ld_so" "$(DESTDIR)/lib/ld64.so.1"
 	cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
 	cp -v "$(BUILD)/pthreads-emb/libpthread.a" "$(DESTDIR)/lib/libpthread.a"
 	# Empty libraries for dl and rt

+ 4 - 3
src/header/signal/dragonos.rs

@@ -1,16 +1,17 @@
 use core::arch::global_asm;
 
 // Needs to be defined in assembly because it can't have a function prologue
-// rax is register, 15 is RT_SIGRETURN
+// rax is register, 25 is RT_SIGRETURN
 #[cfg(target_arch = "x86_64")]
 global_asm!(
     "
     .global __restore_rt
     __restore_rt:
-        mov rax, 15
-        syscall
+        mov rax, 25
+        int 0x80
 "
 );
+
 // x8 is register, 139 is RT_SIGRETURN
 #[cfg(target_arch = "aarch64")]
 global_asm!(

+ 2 - 1
src/ld_so/mod.rs

@@ -153,7 +153,8 @@ pub unsafe fn init(sp: &'static Stack) {
     #[cfg(target_os = "dragonos")]
     {
         const ARCH_GET_FS: usize = 0x1003;
-        syscall!(ARCH_PRCTL, ARCH_GET_FS, &mut tp as *mut usize);
+        // syscall!(ARCH_PRCTL, ARCH_GET_FS, &mut tp as *mut usize);
+        unimplemented!()
     }
     #[cfg(all(target_os = "redox", target_arch = "aarch64"))]
     {

+ 2 - 1
src/ld_so/tcb.rs

@@ -260,7 +260,8 @@ impl Tcb {
     #[cfg(all(target_os = "dragonos", target_arch = "x86_64"))]
     unsafe fn os_arch_activate(tls_end: usize, _tls_len: usize) {
         const ARCH_SET_FS: usize = 0x1002;
-        syscall!(ARCH_PRCTL, ARCH_SET_FS, tls_end);
+        // syscall!(ARCH_PRCTL, ARCH_SET_FS, tls_end);
+        unimplemented!()
     }
 
     /// OS and architecture specific code to activate TLS - Redox aarch64

+ 15 - 12
src/platform/dragonos/epoll.rs

@@ -6,11 +6,13 @@ use crate::header::{signal::sigset_t, sys_epoll::epoll_event};
 
 impl PalEpoll for Sys {
     fn epoll_create1(flags: c_int) -> c_int {
-        unsafe { e(syscall!(EPOLL_CREATE1, flags)) as c_int }
+        // unsafe { e(syscall!(EPOLL_CREATE1, flags)) as c_int }
+        unimplemented!()
     }
 
     fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut epoll_event) -> c_int {
-        unsafe { e(syscall!(EPOLL_CTL, epfd, op, fd, event)) as c_int }
+        // unsafe { e(syscall!(EPOLL_CTL, epfd, op, fd, event)) as c_int }
+        unimplemented!()
     }
 
     fn epoll_pwait(
@@ -20,15 +22,16 @@ impl PalEpoll for Sys {
         timeout: c_int,
         sigmask: *const sigset_t,
     ) -> c_int {
-        unsafe {
-            e(syscall!(
-                EPOLL_PWAIT,
-                epfd,
-                events,
-                maxevents,
-                timeout,
-                sigmask
-            )) as c_int
-        }
+        // unsafe {
+        //     e(syscall!(
+        //         EPOLL_PWAIT,
+        //         epfd,
+        //         events,
+        //         maxevents,
+        //         timeout,
+        //         sigmask
+        //     )) as c_int
+        // }
+        unimplemented!()
     }
 }

+ 238 - 180
src/platform/dragonos/mod.rs

@@ -21,7 +21,6 @@ mod ptrace;
 mod signal;
 mod socket;
 
-
 const AT_FDCWD: c_int = -100;
 const AT_EMPTY_PATH: c_int = 0x1000;
 const AT_REMOVEDIR: c_int = 0x200;
@@ -70,7 +69,8 @@ impl Sys {
 
     pub unsafe fn ioctl(fd: c_int, request: c_ulong, out: *mut c_void) -> c_int {
         // TODO: Somehow support varargs to syscall??
-        e(syscall!(IOCTL, fd, request, out)) as c_int
+        // e(syscall!(IOCTL, fd, request, out)) as c_int
+        unimplemented!()
     }
 
     // fn times(out: *mut tms) -> clock_t {
@@ -80,245 +80,285 @@ impl Sys {
 
 impl Pal for Sys {
     fn access(path: &CStr, mode: c_int) -> c_int {
-        e(unsafe { syscall!(ACCESS, path.as_ptr(), mode) }) as c_int
+        // e(unsafe { syscall!(ACCESS, path.as_ptr(), mode) }) as c_int
+        unimplemented!()
     }
 
     fn brk(addr: *mut c_void) -> *mut c_void {
-        unsafe { syscall!(BRK, addr) as *mut c_void }
+        unsafe { syscall!(SYS_BRK, addr) as *mut c_void }
     }
 
     fn chdir(path: &CStr) -> c_int {
-        e(unsafe { syscall!(CHDIR, path.as_ptr()) }) as c_int
+        e(unsafe { syscall!(SYS_CHDIR, path.as_ptr()) }) as c_int
     }
 
     fn chmod(path: &CStr, mode: mode_t) -> c_int {
-        e(unsafe { syscall!(FCHMODAT, AT_FDCWD, path.as_ptr(), mode, 0) }) as c_int
+        // e(unsafe { syscall!(FCHMODAT, AT_FDCWD, path.as_ptr(), mode, 0) }) as c_int
+        return 0;
     }
 
     fn chown(path: &CStr, owner: uid_t, group: gid_t) -> c_int {
-        e(unsafe {
-            syscall!(
-                FCHOWNAT,
-                AT_FDCWD,
-                path.as_ptr(),
-                owner as u32,
-                group as u32
-            )
-        }) as c_int
+        // e(unsafe {
+        //     syscall!(
+        //         FCHOWNAT,
+        //         AT_FDCWD,
+        //         path.as_ptr(),
+        //         owner as u32,
+        //         group as u32
+        //     )
+        // }) as c_int
+        return 0;
     }
 
     fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int {
-        e(unsafe { syscall!(CLOCK_GETTIME, clk_id, tp) }) as c_int
+        // e(unsafe { syscall!(CLOCK_GETTIME, clk_id, tp) }) as c_int
+        unimplemented!()
     }
 
     fn close(fildes: c_int) -> c_int {
-        e(unsafe { syscall!(CLOSE, fildes) }) as c_int
+        e(unsafe { syscall!(SYS_CLOSE, fildes) }) as c_int
     }
 
     fn dup(fildes: c_int) -> c_int {
-        e(unsafe { syscall!(DUP, fildes) }) as c_int
+        // e(unsafe { syscall!(DUP, fildes) }) as c_int
+        unimplemented!()
     }
 
     fn dup2(fildes: c_int, fildes2: c_int) -> c_int {
-        e(unsafe { syscall!(DUP3, fildes, fildes2, 0) }) as c_int
+        // e(unsafe { syscall!(DUP3, fildes, fildes2, 0) }) as c_int
+        unimplemented!()
     }
 
     unsafe fn execve(path: &CStr, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int {
-        e(syscall!(EXECVE, path.as_ptr(), argv, envp)) as c_int
+        e(syscall!(SYS_EXECVE, path.as_ptr(), argv, envp)) as c_int
     }
 
     fn exit(status: c_int) -> ! {
         unsafe {
-            syscall!(EXIT, status);
+            syscall!(SYS_EXIT, status);
         }
         loop {}
     }
 
     fn fchdir(fildes: c_int) -> c_int {
-        e(unsafe { syscall!(FCHDIR, fildes) }) as c_int
+        // e(unsafe { syscall!(FCHDIR, fildes) }) as c_int
+        unimplemented!()
     }
 
     fn fchmod(fildes: c_int, mode: mode_t) -> c_int {
-        e(unsafe { syscall!(FCHMOD, fildes, mode) }) as c_int
+        // e(unsafe { syscall!(FCHMOD, fildes, mode) }) as c_int
+        return 0;
     }
 
     fn fchown(fildes: c_int, owner: uid_t, group: gid_t) -> c_int {
-        e(unsafe { syscall!(FCHOWN, fildes, owner, group) }) as c_int
+        // e(unsafe { syscall!(FCHOWN, fildes, owner, group) }) as c_int
+        return 0;
     }
 
     fn flock(fd: c_int, operation: c_int) -> c_int {
-        e(unsafe { syscall!(FLOCK, fd, operation) }) as c_int
+        // e(unsafe { syscall!(FLOCK, fd, operation) }) as c_int
+        return 0;
     }
 
     fn fstat(fildes: c_int, buf: *mut stat) -> c_int {
-        let empty = b"\0";
-        let empty_ptr = empty.as_ptr() as *const c_char;
-        e(unsafe { syscall!(NEWFSTATAT, fildes, empty_ptr, buf, AT_EMPTY_PATH) }) as c_int
+        // let empty = b"\0";
+        // let empty_ptr = empty.as_ptr() as *const c_char;
+        // e(unsafe { syscall!(NEWFSTATAT, fildes, empty_ptr, buf, AT_EMPTY_PATH) }) as c_int
+        unimplemented!()
     }
 
     fn fstatvfs(fildes: c_int, buf: *mut statvfs) -> c_int {
-        let mut kbuf = linux_statfs::default();
-        let kbuf_ptr = &mut kbuf as *mut linux_statfs;
-        let res = e(unsafe { syscall!(FSTATFS, fildes, kbuf_ptr) }) as c_int;
-        if res == 0 {
-            unsafe {
-                if !buf.is_null() {
-                    (*buf).f_bsize = kbuf.f_bsize as c_ulong;
-                    (*buf).f_frsize = if kbuf.f_frsize != 0 {
-                        kbuf.f_frsize
-                    } else {
-                        kbuf.f_bsize
-                    } as c_ulong;
-                    (*buf).f_blocks = kbuf.f_blocks;
-                    (*buf).f_bfree = kbuf.f_bfree;
-                    (*buf).f_bavail = kbuf.f_bavail;
-                    (*buf).f_files = kbuf.f_files;
-                    (*buf).f_ffree = kbuf.f_ffree;
-                    (*buf).f_favail = kbuf.f_ffree;
-                    (*buf).f_fsid = kbuf.f_fsid as c_ulong;
-                    (*buf).f_flag = kbuf.f_flags as c_ulong;
-                    (*buf).f_namemax = kbuf.f_namelen as c_ulong;
-                }
-            }
-        }
-        res
+        // let mut kbuf = linux_statfs::default();
+        // let kbuf_ptr = &mut kbuf as *mut linux_statfs;
+        // let res = e(unsafe { syscall!(FSTATFS, fildes, kbuf_ptr) }) as c_int;
+        // if res == 0 {
+        //     unsafe {
+        //         if !buf.is_null() {
+        //             (*buf).f_bsize = kbuf.f_bsize as c_ulong;
+        //             (*buf).f_frsize = if kbuf.f_frsize != 0 {
+        //                 kbuf.f_frsize
+        //             } else {
+        //                 kbuf.f_bsize
+        //             } as c_ulong;
+        //             (*buf).f_blocks = kbuf.f_blocks;
+        //             (*buf).f_bfree = kbuf.f_bfree;
+        //             (*buf).f_bavail = kbuf.f_bavail;
+        //             (*buf).f_files = kbuf.f_files;
+        //             (*buf).f_ffree = kbuf.f_ffree;
+        //             (*buf).f_favail = kbuf.f_ffree;
+        //             (*buf).f_fsid = kbuf.f_fsid as c_ulong;
+        //             (*buf).f_flag = kbuf.f_flags as c_ulong;
+        //             (*buf).f_namemax = kbuf.f_namelen as c_ulong;
+        //         }
+        //     }
+        // }
+        // res
+
+        unimplemented!()
     }
 
     fn fcntl(fildes: c_int, cmd: c_int, arg: c_int) -> c_int {
-        e(unsafe { syscall!(FCNTL, fildes, cmd, arg) }) as c_int
+        // e(unsafe { syscall!(FCNTL, fildes, cmd, arg) }) as c_int
+        unimplemented!()
     }
 
     fn fork() -> pid_t {
-        e(unsafe { syscall!(CLONE, SIGCHLD, 0, 0, 0, 0) }) as pid_t
+        // e(unsafe { syscall!(CLONE, SIGCHLD, 0, 0, 0, 0) }) as pid_t
+        e(unsafe { syscall!(SYS_FORK) }) as pid_t
     }
 
     fn fpath(fildes: c_int, out: &mut [u8]) -> ssize_t {
-        let mut proc_path = b"/proc/self/fd/".to_vec();
-        write!(proc_path, "{}", fildes).unwrap();
-        proc_path.push(0);
+        // let mut proc_path = b"/proc/self/fd/".to_vec();
+        // write!(proc_path, "{}", fildes).unwrap();
+        // proc_path.push(0);
 
-        Self::readlink(CStr::from_bytes_with_nul(&proc_path).unwrap(), out)
+        // Self::readlink(CStr::from_bytes_with_nul(&proc_path).unwrap(), out)
+        unimplemented!()
     }
 
     fn fsync(fildes: c_int) -> c_int {
-        e(unsafe { syscall!(FSYNC, fildes) }) as c_int
+        // e(unsafe { syscall!(FSYNC, fildes) }) as c_int
+        return 0;
     }
 
     fn ftruncate(fildes: c_int, length: off_t) -> c_int {
-        e(unsafe { syscall!(FTRUNCATE, fildes, length) }) as c_int
+        // e(unsafe { syscall!(FTRUNCATE, fildes, length) }) as c_int
+        unimplemented!()
     }
 
     fn futex(addr: *mut c_int, op: c_int, val: c_int, val2: usize) -> c_int {
-        unsafe { syscall!(FUTEX, addr, op, val, val2, 0, 0) as c_int }
+        // unsafe { syscall!(FUTEX, addr, op, val, val2, 0, 0) as c_int }
+        unimplemented!()
     }
 
     fn futimens(fd: c_int, times: *const timespec) -> c_int {
-        e(unsafe { syscall!(UTIMENSAT, fd, ptr::null::<c_char>(), times, 0) }) as c_int
+        // e(unsafe { syscall!(UTIMENSAT, fd, ptr::null::<c_char>(), times, 0) }) as c_int
+        unimplemented!()
     }
 
     fn utimens(path: &CStr, times: *const timespec) -> c_int {
-        e(unsafe { syscall!(UTIMENSAT, AT_FDCWD, path.as_ptr(), times, 0) }) as c_int
+        // e(unsafe { syscall!(UTIMENSAT, AT_FDCWD, path.as_ptr(), times, 0) }) as c_int
+        unimplemented!()
     }
 
     fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char {
-        if e(unsafe { syscall!(GETCWD, buf, size) }) == !0 {
-            ptr::null_mut()
-        } else {
-            buf
-        }
+        // if e(unsafe { syscall!(GETCWD, buf, size) }) == !0 {
+        //     ptr::null_mut()
+        // } else {
+        //     buf
+        // }
+        unimplemented!()
     }
 
     fn getdents(fd: c_int, dirents: *mut dirent, bytes: usize) -> c_int {
-        unsafe { syscall!(GETDENTS64, fd, dirents, bytes) as c_int }
+        unsafe { syscall!(SYS_GET_DENTS, fd, dirents, bytes) as c_int }
     }
 
     fn getegid() -> gid_t {
-        e(unsafe { syscall!(GETEGID) }) as gid_t
+        // e(unsafe { syscall!(GETEGID) }) as gid_t
+        return 0;
     }
 
     fn geteuid() -> uid_t {
-        e(unsafe { syscall!(GETEUID) }) as uid_t
+        // e(unsafe { syscall!(GETEUID) }) as uid_t
+        return 0;
     }
 
     fn getgid() -> gid_t {
-        e(unsafe { syscall!(GETGID) }) as gid_t
+        // e(unsafe { syscall!(GETGID) }) as gid_t
+        return 0;
     }
 
     fn getpagesize() -> usize {
-        4096
+        // 4096
+        1024 * 1024 * 2
     }
 
     fn getpgid(pid: pid_t) -> pid_t {
-        e(unsafe { syscall!(GETPGID, pid) }) as pid_t
+        // e(unsafe { syscall!(GETPGID, pid) }) as pid_t
+        return 0;
     }
 
     fn getpid() -> pid_t {
-        e(unsafe { syscall!(GETPID) }) as pid_t
+        e(unsafe { syscall!(SYS_GETPID) }) as pid_t
     }
 
     fn getppid() -> pid_t {
-        e(unsafe { syscall!(GETPPID) }) as pid_t
+        // e(unsafe { syscall!(GETPPID) }) as pid_t
+        return 0;
     }
 
     fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t {
-        e(unsafe { syscall!(GETRANDOM, buf.as_mut_ptr(), buf.len(), flags) }) as ssize_t
+        // e(unsafe { syscall!(GETRANDOM, buf.as_mut_ptr(), buf.len(), flags) }) as ssize_t
+        unimplemented!()
     }
 
     unsafe fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int {
-        e(syscall!(GETRLIMIT, resource, rlim)) as c_int
+        // e(syscall!(GETRLIMIT, resource, rlim)) as c_int
+        unimplemented!()
     }
 
     fn getsid(pid: pid_t) -> pid_t {
-        e(unsafe { syscall!(GETSID, pid) }) as pid_t
+        // e(unsafe { syscall!(GETSID, pid) }) as pid_t
+        return 0;
     }
 
     fn gettid() -> pid_t {
-        e(unsafe { syscall!(GETTID) }) as pid_t
+        // e(unsafe { syscall!(GETTID) }) as pid_t
+        return Self::getpid();
     }
 
     fn gettimeofday(tp: *mut timeval, tzp: *mut timezone) -> c_int {
-        e(unsafe { syscall!(GETTIMEOFDAY, tp, tzp) }) as c_int
+        // e(unsafe { syscall!(GETTIMEOFDAY, tp, tzp) }) as c_int
+        unimplemented!()
     }
 
     fn getuid() -> uid_t {
-        e(unsafe { syscall!(GETUID) }) as uid_t
+        // e(unsafe { syscall!(GETUID) }) as uid_t
+        return 0;
     }
 
     fn lchown(path: &CStr, owner: uid_t, group: gid_t) -> c_int {
-        e(unsafe { syscall!(LCHOWN, path.as_ptr(), owner, group) }) as c_int
+        // e(unsafe { syscall!(LCHOWN, path.as_ptr(), owner, group) }) as c_int
+        return 0;
     }
 
     fn link(path1: &CStr, path2: &CStr) -> c_int {
-        e(unsafe {
-            syscall!(
-                LINKAT,
-                AT_FDCWD,
-                path1.as_ptr(),
-                AT_FDCWD,
-                path2.as_ptr(),
-                0
-            )
-        }) as c_int
+        // e(unsafe {
+        //     syscall!(
+        //         LINKAT,
+        //         AT_FDCWD,
+        //         path1.as_ptr(),
+        //         AT_FDCWD,
+        //         path2.as_ptr(),
+        //         0
+        //     )
+        // }) as c_int
+        unimplemented!()
     }
 
     fn lseek(fildes: c_int, offset: off_t, whence: c_int) -> off_t {
-        e(unsafe { syscall!(LSEEK, fildes, offset, whence) }) as off_t
+        e(unsafe { syscall!(SYS_LSEEK, fildes, offset, whence) }) as off_t
     }
 
     fn mkdir(path: &CStr, mode: mode_t) -> c_int {
-        e(unsafe { syscall!(MKDIRAT, AT_FDCWD, path.as_ptr(), mode) }) as c_int
+        // e(unsafe { syscall!(MKDIRAT, AT_FDCWD, path.as_ptr(), mode) }) as c_int
+        e(unsafe { syscall!(SYS_MKDIR, path.as_ptr(), mode) }) as c_int
     }
 
     fn mkfifo(path: &CStr, mode: mode_t) -> c_int {
-        e(unsafe { syscall!(MKNODAT, AT_FDCWD, path.as_ptr(), mode | S_IFIFO, 0) }) as c_int
+        // e(unsafe { syscall!(MKNODAT, AT_FDCWD, path.as_ptr(), mode | S_IFIFO, 0) }) as c_int
+        unimplemented!()
     }
 
     unsafe fn mlock(addr: *const c_void, len: usize) -> c_int {
-        e(syscall!(MLOCK, addr, len)) as c_int
+        // e(syscall!(MLOCK, addr, len)) as c_int
+        unimplemented!()
     }
 
     fn mlockall(flags: c_int) -> c_int {
-        e(unsafe { syscall!(MLOCKALL, flags) }) as c_int
+        // e(unsafe { syscall!(MLOCKALL, flags) }) as c_int
+        unimplemented!()
     }
 
     unsafe fn mmap(
@@ -329,160 +369,178 @@ impl Pal for Sys {
         fildes: c_int,
         off: off_t,
     ) -> *mut c_void {
-        e(syscall!(MMAP, addr, len, prot, flags, fildes, off)) as *mut c_void
+        // e(syscall!(MMAP, addr, len, prot, flags, fildes, off)) as *mut c_void
+        unimplemented!()
     }
 
     unsafe fn mprotect(addr: *mut c_void, len: usize, prot: c_int) -> c_int {
-        e(syscall!(MPROTECT, addr, len, prot)) as c_int
+        // e(syscall!(MPROTECT, addr, len, prot)) as c_int
+        unimplemented!()
     }
 
     unsafe fn msync(addr: *mut c_void, len: usize, flags: c_int) -> c_int {
-        e(syscall!(MSYNC, addr, len, flags)) as c_int
+        // e(syscall!(MSYNC, addr, len, flags)) as c_int
+        unimplemented!()
     }
 
     unsafe fn munlock(addr: *const c_void, len: usize) -> c_int {
-        e(syscall!(MUNLOCK, addr, len)) as c_int
+        // e(syscall!(MUNLOCK, addr, len)) as c_int
+        unimplemented!()
     }
 
     fn munlockall() -> c_int {
-        e(unsafe { syscall!(MUNLOCKALL) }) as c_int
+        // e(unsafe { syscall!(MUNLOCKALL) }) as c_int
+        unimplemented!()
     }
 
     unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int {
-        e(syscall!(MUNMAP, addr, len)) as c_int
+        // e(syscall!(MUNMAP, addr, len)) as c_int
+        unimplemented!()
     }
 
     fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int {
-        e(unsafe { syscall!(NANOSLEEP, rqtp, rmtp) }) as c_int
+        e(unsafe { syscall!(SYS_NANOSLEEP, rqtp, rmtp) }) as c_int
     }
 
     fn open(path: &CStr, oflag: c_int, mode: mode_t) -> c_int {
-        e(unsafe { syscall!(OPENAT, AT_FDCWD, path.as_ptr(), oflag, mode) }) as c_int
+        e(unsafe { syscall!(SYS_OPEN, path.as_ptr(), oflag, mode) }) as c_int
     }
 
     fn pipe2(fildes: &mut [c_int], flags: c_int) -> c_int {
-        e(unsafe { syscall!(PIPE2, fildes.as_mut_ptr(), flags) }) as c_int
+        // e(unsafe { syscall!(PIPE2, fildes.as_mut_ptr(), flags) }) as c_int
+        unimplemented!()
     }
 
     #[cfg(target_arch = "x86_64")]
     unsafe fn pte_clone(stack: *mut usize) -> pid_t {
-        let flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD;
-        let pid;
-        asm!("
-            # Call clone syscall
-            syscall
-
-            # Check if child or parent
-            test rax, rax
-            jnz 1f
-
-            # Load registers
-            pop rax
-            pop rdi
-            pop rsi
-            pop rdx
-            pop rcx
-            pop r8
-            pop r9
-
-            # Call entry point
-            call rax
-
-            # Exit
-            mov rax, 60
-            xor rdi, rdi
-            syscall
-
-            # Invalid instruction on failure to exit
-            ud2
-
-            # Return PID if parent
-            1:
-            ",
-            inout("rax") SYS_CLONE => pid,
-            inout("rdi") flags => _,
-            inout("rsi") stack => _,
-            inout("rdx") 0 => _,
-            inout("r10") 0 => _,
-            inout("r8") 0 => _,
-            //TODO: out("rbx") _,
-            out("rcx") _,
-            out("r9") _,
-            out("r11") _,
-            out("r12") _,
-            out("r13") _,
-            out("r14") _,
-            out("r15") _,
-        );
-        e(pid) as pid_t
+        unimplemented!()
+        // let flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD;
+        // let pid;
+        // asm!("
+        //     # Call clone syscall
+        //     syscall
+
+        //     # Check if child or parent
+        //     test rax, rax
+        //     jnz 1f
+
+        //     # Load registers
+        //     pop rax
+        //     pop rdi
+        //     pop rsi
+        //     pop rdx
+        //     pop rcx
+        //     pop r8
+        //     pop r9
+
+        //     # Call entry point
+        //     call rax
+
+        //     # Exit
+        //     mov rax, 60
+        //     xor rdi, rdi
+        //     syscall
+
+        //     # Invalid instruction on failure to exit
+        //     ud2
+
+        //     # Return PID if parent
+        //     1:
+        //     ",
+        //     inout("rax") SYS_CLONE => pid,
+        //     inout("rdi") flags => _,
+        //     inout("rsi") stack => _,
+        //     inout("rdx") 0 => _,
+        //     inout("r10") 0 => _,
+        //     inout("r8") 0 => _,
+        //     //TODO: out("rbx") _,
+        //     out("rcx") _,
+        //     out("r9") _,
+        //     out("r11") _,
+        //     out("r12") _,
+        //     out("r13") _,
+        //     out("r14") _,
+        //     out("r15") _,
+        // );
+        // e(pid) as pid_t
     }
 
     fn read(fildes: c_int, buf: &mut [u8]) -> ssize_t {
-        e(unsafe { syscall!(READ, fildes, buf.as_mut_ptr(), buf.len()) }) as ssize_t
+        e(unsafe { syscall!(SYS_READ, fildes, buf.as_mut_ptr(), buf.len()) }) as ssize_t
     }
 
     fn readlink(pathname: &CStr, out: &mut [u8]) -> ssize_t {
-        e(unsafe {
-            syscall!(
-                READLINKAT,
-                AT_FDCWD,
-                pathname.as_ptr(),
-                out.as_mut_ptr(),
-                out.len()
-            )
-        }) as ssize_t
+        unimplemented!()
+        // e(unsafe {
+        //     syscall!(
+        //         READLINKAT,
+        //         AT_FDCWD,
+        //         pathname.as_ptr(),
+        //         out.as_mut_ptr(),
+        //         out.len()
+        //     )
+        // }) as ssize_t
     }
 
     fn rename(old: &CStr, new: &CStr) -> c_int {
-        e(unsafe { syscall!(RENAMEAT, AT_FDCWD, old.as_ptr(), AT_FDCWD, new.as_ptr()) }) as c_int
+        // e(unsafe { syscall!(RENAMEAT, AT_FDCWD, old.as_ptr(), AT_FDCWD, new.as_ptr()) }) as c_int
+        unimplemented!()
     }
 
     fn rmdir(path: &CStr) -> c_int {
-        e(unsafe { syscall!(UNLINKAT, AT_FDCWD, path.as_ptr(), AT_REMOVEDIR) }) as c_int
+        e(unsafe { syscall!(SYS_UNLINK_AT, 0, path.as_ptr(), AT_REMOVEDIR) }) as c_int
     }
 
     fn sched_yield() -> c_int {
-        e(unsafe { syscall!(SCHED_YIELD) }) as c_int
+        // e(unsafe { syscall!(SCHED_YIELD) }) as c_int
+        unimplemented!()
     }
 
     fn setpgid(pid: pid_t, pgid: pid_t) -> c_int {
-        e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
+        // e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
+        unimplemented!()
     }
 
     fn setregid(rgid: gid_t, egid: gid_t) -> c_int {
-        e(unsafe { syscall!(SETREGID, rgid, egid) }) as c_int
+        // e(unsafe { syscall!(SETREGID, rgid, egid) }) as c_int
+        unimplemented!()
     }
 
     fn setreuid(ruid: uid_t, euid: uid_t) -> c_int {
-        e(unsafe { syscall!(SETREUID, ruid, euid) }) as c_int
+        // e(unsafe { syscall!(SETREUID, ruid, euid) }) as c_int
+        unimplemented!()
     }
 
     fn symlink(path1: &CStr, path2: &CStr) -> c_int {
-        e(unsafe { syscall!(SYMLINKAT, path1.as_ptr(), AT_FDCWD, path2.as_ptr()) }) as c_int
+        // e(unsafe { syscall!(SYMLINKAT, path1.as_ptr(), AT_FDCWD, path2.as_ptr()) }) as c_int
+        unimplemented!()
     }
 
     fn umask(mask: mode_t) -> mode_t {
-        unsafe { syscall!(UMASK, mask) as mode_t }
+        // unsafe { syscall!(UMASK, mask) as mode_t }
+        unimplemented!()
     }
 
     fn uname(utsname: *mut utsname) -> c_int {
-        e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
+        // e(unsafe { syscall!(UNAME, utsname, 0) }) as c_int
+        unimplemented!()
     }
 
     fn unlink(path: &CStr) -> c_int {
-        e(unsafe { syscall!(UNLINKAT, AT_FDCWD, path.as_ptr(), 0) }) as c_int
+        e(unsafe { syscall!(SYS_UNLINK_AT, AT_FDCWD, path.as_ptr(), 0) }) as c_int
     }
 
     fn waitpid(pid: pid_t, stat_loc: *mut c_int, options: c_int) -> pid_t {
-        e(unsafe { syscall!(WAIT4, pid, stat_loc, options, 0) }) as pid_t
+        e(unsafe { syscall!(SYS_WAIT4, pid, stat_loc, options, 0) }) as pid_t
     }
 
     fn write(fildes: c_int, buf: &[u8]) -> ssize_t {
-        e(unsafe { syscall!(WRITE, fildes, buf.as_ptr(), buf.len()) }) as ssize_t
+        e(unsafe { syscall!(SYS_WRITE, fildes, buf.as_ptr(), buf.len()) }) as ssize_t
     }
 
     fn verify() -> bool {
         // GETPID on Linux is 39, which does not exist on Redox
-        e(unsafe { dsc::syscall5(dsc::nr::GETPID, !0, !0, !0, !0, !0) }) != !0
+        // e(unsafe { dsc::syscall5(dsc::nr::GETPID, !0, !0, !0, !0, !0) }) != !0
+        unimplemented!()
     }
 }

+ 2 - 1
src/platform/dragonos/ptrace.rs

@@ -5,6 +5,7 @@ use super::{
 
 impl PalPtrace for Sys {
     fn ptrace(request: c_int, pid: pid_t, addr: *mut c_void, data: *mut c_void) -> c_int {
-        unsafe { e(syscall!(PTRACE, request, pid, addr, data)) as c_int }
+        // unsafe { e(syscall!(PTRACE, request, pid, addr, data)) as c_int }
+        unimplemented!()
     }
 }

+ 14 - 9
src/platform/dragonos/signal.rs

@@ -12,34 +12,37 @@ use crate::header::{
 
 impl PalSignal for Sys {
     fn getitimer(which: c_int, out: *mut itimerval) -> c_int {
-        e(unsafe { syscall!(GETITIMER, which, out) }) as c_int
+        // e(unsafe { syscall!(GETITIMER, which, out) }) as c_int
+        unimplemented!()
     }
 
     fn kill(pid: pid_t, sig: c_int) -> c_int {
-        e(unsafe { syscall!(KILL, pid, sig) }) as c_int
+        e(unsafe { syscall!(SYS_KILL, pid, sig) }) as c_int
     }
 
     fn killpg(pgrp: pid_t, sig: c_int) -> c_int {
-        e(unsafe { syscall!(KILL, -(pgrp as isize) as pid_t, sig) }) as c_int
+        e(unsafe { syscall!(SYS_KILL, -(pgrp as isize) as pid_t, sig) }) as c_int
     }
 
     fn raise(sig: c_int) -> c_int {
-        let tid = e(unsafe { syscall!(GETTID) }) as pid_t;
+        let tid = e(unsafe { syscall!(SYS_GETPID) }) as pid_t;
         if tid == !0 {
             -1
         } else {
-            e(unsafe { syscall!(TKILL, tid, sig) }) as c_int
+            // e(unsafe { syscall!(TKILL, tid, sig) }) as c_int
+            Self::kill(tid, sig)
         }
     }
 
     fn setitimer(which: c_int, new: *const itimerval, old: *mut itimerval) -> c_int {
-        e(unsafe { syscall!(SETITIMER, which, new, old) }) as c_int
+        // e(unsafe { syscall!(SETITIMER, which, new, old) }) as c_int
+        unimplemented!()
     }
 
     fn sigaction(sig: c_int, act: Option<&sigaction>, oact: Option<&mut sigaction>) -> c_int {
         e(unsafe {
             syscall!(
-                RT_SIGACTION,
+                SYS_SIGACTION,
                 sig,
                 act.map_or_else(core::ptr::null, |x| x as *const _),
                 oact.map_or_else(core::ptr::null_mut, |x| x as *mut _),
@@ -49,10 +52,12 @@ impl PalSignal for Sys {
     }
 
     fn sigaltstack(ss: *const stack_t, old_ss: *mut stack_t) -> c_int {
-        e(unsafe { syscall!(SIGALTSTACK, ss, old_ss) }) as c_int
+        // e(unsafe { syscall!(SIGALTSTACK, ss, old_ss) }) as c_int
+        unimplemented!()
     }
 
     fn sigprocmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int {
-        e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as c_int
+        // e(unsafe { syscall!(RT_SIGPROCMASK, how, set, oset, mem::size_of::<sigset_t>()) }) as c_int
+        unimplemented!()
     }
 }

+ 54 - 41
src/platform/dragonos/socket.rs

@@ -7,15 +7,18 @@ use crate::header::sys_socket::{sockaddr, socklen_t};
 
 impl PalSocket for Sys {
     unsafe fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int {
-        e(syscall!(ACCEPT, socket, address, address_len)) as c_int
+        // e(syscall!(ACCEPT, socket, address, address_len)) as c_int
+        unimplemented!()
     }
 
     unsafe fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int {
-        e(syscall!(BIND, socket, address, address_len)) as c_int
+        // e(syscall!(BIND, socket, address, address_len)) as c_int
+        unimplemented!()
     }
 
     unsafe fn connect(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int {
-        e(syscall!(CONNECT, socket, address, address_len)) as c_int
+        // e(syscall!(CONNECT, socket, address, address_len)) as c_int
+        unimplemented!()
     }
 
     unsafe fn getpeername(
@@ -23,7 +26,8 @@ impl PalSocket for Sys {
         address: *mut sockaddr,
         address_len: *mut socklen_t,
     ) -> c_int {
-        e(syscall!(GETPEERNAME, socket, address, address_len)) as c_int
+        // e(syscall!(GETPEERNAME, socket, address, address_len)) as c_int
+        unimplemented!()
     }
 
     unsafe fn getsockname(
@@ -31,7 +35,8 @@ impl PalSocket for Sys {
         address: *mut sockaddr,
         address_len: *mut socklen_t,
     ) -> c_int {
-        e(syscall!(GETSOCKNAME, socket, address, address_len)) as c_int
+        // e(syscall!(GETSOCKNAME, socket, address, address_len)) as c_int
+        unimplemented!()
     }
 
     fn getsockopt(
@@ -41,20 +46,22 @@ impl PalSocket for Sys {
         option_value: *mut c_void,
         option_len: *mut socklen_t,
     ) -> c_int {
-        e(unsafe {
-            syscall!(
-                GETSOCKOPT,
-                socket,
-                level,
-                option_name,
-                option_value,
-                option_len
-            )
-        }) as c_int
+        unimplemented!()
+        // e(unsafe {
+        //     syscall!(
+        //         GETSOCKOPT,
+        //         socket,
+        //         level,
+        //         option_name,
+        //         option_value,
+        //         option_len
+        //     )
+        // }) as c_int
     }
 
     fn listen(socket: c_int, backlog: c_int) -> c_int {
-        e(unsafe { syscall!(LISTEN, socket, backlog) }) as c_int
+        // e(unsafe { syscall!(LISTEN, socket, backlog) }) as c_int
+        unimplemented!()
     }
 
     unsafe fn recvfrom(
@@ -65,15 +72,16 @@ impl PalSocket for Sys {
         address: *mut sockaddr,
         address_len: *mut socklen_t,
     ) -> ssize_t {
-        e(syscall!(
-            RECVFROM,
-            socket,
-            buf,
-            len,
-            flags,
-            address,
-            address_len
-        )) as ssize_t
+        // e(syscall!(
+        //     RECVFROM,
+        //     socket,
+        //     buf,
+        //     len,
+        //     flags,
+        //     address,
+        //     address_len
+        // )) as ssize_t
+        unimplemented!()
     }
 
     unsafe fn sendto(
@@ -84,9 +92,10 @@ impl PalSocket for Sys {
         dest_addr: *const sockaddr,
         dest_len: socklen_t,
     ) -> ssize_t {
-        e(syscall!(
-            SENDTO, socket, buf, len, flags, dest_addr, dest_len
-        )) as ssize_t
+        // e(syscall!(
+        //     SENDTO, socket, buf, len, flags, dest_addr, dest_len
+        // )) as ssize_t
+        unimplemented!()
     }
 
     fn setsockopt(
@@ -96,27 +105,31 @@ impl PalSocket for Sys {
         option_value: *const c_void,
         option_len: socklen_t,
     ) -> c_int {
-        e(unsafe {
-            syscall!(
-                SETSOCKOPT,
-                socket,
-                level,
-                option_name,
-                option_value,
-                option_len
-            )
-        }) as c_int
+        // e(unsafe {
+        //     syscall!(
+        //         SETSOCKOPT,
+        //         socket,
+        //         level,
+        //         option_name,
+        //         option_value,
+        //         option_len
+        //     )
+        // }) as c_int
+        unimplemented!()
     }
 
     fn shutdown(socket: c_int, how: c_int) -> c_int {
-        e(unsafe { syscall!(SHUTDOWN, socket, how) }) as c_int
+        // e(unsafe { syscall!(SHUTDOWN, socket, how) }) as c_int
+        unimplemented!()
     }
 
     unsafe fn socket(domain: c_int, kind: c_int, protocol: c_int) -> c_int {
-        e(syscall!(SOCKET, domain, kind, protocol)) as c_int
+        // e(syscall!(SOCKET, domain, kind, protocol)) as c_int
+        unimplemented!()
     }
 
     fn socketpair(domain: c_int, kind: c_int, protocol: c_int, sv: &mut [c_int; 2]) -> c_int {
-        e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, sv.as_mut_ptr()) }) as c_int
+        // e(unsafe { syscall!(SOCKETPAIR, domain, kind, protocol, sv.as_mut_ptr()) }) as c_int
+        unimplemented!()
     }
 }