the big error refactor

This commit is contained in:
nora 2023-10-03 21:39:32 +02:00
parent 5057c0f977
commit 3829dddcea
19 changed files with 1027 additions and 456 deletions

View file

@ -26,7 +26,7 @@ fn init() {
let prot_read = 1;
let prod_write = 2;
let start = mmap_sys(
let start = sys_mmap(
core::ptr::null(),
HEAP_SIZE,
prot_read | prod_write,
@ -85,7 +85,7 @@ pub unsafe fn free(ptr: *mut u8) {
}
#[cfg_attr(miri, allow(unused_variables, unreachable_code))]
pub unsafe fn mmap_sys(
pub unsafe fn sys_mmap(
addr: *const u8,
size: usize,
prot: c_int,

View file

@ -1,84 +0,0 @@
use core::{cell::UnsafeCell, ptr::addr_of};
use crate::utils::SyncUnsafeCell;
// Todo: This should be a thread local once we have threads.
static ERRNO: SyncUnsafeCell<i32> = SyncUnsafeCell(UnsafeCell::new(0));
pub fn errno_location() -> *const i32 {
addr_of!(ERRNO).cast()
}
pub fn errno() -> i32 {
unsafe { *ERRNO.0.get() }
}
pub fn set_errno(errno: i32) {
unsafe { ERRNO.0.get().write(errno) }
}
pub trait IntoOkOrErrno {
type Int: ReturnInt;
fn into_ok_or_errno(self) -> Self::Int;
}
impl<T: ReturnInt> IntoOkOrErrno for Result<T, i32> {
type Int = T;
fn into_ok_or_errno(self) -> Self::Int {
self.unwrap_or_else(|err| {
set_errno(err);
T::negative_one()
})
}
}
pub trait ReturnInt {
fn negative_one() -> Self;
}
macro_rules! return_int_impl_s {
($($ty:ty)*) => {
$(impl ReturnInt for $ty {
fn negative_one() -> Self {
-1
}
})*
};
}
return_int_impl_s!(i8 i16 i32 i64 isize);
pub const EPERM: i32 = 1; /* Operation not permitted */
pub const ENOENT: i32 = 2; /* No such file or directory */
pub const ESRCH: i32 = 3; /* No such process */
pub const EINTR: i32 = 4; /* Interrupted system call */
pub const EIO: i32 = 5; /* I/O error */
pub const ENXIO: i32 = 6; /* No such device or address */
pub const E2BIG: i32 = 7; /* Argument list too long */
pub const ENOEXEC: i32 = 8; /* Exec format error */
pub const EBADF: i32 = 9; /* Bad file number */
pub const ECHILD: i32 = 10; /* No child processes */
pub const EAGAIN: i32 = 11; /* Try again */
pub const ENOMEM: i32 = 12; /* Out of memory */
pub const EACCES: i32 = 13; /* Permission denied */
pub const EFAULT: i32 = 14; /* Bad address */
pub const ENOTBLK: i32 = 15; /* Block device required */
pub const EBUSY: i32 = 16; /* Device or resource busy */
pub const EEXIST: i32 = 17; /* File exists */
pub const EXDEV: i32 = 18; /* Cross-device link */
pub const ENODEV: i32 = 19; /* No such device */
pub const ENOTDIR: i32 = 20; /* Not a directory */
pub const EISDIR: i32 = 21; /* Is a directory */
pub const EINVAL: i32 = 22; /* Invalid argument */
pub const ENFILE: i32 = 23; /* File table overflow */
pub const EMFILE: i32 = 24; /* Too many open files */
pub const ENOTTY: i32 = 25; /* Not a typewriter */
pub const ETXTBSY: i32 = 26; /* Text file busy */
pub const EFBIG: i32 = 27; /* File too large */
pub const ENOSPC: i32 = 28; /* No space left on device */
pub const ESPIPE: i32 = 29; /* Illegal seek */
pub const EROFS: i32 = 30; /* Read-only file system */
pub const EMLINK: i32 = 31; /* Too many links */
pub const EPIPE: i32 = 32; /* Broken pipe */
pub const EDOM: i32 = 33; /* Math argument out of domain of func */
pub const ERANGE: i32 = 34; /* Math result not representable */

412
libuwuc/src/error/errno.rs Normal file
View file

@ -0,0 +1,412 @@
/* modified by hand to add the Error impls and make them i32! */
/* automatically generated by rust-bindgen 0.66.1 */
/* bindgen /nix/store/y8wfrgk7br5rfz4221lfb9v8w3n0cnyd-glibc-2.37-8-dev/include/bits/errno.h -- -D_ERRNO_H > errno.rs */
pub const EPERM: i32 = 1;
pub const ENOENT: i32 = 2;
pub const ESRCH: i32 = 3;
pub const EINTR: i32 = 4;
pub const EIO: i32 = 5;
pub const ENXIO: i32 = 6;
pub const E2BIG: i32 = 7;
pub const ENOEXEC: i32 = 8;
pub const EBADF: i32 = 9;
pub const ECHILD: i32 = 10;
pub const EAGAIN: i32 = 11;
pub const ENOMEM: i32 = 12;
pub const EACCES: i32 = 13;
pub const EFAULT: i32 = 14;
pub const ENOTBLK: i32 = 15;
pub const EBUSY: i32 = 16;
pub const EEXIST: i32 = 17;
pub const EXDEV: i32 = 18;
pub const ENODEV: i32 = 19;
pub const ENOTDIR: i32 = 20;
pub const EISDIR: i32 = 21;
pub const EINVAL: i32 = 22;
pub const ENFILE: i32 = 23;
pub const EMFILE: i32 = 24;
pub const ENOTTY: i32 = 25;
pub const ETXTBSY: i32 = 26;
pub const EFBIG: i32 = 27;
pub const ENOSPC: i32 = 28;
pub const ESPIPE: i32 = 29;
pub const EROFS: i32 = 30;
pub const EMLINK: i32 = 31;
pub const EPIPE: i32 = 32;
pub const EDOM: i32 = 33;
pub const ERANGE: i32 = 34;
pub const EDEADLK: i32 = 35;
pub const ENAMETOOLONG: i32 = 36;
pub const ENOLCK: i32 = 37;
pub const ENOSYS: i32 = 38;
pub const ENOTEMPTY: i32 = 39;
pub const ELOOP: i32 = 40;
pub const EWOULDBLOCK: i32 = 11;
pub const ENOMSG: i32 = 42;
pub const EIDRM: i32 = 43;
pub const ECHRNG: i32 = 44;
pub const EL2NSYNC: i32 = 45;
pub const EL3HLT: i32 = 46;
pub const EL3RST: i32 = 47;
pub const ELNRNG: i32 = 48;
pub const EUNATCH: i32 = 49;
pub const ENOCSI: i32 = 50;
pub const EL2HLT: i32 = 51;
pub const EBADE: i32 = 52;
pub const EBADR: i32 = 53;
pub const EXFULL: i32 = 54;
pub const ENOANO: i32 = 55;
pub const EBADRQC: i32 = 56;
pub const EBADSLT: i32 = 57;
pub const EDEADLOCK: i32 = 35;
pub const EBFONT: i32 = 59;
pub const ENOSTR: i32 = 60;
pub const ENODATA: i32 = 61;
pub const ETIME: i32 = 62;
pub const ENOSR: i32 = 63;
pub const ENONET: i32 = 64;
pub const ENOPKG: i32 = 65;
pub const EREMOTE: i32 = 66;
pub const ENOLINK: i32 = 67;
pub const EADV: i32 = 68;
pub const ESRMNT: i32 = 69;
pub const ECOMM: i32 = 70;
pub const EPROTO: i32 = 71;
pub const EMULTIHOP: i32 = 72;
pub const EDOTDOT: i32 = 73;
pub const EBADMSG: i32 = 74;
pub const EOVERFLOW: i32 = 75;
pub const ENOTUNIQ: i32 = 76;
pub const EBADFD: i32 = 77;
pub const EREMCHG: i32 = 78;
pub const ELIBACC: i32 = 79;
pub const ELIBBAD: i32 = 80;
pub const ELIBSCN: i32 = 81;
pub const ELIBMAX: i32 = 82;
pub const ELIBEXEC: i32 = 83;
pub const EILSEQ: i32 = 84;
pub const ERESTART: i32 = 85;
pub const ESTRPIPE: i32 = 86;
pub const EUSERS: i32 = 87;
pub const ENOTSOCK: i32 = 88;
pub const EDESTADDRREQ: i32 = 89;
pub const EMSGSIZE: i32 = 90;
pub const EPROTOTYPE: i32 = 91;
pub const ENOPROTOOPT: i32 = 92;
pub const EPROTONOSUPPORT: i32 = 93;
pub const ESOCKTNOSUPPORT: i32 = 94;
pub const EOPNOTSUPP: i32 = 95;
pub const EPFNOSUPPORT: i32 = 96;
pub const EAFNOSUPPORT: i32 = 97;
pub const EADDRINUSE: i32 = 98;
pub const EADDRNOTAVAIL: i32 = 99;
pub const ENETDOWN: i32 = 100;
pub const ENETUNREACH: i32 = 101;
pub const ENETRESET: i32 = 102;
pub const ECONNABORTED: i32 = 103;
pub const ECONNRESET: i32 = 104;
pub const ENOBUFS: i32 = 105;
pub const EISCONN: i32 = 106;
pub const ENOTCONN: i32 = 107;
pub const ESHUTDOWN: i32 = 108;
pub const ETOOMANYREFS: i32 = 109;
pub const ETIMEDOUT: i32 = 110;
pub const ECONNREFUSED: i32 = 111;
pub const EHOSTDOWN: i32 = 112;
pub const EHOSTUNREACH: i32 = 113;
pub const EALREADY: i32 = 114;
pub const EINPROGRESS: i32 = 115;
pub const ESTALE: i32 = 116;
pub const EUCLEAN: i32 = 117;
pub const ENOTNAM: i32 = 118;
pub const ENAVAIL: i32 = 119;
pub const EISNAM: i32 = 120;
pub const EREMOTEIO: i32 = 121;
pub const EDQUOT: i32 = 122;
pub const ENOMEDIUM: i32 = 123;
pub const EMEDIUMTYPE: i32 = 124;
pub const ECANCELED: i32 = 125;
pub const ENOKEY: i32 = 126;
pub const EKEYEXPIRED: i32 = 127;
pub const EKEYREVOKED: i32 = 128;
pub const EKEYREJECTED: i32 = 129;
pub const EOWNERDEAD: i32 = 130;
pub const ENOTRECOVERABLE: i32 = 131;
pub const ERFKILL: i32 = 132;
pub const EHWPOISON: i32 = 133;
pub const ENOTSUP: i32 = 95;
impl super::Error {
pub const PERM: Self = Self(EPERM);
pub const NOENT: Self = Self(ENOENT);
pub const SRCH: Self = Self(ESRCH);
pub const INTR: Self = Self(EINTR);
pub const IO: Self = Self(EIO);
pub const NXIO: Self = Self(ENXIO);
pub const E2BIG: Self = Self(E2BIG);
pub const NOEXEC: Self = Self(ENOEXEC);
pub const BADF: Self = Self(EBADF);
pub const CHILD: Self = Self(ECHILD);
pub const AGAIN: Self = Self(EAGAIN);
pub const NOMEM: Self = Self(ENOMEM);
pub const ACCES: Self = Self(EACCES);
pub const FAULT: Self = Self(EFAULT);
pub const NOTBLK: Self = Self(ENOTBLK);
pub const BUSY: Self = Self(EBUSY);
pub const EXIST: Self = Self(EEXIST);
pub const XDEV: Self = Self(EXDEV);
pub const NODEV: Self = Self(ENODEV);
pub const NOTDIR: Self = Self(ENOTDIR);
pub const ISDIR: Self = Self(EISDIR);
pub const INVAL: Self = Self(EINVAL);
pub const NFILE: Self = Self(ENFILE);
pub const MFILE: Self = Self(EMFILE);
pub const NOTTY: Self = Self(ENOTTY);
pub const TXTBSY: Self = Self(ETXTBSY);
pub const FBIG: Self = Self(EFBIG);
pub const NOSPC: Self = Self(ENOSPC);
pub const SPIPE: Self = Self(ESPIPE);
pub const ROFS: Self = Self(EROFS);
pub const MLINK: Self = Self(EMLINK);
pub const PIPE: Self = Self(EPIPE);
pub const DOM: Self = Self(EDOM);
pub const RANGE: Self = Self(ERANGE);
pub const DEADLK: Self = Self(EDEADLK);
pub const NAMETOOLONG: Self = Self(ENAMETOOLONG);
pub const NOLCK: Self = Self(ENOLCK);
pub const NOSYS: Self = Self(ENOSYS);
pub const NOTEMPTY: Self = Self(ENOTEMPTY);
pub const LOOP: Self = Self(ELOOP);
pub const WOULDBLOCK: Self = Self(EWOULDBLOCK);
pub const NOMSG: Self = Self(ENOMSG);
pub const IDRM: Self = Self(EIDRM);
pub const CHRNG: Self = Self(ECHRNG);
pub const L2NSYNC: Self = Self(EL2NSYNC);
pub const L3HLT: Self = Self(EL3HLT);
pub const L3RST: Self = Self(EL3RST);
pub const LNRNG: Self = Self(ELNRNG);
pub const UNATCH: Self = Self(EUNATCH);
pub const NOCSI: Self = Self(ENOCSI);
pub const L2HLT: Self = Self(EL2HLT);
pub const BADE: Self = Self(EBADE);
pub const BADR: Self = Self(EBADR);
pub const XFULL: Self = Self(EXFULL);
pub const NOANO: Self = Self(ENOANO);
pub const BADRQC: Self = Self(EBADRQC);
pub const BADSLT: Self = Self(EBADSLT);
pub const DEADLOCK: Self = Self(EDEADLOCK);
pub const BFONT: Self = Self(EBFONT);
pub const NOSTR: Self = Self(ENOSTR);
pub const NODATA: Self = Self(ENODATA);
pub const TIME: Self = Self(ETIME);
pub const NOSR: Self = Self(ENOSR);
pub const NONET: Self = Self(ENONET);
pub const NOPKG: Self = Self(ENOPKG);
pub const REMOTE: Self = Self(EREMOTE);
pub const NOLINK: Self = Self(ENOLINK);
pub const ADV: Self = Self(EADV);
pub const SRMNT: Self = Self(ESRMNT);
pub const COMM: Self = Self(ECOMM);
pub const PROTO: Self = Self(EPROTO);
pub const MULTIHOP: Self = Self(EMULTIHOP);
pub const DOTDOT: Self = Self(EDOTDOT);
pub const BADMSG: Self = Self(EBADMSG);
pub const OVERFLOW: Self = Self(EOVERFLOW);
pub const NOTUNIQ: Self = Self(ENOTUNIQ);
pub const BADFD: Self = Self(EBADFD);
pub const REMCHG: Self = Self(EREMCHG);
pub const LIBACC: Self = Self(ELIBACC);
pub const LIBBAD: Self = Self(ELIBBAD);
pub const LIBSCN: Self = Self(ELIBSCN);
pub const LIBMAX: Self = Self(ELIBMAX);
pub const LIBEXEC: Self = Self(ELIBEXEC);
pub const ILSEQ: Self = Self(EILSEQ);
pub const RESTART: Self = Self(ERESTART);
pub const STRPIPE: Self = Self(ESTRPIPE);
pub const USERS: Self = Self(EUSERS);
pub const NOTSOCK: Self = Self(ENOTSOCK);
pub const DESTADDRREQ: Self = Self(EDESTADDRREQ);
pub const MSGSIZE: Self = Self(EMSGSIZE);
pub const PROTOTYPE: Self = Self(EPROTOTYPE);
pub const NOPROTOOPT: Self = Self(ENOPROTOOPT);
pub const PROTONOSUPPORT: Self = Self(EPROTONOSUPPORT);
pub const SOCKTNOSUPPORT: Self = Self(ESOCKTNOSUPPORT);
pub const OPNOTSUPP: Self = Self(EOPNOTSUPP);
pub const PFNOSUPPORT: Self = Self(EPFNOSUPPORT);
pub const AFNOSUPPORT: Self = Self(EAFNOSUPPORT);
pub const ADDRINUSE: Self = Self(EADDRINUSE);
pub const ADDRNOTAVAIL: Self = Self(EADDRNOTAVAIL);
pub const NETDOWN: Self = Self(ENETDOWN);
pub const NETUNREACH: Self = Self(ENETUNREACH);
pub const NETRESET: Self = Self(ENETRESET);
pub const CONNABORTED: Self = Self(ECONNABORTED);
pub const CONNRESET: Self = Self(ECONNRESET);
pub const NOBUFS: Self = Self(ENOBUFS);
pub const ISCONN: Self = Self(EISCONN);
pub const NOTCONN: Self = Self(ENOTCONN);
pub const SHUTDOWN: Self = Self(ESHUTDOWN);
pub const TOOMANYREFS: Self = Self(ETOOMANYREFS);
pub const TIMEDOUT: Self = Self(ETIMEDOUT);
pub const CONNREFUSED: Self = Self(ECONNREFUSED);
pub const HOSTDOWN: Self = Self(EHOSTDOWN);
pub const HOSTUNREACH: Self = Self(EHOSTUNREACH);
pub const ALREADY: Self = Self(EALREADY);
pub const INPROGRESS: Self = Self(EINPROGRESS);
pub const STALE: Self = Self(ESTALE);
pub const UCLEAN: Self = Self(EUCLEAN);
pub const NOTNAM: Self = Self(ENOTNAM);
pub const NAVAIL: Self = Self(ENAVAIL);
pub const ISNAM: Self = Self(EISNAM);
pub const REMOTEIO: Self = Self(EREMOTEIO);
pub const DQUOT: Self = Self(EDQUOT);
pub const NOMEDIUM: Self = Self(ENOMEDIUM);
pub const MEDIUMTYPE: Self = Self(EMEDIUMTYPE);
pub const CANCELED: Self = Self(ECANCELED);
pub const NOKEY: Self = Self(ENOKEY);
pub const KEYEXPIRED: Self = Self(EKEYEXPIRED);
pub const KEYREVOKED: Self = Self(EKEYREVOKED);
pub const KEYREJECTED: Self = Self(EKEYREJECTED);
pub const OWNERDEAD: Self = Self(EOWNERDEAD);
pub const NOTRECOVERABLE: Self = Self(ENOTRECOVERABLE);
pub const RFKILL: Self = Self(ERFKILL);
pub const HWPOISON: Self = Self(EHWPOISON);
pub const NOTSUP: Self = Self(ENOTSUP);
pub fn simple_str(self) -> &'static str {
match self {
Self::PERM => "EPERM",
Self::NOENT => "ENOENT",
Self::SRCH => "ESRCH",
Self::INTR => "EINTR",
Self::IO => "EIO",
Self::NXIO => "ENXIO",
Self::E2BIG => "E2BIG",
Self::NOEXEC => "ENOEXEC",
Self::BADF => "EBADF",
Self::CHILD => "ECHILD",
Self::AGAIN => "EAGAIN",
Self::NOMEM => "ENOMEM",
Self::ACCES => "EACCES",
Self::FAULT => "EFAULT",
Self::NOTBLK => "ENOTBLK",
Self::BUSY => "EBUSY",
Self::EXIST => "EEXIST",
Self::XDEV => "EXDEV",
Self::NODEV => "ENODEV",
Self::NOTDIR => "ENOTDIR",
Self::ISDIR => "EISDIR",
Self::INVAL => "EINVAL",
Self::NFILE => "ENFILE",
Self::MFILE => "EMFILE",
Self::NOTTY => "ENOTTY",
Self::TXTBSY => "ETXTBSY",
Self::FBIG => "EFBIG",
Self::NOSPC => "ENOSPC",
Self::SPIPE => "ESPIPE",
Self::ROFS => "EROFS",
Self::MLINK => "EMLINK",
Self::PIPE => "EPIPE",
Self::DOM => "EDOM",
Self::RANGE => "ERANGE",
Self::DEADLK => "EDEADLK",
Self::NAMETOOLONG => "ENAMETOOLONG",
Self::NOLCK => "ENOLCK",
Self::NOSYS => "ENOSYS",
Self::NOTEMPTY => "ENOTEMPTY",
Self::LOOP => "ELOOP",
Self::NOMSG => "ENOMSG",
Self::IDRM => "EIDRM",
Self::CHRNG => "ECHRNG",
Self::L2NSYNC => "EL2NSYNC",
Self::L3HLT => "EL3HLT",
Self::L3RST => "EL3RST",
Self::LNRNG => "ELNRNG",
Self::UNATCH => "EUNATCH",
Self::NOCSI => "ENOCSI",
Self::L2HLT => "EL2HLT",
Self::BADE => "EBADE",
Self::BADR => "EBADR",
Self::XFULL => "EXFULL",
Self::NOANO => "ENOANO",
Self::BADRQC => "EBADRQC",
Self::BADSLT => "EBADSLT",
Self::BFONT => "EBFONT",
Self::NOSTR => "ENOSTR",
Self::NODATA => "ENODATA",
Self::TIME => "ETIME",
Self::NOSR => "ENOSR",
Self::NONET => "ENONET",
Self::NOPKG => "ENOPKG",
Self::REMOTE => "EREMOTE",
Self::NOLINK => "ENOLINK",
Self::ADV => "EADV",
Self::SRMNT => "ESRMNT",
Self::COMM => "ECOMM",
Self::PROTO => "EPROTO",
Self::MULTIHOP => "EMULTIHOP",
Self::DOTDOT => "EDOTDOT",
Self::BADMSG => "EBADMSG",
Self::OVERFLOW => "EOVERFLOW",
Self::NOTUNIQ => "ENOTUNIQ",
Self::BADFD => "EBADFD",
Self::REMCHG => "EREMCHG",
Self::LIBACC => "ELIBACC",
Self::LIBBAD => "ELIBBAD",
Self::LIBSCN => "ELIBSCN",
Self::LIBMAX => "ELIBMAX",
Self::LIBEXEC => "ELIBEXEC",
Self::ILSEQ => "EILSEQ",
Self::RESTART => "ERESTART",
Self::STRPIPE => "ESTRPIPE",
Self::USERS => "EUSERS",
Self::NOTSOCK => "ENOTSOCK",
Self::DESTADDRREQ => "EDESTADDRREQ",
Self::MSGSIZE => "EMSGSIZE",
Self::PROTOTYPE => "EPROTOTYPE",
Self::NOPROTOOPT => "ENOPROTOOPT",
Self::PROTONOSUPPORT => "EPROTONOSUPPORT",
Self::SOCKTNOSUPPORT => "ESOCKTNOSUPPORT",
Self::OPNOTSUPP => "EOPNOTSUPP",
Self::PFNOSUPPORT => "EPFNOSUPPORT",
Self::AFNOSUPPORT => "EAFNOSUPPORT",
Self::ADDRINUSE => "EADDRINUSE",
Self::ADDRNOTAVAIL => "EADDRNOTAVAIL",
Self::NETDOWN => "ENETDOWN",
Self::NETUNREACH => "ENETUNREACH",
Self::NETRESET => "ENETRESET",
Self::CONNABORTED => "ECONNABORTED",
Self::CONNRESET => "ECONNRESET",
Self::NOBUFS => "ENOBUFS",
Self::ISCONN => "EISCONN",
Self::NOTCONN => "ENOTCONN",
Self::SHUTDOWN => "ESHUTDOWN",
Self::TOOMANYREFS => "ETOOMANYREFS",
Self::TIMEDOUT => "ETIMEDOUT",
Self::CONNREFUSED => "ECONNREFUSED",
Self::HOSTDOWN => "EHOSTDOWN",
Self::HOSTUNREACH => "EHOSTUNREACH",
Self::ALREADY => "EALREADY",
Self::INPROGRESS => "EINPROGRESS",
Self::STALE => "ESTALE",
Self::UCLEAN => "EUCLEAN",
Self::NOTNAM => "ENOTNAM",
Self::NAVAIL => "ENAVAIL",
Self::ISNAM => "EISNAM",
Self::REMOTEIO => "EREMOTEIO",
Self::DQUOT => "EDQUOT",
Self::NOMEDIUM => "ENOMEDIUM",
Self::MEDIUMTYPE => "EMEDIUMTYPE",
Self::CANCELED => "ECANCELED",
Self::NOKEY => "ENOKEY",
Self::KEYEXPIRED => "EKEYEXPIRED",
Self::KEYREVOKED => "EKEYREVOKED",
Self::KEYREJECTED => "EKEYREJECTED",
Self::OWNERDEAD => "EOWNERDEAD",
Self::NOTRECOVERABLE => "ENOTRECOVERABLE",
Self::RFKILL => "ERFKILL",
Self::HWPOISON => "EHWPOISON",
_ => "<invalid error>",
}
}
}

67
libuwuc/src/error/mod.rs Normal file
View file

@ -0,0 +1,67 @@
use core::{cell::UnsafeCell, fmt::Debug, ptr::addr_of};
use crate::{io::fd::Fd, utils::SyncUnsafeCell};
mod errno;
pub use errno::*;
// Todo: This should be a thread local once we have threads.
static ERRNO: SyncUnsafeCell<i32> = SyncUnsafeCell(UnsafeCell::new(0));
pub fn errno_location() -> *const i32 {
addr_of!(ERRNO).cast()
}
pub fn errno() -> i32 {
unsafe { *ERRNO.0.get() }
}
pub fn set_errno(errno: i32) {
unsafe { ERRNO.0.get().write(errno) }
}
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Error(pub i32);
impl Debug for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(self.simple_str())
}
}
pub trait IntoOkOrErrno {
type Int: ReturnInt;
fn into_ok_or_errno(self) -> Self::Int;
}
impl<T: ReturnInt> IntoOkOrErrno for Result<T, Error> {
type Int = T;
fn into_ok_or_errno(self) -> Self::Int {
self.unwrap_or_else(|err| {
set_errno(err.0);
T::negative_one()
})
}
}
pub trait ReturnInt {
fn negative_one() -> Self;
}
macro_rules! return_int_impl_s {
($($ty:ty)*) => {
$(impl ReturnInt for $ty {
fn negative_one() -> Self {
-1
}
})*
};
}
return_int_impl_s!(i8 i16 i32 i64 isize);
impl ReturnInt for Fd {
fn negative_one() -> Self {
Self(-1)
}
}

View file

@ -1,15 +1,12 @@
use core::ffi::{c_int, c_long};
use crate::{
error::{set_errno, EINVAL},
utils::SharedThinCstr,
};
use crate::{error::Error, utils::SharedThinCstr};
pub fn parse_long<'a>(
str: SharedThinCstr<'a>,
endptr: Option<&mut Option<SharedThinCstr<'a>>>,
base: c_int,
) -> c_long {
) -> Result<c_long, Error> {
if base != 10 {
todo!();
}
@ -47,13 +44,11 @@ pub fn parse_long<'a>(
}
Some((_, c)) if !c.is_ascii_digit() => {
write_end(0);
set_errno(EINVAL);
return 0;
return Err(Error::INVAL);
}
None => {
write_end(0);
set_errno(EINVAL);
return 0;
return Err(Error::INVAL);
}
Some((pos, _)) => {
last_pos = *pos;
@ -83,7 +78,7 @@ pub fn parse_long<'a>(
}
}
acc
Ok(acc)
}
#[cfg(test)]
@ -92,7 +87,7 @@ mod tests {
fn test_strtol(str: SharedThinCstr<'_>, expected: i64, base: i32, parsed_len: usize) {
let mut end = None;
let result = super::parse_long(str, Some(&mut end), base);
let result = super::parse_long(str, Some(&mut end), base).unwrap();
assert_eq!(result, expected);
let end = end.unwrap();
let read = end.as_raw() as usize - str.as_raw() as usize;

View file

@ -1,18 +1,18 @@
use core::ffi::VaList;
use crate::{io::IoWrite, utils::SharedThinCstr};
use crate::{io::IoWrite, utils::SharedThinCstr, error::Error};
pub unsafe fn printf_generic(
mut sink: impl IoWrite,
format: SharedThinCstr<'_>,
mut args: VaList<'_, '_>,
) -> Result<(), i32> {
) -> Result<(), Error> {
let mut chars = format.into_iter();
while let Some(c) = chars.next() {
if c == b'%' {
let Some(c) = chars.next() else {
return Err(-1);
return Err(Error::INVAL);
};
// todo: do this properly
match c {
@ -22,7 +22,7 @@ pub unsafe fn printf_generic(
}
b'l' => {
let Some(c) = chars.next() else {
return Err(-1);
return Err(Error::INVAL);
};
if c != b'd' {
todo!();

33
libuwuc/src/io/fd.rs Normal file
View file

@ -0,0 +1,33 @@
use crate::{utils::SharedThinCstr, println, error::Error};
#[repr(transparent)]
pub struct Fd(pub i32);
pub fn open(arg: SharedThinCstr<'_>, flags: i32) -> Result<Fd, Error> {
sys_open(arg, flags)
}
pub fn sys_open(arg: SharedThinCstr<'_>, flags: i32) -> Result<Fd, Error> {
let fd = unsafe { crate::syscall::syscall!(crate::syscall::SYS_OPEN, arg.as_raw(), flags) };
if fd < 0 {
println!("fd: {fd}");
}
todo!()
}
pub const O_ACCMODE: i32 = 0o0003;
pub const O_RDONLY: i32 = 0o00;
pub const O_WRONLY: i32 = 0o01;
pub const O_RDWR: i32 = 0o02;
pub const O_CREAT: i32 = 0o0100; /* Not fcntl. */
pub const O_EXCL: i32 = 0o0200; /* Not fcntl. */
pub const O_NOCTTY: i32 = 0o0400; /* Not fcntl. */
pub const O_TRUNC: i32 = 0o01000; /* Not fcntl. */
pub const O_APPEND: i32 = 0o02000;
pub const O_NONBLOCK: i32 = 0o04000;
pub const O_NDELAY: i32 = O_NONBLOCK;
pub const O_SYNC: i32 = 0o04010000;
pub const O_FSYNC: i32 = O_SYNC;
pub const O_ASYNC: i32 = 0o020000;

View file

@ -1,3 +1,4 @@
pub mod fd;
pub mod stream;
pub mod traits;
@ -5,7 +6,7 @@ pub use traits::IoWrite;
use core::ffi::c_char;
use crate::sys::syscall;
use crate::{error::Error, sys::syscall};
pub const STDIN: i32 = 0;
pub const STDOUT: i32 = 1;
@ -33,18 +34,18 @@ macro_rules! println {
}
pub use println;
pub unsafe fn write(fd: i32, buf: &[u8]) -> Result<usize, i32> {
pub unsafe fn sys_write(fd: i32, buf: &[u8]) -> Result<usize, Error> {
let result = syscall::syscall!(syscall::SYS_WRITE, fd, buf.as_ptr(), buf.len()) as i64;
if result < 0 {
Err(result as _)
Err(Error(result as _))
} else {
Ok(result as _)
}
}
pub unsafe fn write_all(fd: i32, mut buf: &[u8]) -> Result<(), i64> {
pub unsafe fn write_all(fd: i32, mut buf: &[u8]) -> Result<(), Error> {
while !buf.is_empty() {
let result = write(fd, buf)?;
let result = sys_write(fd, buf)?;
buf = &buf[result..];
}
Ok(())

View file

@ -0,0 +1,70 @@
use crate::utils::SharedThinCstr;
#[derive(Debug, PartialEq)]
pub enum OpenMode {
R,
RP,
W,
WP,
A,
AP,
}
impl OpenMode {
pub fn parse(str: SharedThinCstr<'_>) -> Result<OpenMode, &'static str> {
let mut buf = [0; 2];
let mut i = 0;
for c in str.into_iter().filter(|&c| c != b'c') {
if i > 1 {
return Err("too many characters for mode");
}
buf[i] = c;
i += 1;
}
Ok(match &buf {
b"r\0" => OpenMode::R,
b"r+" => OpenMode::RP,
b"w\0" => OpenMode::W,
b"w+" => OpenMode::WP,
b"a\0" => OpenMode::A,
b"a+" => OpenMode::AP,
_ => return Err("invalid mode"),
})
}
}
#[cfg(test)]
mod tests {
use crate::cstr;
use super::OpenMode;
#[test]
fn parse_modes() {
use OpenMode::*;
let modes = [
(cstr!("r"), R),
(cstr!("r+"), RP),
(cstr!("w"), W),
(cstr!("w+"), WP),
(cstr!("a"), A),
(cstr!("a+"), AP),
];
for (str, expected) in modes {
let mode = OpenMode::parse(str).unwrap();
assert_eq!(mode, expected);
}
}
#[test]
fn invalid_modes() {
let modes = [cstr!("meow"), cstr!(""), cstr!("r-"), cstr!("r++")];
for str in modes {
OpenMode::parse(str).expect_err("expected failing parse");
}
}
}

View file

@ -1,5 +1,9 @@
pub mod file;
use core::ffi::c_int;
use crate::{error::Error, io::stream::file::OpenMode, utils::SharedThinCstr};
use super::{IoWrite, EOF};
/// A `FILE`.
@ -13,17 +17,28 @@ impl FileStream {
Self { fd }
}
fn write_byte(&self, c: u8) -> Result<(), i32> {
unsafe { super::write_all(self.fd, &[c]).map_err(|e| e as _) }
fn write_byte(&self, c: u8) -> Result<(), Error> {
unsafe { super::write_all(self.fd, &[c]) }
}
}
impl IoWrite for &FileStream {
fn write(&mut self, buf: &[u8]) -> Result<usize, i32> {
unsafe { super::write(self.fd, buf) }
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
unsafe { super::sys_write(self.fd, buf) }
}
}
pub unsafe fn fopen<'a>(
pathname: SharedThinCstr<'_>,
mode: SharedThinCstr<'_>,
) -> Result<&'a FileStream, Error> {
let Ok(mode) = OpenMode::parse(mode) else {
return Err(Error::INVAL);
};
todo!()
}
pub fn fputc(c: u8, stream: &FileStream) -> i32 {
match stream.write_byte(c) {
Ok(_) => c as _,

View file

@ -1,9 +1,11 @@
use core::fmt;
pub trait IoWrite {
fn write(&mut self, buf: &[u8]) -> Result<usize, i32>;
use crate::error::Error;
fn write_all(&mut self, mut buf: &[u8]) -> Result<(), i32> {
pub trait IoWrite {
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>;
fn write_all(&mut self, mut buf: &[u8]) -> Result<(), Error> {
while !buf.is_empty() {
let n = self.write(buf)?;
buf = &buf[n..];
@ -11,16 +13,16 @@ pub trait IoWrite {
Ok(())
}
fn write_byte(&mut self, byte: u8) -> Result<(), i32> {
fn write_byte(&mut self, byte: u8) -> Result<(), Error> {
self.write_all(&[byte])
}
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), i32> {
fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> Result<(), Error> {
// Create a shim which translates a Write to a fmt::Write and saves
// off I/O errors. instead of discarding them
struct Adapter<'a, T: ?Sized> {
inner: &'a mut T,
error: Result<(), i32>,
error: Result<(), Error>,
}
impl<T: IoWrite + ?Sized> fmt::Write for Adapter<'_, T> {
@ -46,7 +48,7 @@ pub trait IoWrite {
if output.error.is_err() {
output.error
} else {
Err(-1)
Err(Error::INVAL)
}
}
}
@ -54,7 +56,7 @@ pub trait IoWrite {
}
impl<W: IoWrite> IoWrite for &mut W {
fn write(&mut self, buf: &[u8]) -> Result<usize, i32> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
W::write(self, buf)
}
}
@ -62,7 +64,7 @@ impl<W: IoWrite> IoWrite for &mut W {
pub struct WriteCounter<W>(pub W, pub usize);
impl<W: IoWrite> IoWrite for WriteCounter<W> {
fn write(&mut self, buf: &[u8]) -> Result<usize, i32> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
let n = self.0.write(buf)?;
self.1 += n;
Ok(n)
@ -73,11 +75,13 @@ impl<W: IoWrite> IoWrite for WriteCounter<W> {
mod test_impls {
extern crate std;
use crate::error::Error;
use super::IoWrite;
use std::vec::Vec;
impl IoWrite for Vec<u8> {
fn write(&mut self, buf: &[u8]) -> Result<usize, i32> {
fn write(&mut self, buf: &[u8]) -> Result<usize, Error> {
self.extend(buf);
Ok(buf.len())
}

View file

@ -19,10 +19,10 @@ pub(crate) unsafe extern "C" fn start(rsp: u64) -> ! {
let result = main(argc as i32, argv);
exit(result as u64);
sys_exit(result as u64);
}
pub fn exit(code: u64) -> ! {
pub fn sys_exit(code: u64) -> ! {
unsafe {
crate::sys::syscall::syscall!(crate::sys::syscall::SYS_EXIT, code);
crate::sys::helpers::trap!();

View file

@ -1,8 +0,0 @@
# curl -L https://filippo.io/linux-syscall-table/TABELLA_64.json > table.json
import json
with open ("table.json") as f:
data = f.read()
data=json.loads(data)
for entry in data:
value = data[entry]
print(f"pub const SYS_{value[1].upper()}: i64 = {value[0]};")

View file

@ -7,7 +7,7 @@ pub use values::*;
#[macro_export]
macro_rules! syscall {
($number:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rdi") $number,
@ -19,7 +19,7 @@ macro_rules! syscall {
out
}};
($number:expr, $arg1:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rax") $number,
@ -32,7 +32,7 @@ macro_rules! syscall {
out
}};
($number:expr, $arg1:expr, $arg2:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rax") $number,
@ -46,7 +46,7 @@ macro_rules! syscall {
out
}};
($number:expr, $arg1:expr, $arg2:expr, $arg3:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rax") $number,
@ -61,7 +61,7 @@ macro_rules! syscall {
out
}};
($number:expr, $arg1:expr, $arg2:expr, $arg3:expr, $arg4:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rax") $number,
@ -77,7 +77,7 @@ macro_rules! syscall {
out
}};
($number:expr, $arg1:expr, $arg2:expr, $arg3:expr, $arg4:expr, $arg5:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rax") $number,
@ -94,7 +94,7 @@ macro_rules! syscall {
out
}};
($number:expr, $arg1:expr, $arg2:expr, $arg3:expr, $arg4:expr, $arg5:expr, $arg6:expr) => {{
let out: u64;
let out: i64;
::core::arch::asm!(
"syscall",
in("rax") $number,

View file

@ -1,314 +1,363 @@
pub const SYS_READ: i64 = 0;
pub const SYS_WRITE: i64 = 1;
pub const SYS_OPEN: i64 = 2;
pub const SYS_CLOSE: i64 = 3;
pub const SYS_STAT: i64 = 4;
pub const SYS_FSTAT: i64 = 5;
pub const SYS_LSTAT: i64 = 6;
pub const SYS_POLL: i64 = 7;
pub const SYS_LSEEK: i64 = 8;
pub const SYS_MMAP: i64 = 9;
pub const SYS_MPROTECT: i64 = 10;
pub const SYS_MUNMAP: i64 = 11;
pub const SYS_BRK: i64 = 12;
pub const SYS_RT_SIGACTION: i64 = 13;
pub const SYS_RT_SIGPROCMASK: i64 = 14;
pub const SYS_RT_SIGRETURN: i64 = 15;
pub const SYS_IOCTL: i64 = 16;
pub const SYS_PREAD64: i64 = 17;
pub const SYS_PWRITE64: i64 = 18;
pub const SYS_READV: i64 = 19;
pub const SYS_WRITEV: i64 = 20;
pub const SYS_ACCESS: i64 = 21;
pub const SYS_PIPE: i64 = 22;
pub const SYS_SELECT: i64 = 23;
pub const SYS_SCHED_YIELD: i64 = 24;
pub const SYS_MREMAP: i64 = 25;
pub const SYS_MSYNC: i64 = 26;
pub const SYS_MINCORE: i64 = 27;
pub const SYS_MADVISE: i64 = 28;
pub const SYS_SHMGET: i64 = 29;
pub const SYS_SHMAT: i64 = 30;
pub const SYS_SHMCTL: i64 = 31;
pub const SYS_DUP: i64 = 32;
pub const SYS_DUP2: i64 = 33;
pub const SYS_PAUSE: i64 = 34;
pub const SYS_NANOSLEEP: i64 = 35;
pub const SYS_GETITIMER: i64 = 36;
pub const SYS_ALARM: i64 = 37;
pub const SYS_SETITIMER: i64 = 38;
pub const SYS_GETPID: i64 = 39;
pub const SYS_SENDFILE: i64 = 40;
pub const SYS_SOCKET: i64 = 41;
pub const SYS_CONNECT: i64 = 42;
pub const SYS_ACCEPT: i64 = 43;
pub const SYS_SENDTO: i64 = 44;
pub const SYS_RECVFROM: i64 = 45;
pub const SYS_SENDMSG: i64 = 46;
pub const SYS_RECVMSG: i64 = 47;
pub const SYS_SHUTDOWN: i64 = 48;
pub const SYS_BIND: i64 = 49;
pub const SYS_LISTEN: i64 = 50;
pub const SYS_GETSOCKNAME: i64 = 51;
pub const SYS_GETPEERNAME: i64 = 52;
pub const SYS_SOCKETPAIR: i64 = 53;
pub const SYS_SETSOCKOPT: i64 = 54;
pub const SYS_GETSOCKOPT: i64 = 55;
pub const SYS_CLONE: i64 = 56;
pub const SYS_FORK: i64 = 57;
pub const SYS_VFORK: i64 = 58;
pub const SYS_EXECVE: i64 = 59;
pub const SYS_EXIT: i64 = 60;
pub const SYS_WAIT4: i64 = 61;
pub const SYS_KILL: i64 = 62;
pub const SYS_UNAME: i64 = 63;
pub const SYS_SEMGET: i64 = 64;
pub const SYS_SEMOP: i64 = 65;
pub const SYS_SEMCTL: i64 = 66;
pub const SYS_SHMDT: i64 = 67;
pub const SYS_MSGGET: i64 = 68;
pub const SYS_MSGSND: i64 = 69;
pub const SYS_MSGRCV: i64 = 70;
pub const SYS_MSGCTL: i64 = 71;
pub const SYS_FCNTL: i64 = 72;
pub const SYS_FLOCK: i64 = 73;
pub const SYS_FSYNC: i64 = 74;
pub const SYS_FDATASYNC: i64 = 75;
pub const SYS_TRUNCATE: i64 = 76;
pub const SYS_FTRUNCATE: i64 = 77;
pub const SYS_GETDENTS: i64 = 78;
pub const SYS_GETCWD: i64 = 79;
pub const SYS_CHDIR: i64 = 80;
pub const SYS_FCHDIR: i64 = 81;
pub const SYS_RENAME: i64 = 82;
pub const SYS_MKDIR: i64 = 83;
pub const SYS_RMDIR: i64 = 84;
pub const SYS_CREAT: i64 = 85;
pub const SYS_LINK: i64 = 86;
pub const SYS_UNLINK: i64 = 87;
pub const SYS_SYMLINK: i64 = 88;
pub const SYS_READLINK: i64 = 89;
pub const SYS_CHMOD: i64 = 90;
pub const SYS_FCHMOD: i64 = 91;
pub const SYS_CHOWN: i64 = 92;
pub const SYS_FCHOWN: i64 = 93;
pub const SYS_LCHOWN: i64 = 94;
pub const SYS_UMASK: i64 = 95;
pub const SYS_GETTIMEOFDAY: i64 = 96;
pub const SYS_GETRLIMIT: i64 = 97;
pub const SYS_GETRUSAGE: i64 = 98;
pub const SYS_SYSINFO: i64 = 99;
pub const SYS_TIMES: i64 = 100;
pub const SYS_PTRACE: i64 = 101;
pub const SYS_GETUID: i64 = 102;
pub const SYS_SYSLOG: i64 = 103;
pub const SYS_GETGID: i64 = 104;
pub const SYS_SETUID: i64 = 105;
pub const SYS_SETGID: i64 = 106;
pub const SYS_GETEUID: i64 = 107;
pub const SYS_GETEGID: i64 = 108;
pub const SYS_SETPGID: i64 = 109;
pub const SYS_GETPPID: i64 = 110;
pub const SYS_GETPGRP: i64 = 111;
pub const SYS_SETSID: i64 = 112;
pub const SYS_SETREUID: i64 = 113;
pub const SYS_SETREGID: i64 = 114;
pub const SYS_GETGROUPS: i64 = 115;
pub const SYS_SETGROUPS: i64 = 116;
pub const SYS_SETRESUID: i64 = 117;
pub const SYS_GETRESUID: i64 = 118;
pub const SYS_SETRESGID: i64 = 119;
pub const SYS_GETRESGID: i64 = 120;
pub const SYS_GETPGID: i64 = 121;
pub const SYS_SETFSUID: i64 = 122;
pub const SYS_SETFSGID: i64 = 123;
pub const SYS_GETSID: i64 = 124;
pub const SYS_CAPGET: i64 = 125;
pub const SYS_CAPSET: i64 = 126;
pub const SYS_RT_SIGPENDING: i64 = 127;
pub const SYS_RT_SIGTIMEDWAIT: i64 = 128;
pub const SYS_RT_SIGQUEUEINFO: i64 = 129;
pub const SYS_RT_SIGSUSPEND: i64 = 130;
pub const SYS_SIGALTSTACK: i64 = 131;
pub const SYS_UTIME: i64 = 132;
pub const SYS_MKNOD: i64 = 133;
pub const SYS_USELIB: i64 = 134;
pub const SYS_PERSONALITY: i64 = 135;
pub const SYS_USTAT: i64 = 136;
pub const SYS_STATFS: i64 = 137;
pub const SYS_FSTATFS: i64 = 138;
pub const SYS_SYSFS: i64 = 139;
pub const SYS_GETPRIORITY: i64 = 140;
pub const SYS_SETPRIORITY: i64 = 141;
pub const SYS_SCHED_SETPARAM: i64 = 142;
pub const SYS_SCHED_GETPARAM: i64 = 143;
pub const SYS_SCHED_SETSCHEDULER: i64 = 144;
pub const SYS_SCHED_GETSCHEDULER: i64 = 145;
pub const SYS_SCHED_GET_PRIORITY_MAX: i64 = 146;
pub const SYS_SCHED_GET_PRIORITY_MIN: i64 = 147;
pub const SYS_SCHED_RR_GET_INTERVAL: i64 = 148;
pub const SYS_MLOCK: i64 = 149;
pub const SYS_MUNLOCK: i64 = 150;
pub const SYS_MLOCKALL: i64 = 151;
pub const SYS_MUNLOCKALL: i64 = 152;
pub const SYS_VHANGUP: i64 = 153;
pub const SYS_MODIFY_LDT: i64 = 154;
pub const SYS_PIVOT_ROOT: i64 = 155;
pub const SYS__SYSCTL: i64 = 156;
pub const SYS_PRCTL: i64 = 157;
pub const SYS_ARCH_PRCTL: i64 = 158;
pub const SYS_ADJTIMEX: i64 = 159;
pub const SYS_SETRLIMIT: i64 = 160;
pub const SYS_CHROOT: i64 = 161;
pub const SYS_SYNC: i64 = 162;
pub const SYS_ACCT: i64 = 163;
pub const SYS_SETTIMEOFDAY: i64 = 164;
pub const SYS_MOUNT: i64 = 165;
pub const SYS_UMOUNT2: i64 = 166;
pub const SYS_SWAPON: i64 = 167;
pub const SYS_SWAPOFF: i64 = 168;
pub const SYS_REBOOT: i64 = 169;
pub const SYS_SETHOSTNAME: i64 = 170;
pub const SYS_SETDOMAINNAME: i64 = 171;
pub const SYS_IOPL: i64 = 172;
pub const SYS_IOPERM: i64 = 173;
pub const SYS_CREATE_MODULE: i64 = 174;
pub const SYS_INIT_MODULE: i64 = 175;
pub const SYS_DELETE_MODULE: i64 = 176;
pub const SYS_GET_KERNEL_SYMS: i64 = 177;
pub const SYS_QUERY_MODULE: i64 = 178;
pub const SYS_QUOTACTL: i64 = 179;
pub const SYS_NFSSERVCTL: i64 = 180;
pub const SYS_GETPMSG: i64 = 181;
pub const SYS_PUTPMSG: i64 = 182;
pub const SYS_AFS_SYSCALL: i64 = 183;
pub const SYS_TUXCALL: i64 = 184;
pub const SYS_SECURITY: i64 = 185;
pub const SYS_GETTID: i64 = 186;
pub const SYS_READAHEAD: i64 = 187;
pub const SYS_SETXATTR: i64 = 188;
pub const SYS_LSETXATTR: i64 = 189;
pub const SYS_FSETXATTR: i64 = 190;
pub const SYS_GETXATTR: i64 = 191;
pub const SYS_LGETXATTR: i64 = 192;
pub const SYS_FGETXATTR: i64 = 193;
pub const SYS_LISTXATTR: i64 = 194;
pub const SYS_LLISTXATTR: i64 = 195;
pub const SYS_FLISTXATTR: i64 = 196;
pub const SYS_REMOVEXATTR: i64 = 197;
pub const SYS_LREMOVEXATTR: i64 = 198;
pub const SYS_FREMOVEXATTR: i64 = 199;
pub const SYS_TKILL: i64 = 200;
pub const SYS_TIME: i64 = 201;
pub const SYS_FUTEX: i64 = 202;
pub const SYS_SCHED_SETAFFINITY: i64 = 203;
pub const SYS_SCHED_GETAFFINITY: i64 = 204;
pub const SYS_SET_THREAD_AREA: i64 = 205;
pub const SYS_IO_SETUP: i64 = 206;
pub const SYS_IO_DESTROY: i64 = 207;
pub const SYS_IO_GETEVENTS: i64 = 208;
pub const SYS_IO_SUBMIT: i64 = 209;
pub const SYS_IO_CANCEL: i64 = 210;
pub const SYS_GET_THREAD_AREA: i64 = 211;
pub const SYS_LOOKUP_DCOOKIE: i64 = 212;
pub const SYS_EPOLL_CREATE: i64 = 213;
pub const SYS_EPOLL_CTL_OLD: i64 = 214;
pub const SYS_EPOLL_WAIT_OLD: i64 = 215;
pub const SYS_REMAP_FILE_PAGES: i64 = 216;
pub const SYS_GETDENTS64: i64 = 217;
pub const SYS_SET_TID_ADDRESS: i64 = 218;
pub const SYS_RESTART_SYSCALL: i64 = 219;
pub const SYS_SEMTIMEDOP: i64 = 220;
pub const SYS_FADVISE64: i64 = 221;
pub const SYS_TIMER_CREATE: i64 = 222;
pub const SYS_TIMER_SETTIME: i64 = 223;
pub const SYS_TIMER_GETTIME: i64 = 224;
pub const SYS_TIMER_GETOVERRUN: i64 = 225;
pub const SYS_TIMER_DELETE: i64 = 226;
pub const SYS_CLOCK_SETTIME: i64 = 227;
pub const SYS_CLOCK_GETTIME: i64 = 228;
pub const SYS_CLOCK_GETRES: i64 = 229;
pub const SYS_CLOCK_NANOSLEEP: i64 = 230;
pub const SYS_EXIT_GROUP: i64 = 231;
pub const SYS_EPOLL_WAIT: i64 = 232;
pub const SYS_EPOLL_CTL: i64 = 233;
pub const SYS_TGKILL: i64 = 234;
pub const SYS_UTIMES: i64 = 235;
pub const SYS_VSERVER: i64 = 236;
pub const SYS_MBIND: i64 = 237;
pub const SYS_SET_MEMPOLICY: i64 = 238;
pub const SYS_GET_MEMPOLICY: i64 = 239;
pub const SYS_MQ_OPEN: i64 = 240;
pub const SYS_MQ_UNLINK: i64 = 241;
pub const SYS_MQ_TIMEDSEND: i64 = 242;
pub const SYS_MQ_TIMEDRECEIVE: i64 = 243;
pub const SYS_MQ_NOTIFY: i64 = 244;
pub const SYS_MQ_GETSETATTR: i64 = 245;
pub const SYS_KEXEC_LOAD: i64 = 246;
pub const SYS_WAITID: i64 = 247;
pub const SYS_ADD_KEY: i64 = 248;
pub const SYS_REQUEST_KEY: i64 = 249;
pub const SYS_KEYCTL: i64 = 250;
pub const SYS_IOPRIO_SET: i64 = 251;
pub const SYS_IOPRIO_GET: i64 = 252;
pub const SYS_INOTIFY_INIT: i64 = 253;
pub const SYS_INOTIFY_ADD_WATCH: i64 = 254;
pub const SYS_INOTIFY_RM_WATCH: i64 = 255;
pub const SYS_MIGRATE_PAGES: i64 = 256;
pub const SYS_OPENAT: i64 = 257;
pub const SYS_MKDIRAT: i64 = 258;
pub const SYS_MKNODAT: i64 = 259;
pub const SYS_FCHOWNAT: i64 = 260;
pub const SYS_FUTIMESAT: i64 = 261;
pub const SYS_NEWFSTATAT: i64 = 262;
pub const SYS_UNLINKAT: i64 = 263;
pub const SYS_RENAMEAT: i64 = 264;
pub const SYS_LINKAT: i64 = 265;
pub const SYS_SYMLINKAT: i64 = 266;
pub const SYS_READLINKAT: i64 = 267;
pub const SYS_FCHMODAT: i64 = 268;
pub const SYS_FACCESSAT: i64 = 269;
pub const SYS_PSELECT6: i64 = 270;
pub const SYS_PPOLL: i64 = 271;
pub const SYS_UNSHARE: i64 = 272;
pub const SYS_SET_ROBUST_LIST: i64 = 273;
pub const SYS_GET_ROBUST_LIST: i64 = 274;
pub const SYS_SPLICE: i64 = 275;
pub const SYS_TEE: i64 = 276;
pub const SYS_SYNC_FILE_RANGE: i64 = 277;
pub const SYS_VMSPLICE: i64 = 278;
pub const SYS_MOVE_PAGES: i64 = 279;
pub const SYS_UTIMENSAT: i64 = 280;
pub const SYS_EPOLL_PWAIT: i64 = 281;
pub const SYS_SIGNALFD: i64 = 282;
pub const SYS_TIMERFD_CREATE: i64 = 283;
pub const SYS_EVENTFD: i64 = 284;
pub const SYS_FALLOCATE: i64 = 285;
pub const SYS_TIMERFD_SETTIME: i64 = 286;
pub const SYS_TIMERFD_GETTIME: i64 = 287;
pub const SYS_ACCEPT4: i64 = 288;
pub const SYS_SIGNALFD4: i64 = 289;
pub const SYS_EVENTFD2: i64 = 290;
pub const SYS_EPOLL_CREATE1: i64 = 291;
pub const SYS_DUP3: i64 = 292;
pub const SYS_PIPE2: i64 = 293;
pub const SYS_INOTIFY_INIT1: i64 = 294;
pub const SYS_PREADV: i64 = 295;
pub const SYS_PWRITEV: i64 = 296;
pub const SYS_RT_TGSIGQUEUEINFO: i64 = 297;
pub const SYS_PERF_EVENT_OPEN: i64 = 298;
pub const SYS_RECVMMSG: i64 = 299;
pub const SYS_FANOTIFY_INIT: i64 = 300;
pub const SYS_FANOTIFY_MARK: i64 = 301;
pub const SYS_PRLIMIT64: i64 = 302;
pub const SYS_NAME_TO_HANDLE_AT: i64 = 303;
pub const SYS_OPEN_BY_HANDLE_AT: i64 = 304;
pub const SYS_CLOCK_ADJTIME: i64 = 305;
pub const SYS_SYNCFS: i64 = 306;
pub const SYS_SENDMMSG: i64 = 307;
pub const SYS_SETNS: i64 = 308;
pub const SYS_GETCPU: i64 = 309;
pub const SYS_PROCESS_VM_READV: i64 = 310;
pub const SYS_PROCESS_VM_WRITEV: i64 = 311;
pub const SYS_KCMP: i64 = 312;
pub const SYS_FINIT_MODULE: i64 = 313;
pub const SYS_READ: i32 = 0;
pub const SYS_WRITE: i32 = 1;
pub const SYS_OPEN: i32 = 2;
pub const SYS_CLOSE: i32 = 3;
pub const SYS_STAT: i32 = 4;
pub const SYS_FSTAT: i32 = 5;
pub const SYS_LSTAT: i32 = 6;
pub const SYS_POLL: i32 = 7;
pub const SYS_LSEEK: i32 = 8;
pub const SYS_MMAP: i32 = 9;
pub const SYS_MPROTECT: i32 = 10;
pub const SYS_MUNMAP: i32 = 11;
pub const SYS_BRK: i32 = 12;
pub const SYS_RT_SIGACTION: i32 = 13;
pub const SYS_RT_SIGPROCMASK: i32 = 14;
pub const SYS_RT_SIGRETURN: i32 = 15;
pub const SYS_IOCTL: i32 = 16;
pub const SYS_PREAD64: i32 = 17;
pub const SYS_PWRITE64: i32 = 18;
pub const SYS_READV: i32 = 19;
pub const SYS_WRITEV: i32 = 20;
pub const SYS_ACCESS: i32 = 21;
pub const SYS_PIPE: i32 = 22;
pub const SYS_SELECT: i32 = 23;
pub const SYS_SCHED_YIELD: i32 = 24;
pub const SYS_MREMAP: i32 = 25;
pub const SYS_MSYNC: i32 = 26;
pub const SYS_MINCORE: i32 = 27;
pub const SYS_MADVISE: i32 = 28;
pub const SYS_SHMGET: i32 = 29;
pub const SYS_SHMAT: i32 = 30;
pub const SYS_SHMCTL: i32 = 31;
pub const SYS_DUP: i32 = 32;
pub const SYS_DUP2: i32 = 33;
pub const SYS_PAUSE: i32 = 34;
pub const SYS_NANOSLEEP: i32 = 35;
pub const SYS_GETITIMER: i32 = 36;
pub const SYS_ALARM: i32 = 37;
pub const SYS_SETITIMER: i32 = 38;
pub const SYS_GETPID: i32 = 39;
pub const SYS_SENDFILE: i32 = 40;
pub const SYS_SOCKET: i32 = 41;
pub const SYS_CONNECT: i32 = 42;
pub const SYS_ACCEPT: i32 = 43;
pub const SYS_SENDTO: i32 = 44;
pub const SYS_RECVFROM: i32 = 45;
pub const SYS_SENDMSG: i32 = 46;
pub const SYS_RECVMSG: i32 = 47;
pub const SYS_SHUTDOWN: i32 = 48;
pub const SYS_BIND: i32 = 49;
pub const SYS_LISTEN: i32 = 50;
pub const SYS_GETSOCKNAME: i32 = 51;
pub const SYS_GETPEERNAME: i32 = 52;
pub const SYS_SOCKETPAIR: i32 = 53;
pub const SYS_SETSOCKOPT: i32 = 54;
pub const SYS_GETSOCKOPT: i32 = 55;
pub const SYS_CLONE: i32 = 56;
pub const SYS_FORK: i32 = 57;
pub const SYS_VFORK: i32 = 58;
pub const SYS_EXECVE: i32 = 59;
pub const SYS_EXIT: i32 = 60;
pub const SYS_WAIT4: i32 = 61;
pub const SYS_KILL: i32 = 62;
pub const SYS_UNAME: i32 = 63;
pub const SYS_SEMGET: i32 = 64;
pub const SYS_SEMOP: i32 = 65;
pub const SYS_SEMCTL: i32 = 66;
pub const SYS_SHMDT: i32 = 67;
pub const SYS_MSGGET: i32 = 68;
pub const SYS_MSGSND: i32 = 69;
pub const SYS_MSGRCV: i32 = 70;
pub const SYS_MSGCTL: i32 = 71;
pub const SYS_FCNTL: i32 = 72;
pub const SYS_FLOCK: i32 = 73;
pub const SYS_FSYNC: i32 = 74;
pub const SYS_FDATASYNC: i32 = 75;
pub const SYS_TRUNCATE: i32 = 76;
pub const SYS_FTRUNCATE: i32 = 77;
pub const SYS_GETDENTS: i32 = 78;
pub const SYS_GETCWD: i32 = 79;
pub const SYS_CHDIR: i32 = 80;
pub const SYS_FCHDIR: i32 = 81;
pub const SYS_RENAME: i32 = 82;
pub const SYS_MKDIR: i32 = 83;
pub const SYS_RMDIR: i32 = 84;
pub const SYS_CREAT: i32 = 85;
pub const SYS_LINK: i32 = 86;
pub const SYS_UNLINK: i32 = 87;
pub const SYS_SYMLINK: i32 = 88;
pub const SYS_READLINK: i32 = 89;
pub const SYS_CHMOD: i32 = 90;
pub const SYS_FCHMOD: i32 = 91;
pub const SYS_CHOWN: i32 = 92;
pub const SYS_FCHOWN: i32 = 93;
pub const SYS_LCHOWN: i32 = 94;
pub const SYS_UMASK: i32 = 95;
pub const SYS_GETTIMEOFDAY: i32 = 96;
pub const SYS_GETRLIMIT: i32 = 97;
pub const SYS_GETRUSAGE: i32 = 98;
pub const SYS_SYSINFO: i32 = 99;
pub const SYS_TIMES: i32 = 100;
pub const SYS_PTRACE: i32 = 101;
pub const SYS_GETUID: i32 = 102;
pub const SYS_SYSLOG: i32 = 103;
pub const SYS_GETGID: i32 = 104;
pub const SYS_SETUID: i32 = 105;
pub const SYS_SETGID: i32 = 106;
pub const SYS_GETEUID: i32 = 107;
pub const SYS_GETEGID: i32 = 108;
pub const SYS_SETPGID: i32 = 109;
pub const SYS_GETPPID: i32 = 110;
pub const SYS_GETPGRP: i32 = 111;
pub const SYS_SETSID: i32 = 112;
pub const SYS_SETREUID: i32 = 113;
pub const SYS_SETREGID: i32 = 114;
pub const SYS_GETGROUPS: i32 = 115;
pub const SYS_SETGROUPS: i32 = 116;
pub const SYS_SETRESUID: i32 = 117;
pub const SYS_GETRESUID: i32 = 118;
pub const SYS_SETRESGID: i32 = 119;
pub const SYS_GETRESGID: i32 = 120;
pub const SYS_GETPGID: i32 = 121;
pub const SYS_SETFSUID: i32 = 122;
pub const SYS_SETFSGID: i32 = 123;
pub const SYS_GETSID: i32 = 124;
pub const SYS_CAPGET: i32 = 125;
pub const SYS_CAPSET: i32 = 126;
pub const SYS_RT_SIGPENDING: i32 = 127;
pub const SYS_RT_SIGTIMEDWAIT: i32 = 128;
pub const SYS_RT_SIGQUEUEINFO: i32 = 129;
pub const SYS_RT_SIGSUSPEND: i32 = 130;
pub const SYS_SIGALTSTACK: i32 = 131;
pub const SYS_UTIME: i32 = 132;
pub const SYS_MKNOD: i32 = 133;
pub const SYS_USELIB: i32 = 134;
pub const SYS_PERSONALITY: i32 = 135;
pub const SYS_USTAT: i32 = 136;
pub const SYS_STATFS: i32 = 137;
pub const SYS_FSTATFS: i32 = 138;
pub const SYS_SYSFS: i32 = 139;
pub const SYS_GETPRIORITY: i32 = 140;
pub const SYS_SETPRIORITY: i32 = 141;
pub const SYS_SCHED_SETPARAM: i32 = 142;
pub const SYS_SCHED_GETPARAM: i32 = 143;
pub const SYS_SCHED_SETSCHEDULER: i32 = 144;
pub const SYS_SCHED_GETSCHEDULER: i32 = 145;
pub const SYS_SCHED_GET_PRIORITY_MAX: i32 = 146;
pub const SYS_SCHED_GET_PRIORITY_MIN: i32 = 147;
pub const SYS_SCHED_RR_GET_INTERVAL: i32 = 148;
pub const SYS_MLOCK: i32 = 149;
pub const SYS_MUNLOCK: i32 = 150;
pub const SYS_MLOCKALL: i32 = 151;
pub const SYS_MUNLOCKALL: i32 = 152;
pub const SYS_VHANGUP: i32 = 153;
pub const SYS_MODIFY_LDT: i32 = 154;
pub const SYS_PIVOT_ROOT: i32 = 155;
pub const SYS__SYSCTL: i32 = 156;
pub const SYS_PRCTL: i32 = 157;
pub const SYS_ARCH_PRCTL: i32 = 158;
pub const SYS_ADJTIMEX: i32 = 159;
pub const SYS_SETRLIMIT: i32 = 160;
pub const SYS_CHROOT: i32 = 161;
pub const SYS_SYNC: i32 = 162;
pub const SYS_ACCT: i32 = 163;
pub const SYS_SETTIMEOFDAY: i32 = 164;
pub const SYS_MOUNT: i32 = 165;
pub const SYS_UMOUNT2: i32 = 166;
pub const SYS_SWAPON: i32 = 167;
pub const SYS_SWAPOFF: i32 = 168;
pub const SYS_REBOOT: i32 = 169;
pub const SYS_SETHOSTNAME: i32 = 170;
pub const SYS_SETDOMAINNAME: i32 = 171;
pub const SYS_IOPL: i32 = 172;
pub const SYS_IOPERM: i32 = 173;
pub const SYS_CREATE_MODULE: i32 = 174;
pub const SYS_INIT_MODULE: i32 = 175;
pub const SYS_DELETE_MODULE: i32 = 176;
pub const SYS_GET_KERNEL_SYMS: i32 = 177;
pub const SYS_QUERY_MODULE: i32 = 178;
pub const SYS_QUOTACTL: i32 = 179;
pub const SYS_NFSSERVCTL: i32 = 180;
pub const SYS_GETPMSG: i32 = 181;
pub const SYS_PUTPMSG: i32 = 182;
pub const SYS_AFS_SYSCALL: i32 = 183;
pub const SYS_TUXCALL: i32 = 184;
pub const SYS_SECURITY: i32 = 185;
pub const SYS_GETTID: i32 = 186;
pub const SYS_READAHEAD: i32 = 187;
pub const SYS_SETXATTR: i32 = 188;
pub const SYS_LSETXATTR: i32 = 189;
pub const SYS_FSETXATTR: i32 = 190;
pub const SYS_GETXATTR: i32 = 191;
pub const SYS_LGETXATTR: i32 = 192;
pub const SYS_FGETXATTR: i32 = 193;
pub const SYS_LISTXATTR: i32 = 194;
pub const SYS_LLISTXATTR: i32 = 195;
pub const SYS_FLISTXATTR: i32 = 196;
pub const SYS_REMOVEXATTR: i32 = 197;
pub const SYS_LREMOVEXATTR: i32 = 198;
pub const SYS_FREMOVEXATTR: i32 = 199;
pub const SYS_TKILL: i32 = 200;
pub const SYS_TIME: i32 = 201;
pub const SYS_FUTEX: i32 = 202;
pub const SYS_SCHED_SETAFFINITY: i32 = 203;
pub const SYS_SCHED_GETAFFINITY: i32 = 204;
pub const SYS_SET_THREAD_AREA: i32 = 205;
pub const SYS_IO_SETUP: i32 = 206;
pub const SYS_IO_DESTROY: i32 = 207;
pub const SYS_IO_GETEVENTS: i32 = 208;
pub const SYS_IO_SUBMIT: i32 = 209;
pub const SYS_IO_CANCEL: i32 = 210;
pub const SYS_GET_THREAD_AREA: i32 = 211;
pub const SYS_LOOKUP_DCOOKIE: i32 = 212;
pub const SYS_EPOLL_CREATE: i32 = 213;
pub const SYS_EPOLL_CTL_OLD: i32 = 214;
pub const SYS_EPOLL_WAIT_OLD: i32 = 215;
pub const SYS_REMAP_FILE_PAGES: i32 = 216;
pub const SYS_GETDENTS64: i32 = 217;
pub const SYS_SET_TID_ADDRESS: i32 = 218;
pub const SYS_RESTART_SYSCALL: i32 = 219;
pub const SYS_SEMTIMEDOP: i32 = 220;
pub const SYS_FADVISE64: i32 = 221;
pub const SYS_TIMER_CREATE: i32 = 222;
pub const SYS_TIMER_SETTIME: i32 = 223;
pub const SYS_TIMER_GETTIME: i32 = 224;
pub const SYS_TIMER_GETOVERRUN: i32 = 225;
pub const SYS_TIMER_DELETE: i32 = 226;
pub const SYS_CLOCK_SETTIME: i32 = 227;
pub const SYS_CLOCK_GETTIME: i32 = 228;
pub const SYS_CLOCK_GETRES: i32 = 229;
pub const SYS_CLOCK_NANOSLEEP: i32 = 230;
pub const SYS_EXIT_GROUP: i32 = 231;
pub const SYS_EPOLL_WAIT: i32 = 232;
pub const SYS_EPOLL_CTL: i32 = 233;
pub const SYS_TGKILL: i32 = 234;
pub const SYS_UTIMES: i32 = 235;
pub const SYS_VSERVER: i32 = 236;
pub const SYS_MBIND: i32 = 237;
pub const SYS_SET_MEMPOLICY: i32 = 238;
pub const SYS_GET_MEMPOLICY: i32 = 239;
pub const SYS_MQ_OPEN: i32 = 240;
pub const SYS_MQ_UNLINK: i32 = 241;
pub const SYS_MQ_TIMEDSEND: i32 = 242;
pub const SYS_MQ_TIMEDRECEIVE: i32 = 243;
pub const SYS_MQ_NOTIFY: i32 = 244;
pub const SYS_MQ_GETSETATTR: i32 = 245;
pub const SYS_KEXEC_LOAD: i32 = 246;
pub const SYS_WAITID: i32 = 247;
pub const SYS_ADD_KEY: i32 = 248;
pub const SYS_REQUEST_KEY: i32 = 249;
pub const SYS_KEYCTL: i32 = 250;
pub const SYS_IOPRIO_SET: i32 = 251;
pub const SYS_IOPRIO_GET: i32 = 252;
pub const SYS_INOTIFY_INIT: i32 = 253;
pub const SYS_INOTIFY_ADD_WATCH: i32 = 254;
pub const SYS_INOTIFY_RM_WATCH: i32 = 255;
pub const SYS_MIGRATE_PAGES: i32 = 256;
pub const SYS_OPENAT: i32 = 257;
pub const SYS_MKDIRAT: i32 = 258;
pub const SYS_MKNODAT: i32 = 259;
pub const SYS_FCHOWNAT: i32 = 260;
pub const SYS_FUTIMESAT: i32 = 261;
pub const SYS_NEWFSTATAT: i32 = 262;
pub const SYS_UNLINKAT: i32 = 263;
pub const SYS_RENAMEAT: i32 = 264;
pub const SYS_LINKAT: i32 = 265;
pub const SYS_SYMLINKAT: i32 = 266;
pub const SYS_READLINKAT: i32 = 267;
pub const SYS_FCHMODAT: i32 = 268;
pub const SYS_FACCESSAT: i32 = 269;
pub const SYS_PSELECT6: i32 = 270;
pub const SYS_PPOLL: i32 = 271;
pub const SYS_UNSHARE: i32 = 272;
pub const SYS_SET_ROBUST_LIST: i32 = 273;
pub const SYS_GET_ROBUST_LIST: i32 = 274;
pub const SYS_SPLICE: i32 = 275;
pub const SYS_TEE: i32 = 276;
pub const SYS_SYNC_FILE_RANGE: i32 = 277;
pub const SYS_VMSPLICE: i32 = 278;
pub const SYS_MOVE_PAGES: i32 = 279;
pub const SYS_UTIMENSAT: i32 = 280;
pub const SYS_EPOLL_PWAIT: i32 = 281;
pub const SYS_SIGNALFD: i32 = 282;
pub const SYS_TIMERFD_CREATE: i32 = 283;
pub const SYS_EVENTFD: i32 = 284;
pub const SYS_FALLOCATE: i32 = 285;
pub const SYS_TIMERFD_SETTIME: i32 = 286;
pub const SYS_TIMERFD_GETTIME: i32 = 287;
pub const SYS_ACCEPT4: i32 = 288;
pub const SYS_SIGNALFD4: i32 = 289;
pub const SYS_EVENTFD2: i32 = 290;
pub const SYS_EPOLL_CREATE1: i32 = 291;
pub const SYS_DUP3: i32 = 292;
pub const SYS_PIPE2: i32 = 293;
pub const SYS_INOTIFY_INIT1: i32 = 294;
pub const SYS_PREADV: i32 = 295;
pub const SYS_PWRITEV: i32 = 296;
pub const SYS_RT_TGSIGQUEUEINFO: i32 = 297;
pub const SYS_PERF_EVENT_OPEN: i32 = 298;
pub const SYS_RECVMMSG: i32 = 299;
pub const SYS_FANOTIFY_INIT: i32 = 300;
pub const SYS_FANOTIFY_MARK: i32 = 301;
pub const SYS_PRLIMIT64: i32 = 302;
pub const SYS_NAME_TO_HANDLE_AT: i32 = 303;
pub const SYS_OPEN_BY_HANDLE_AT: i32 = 304;
pub const SYS_CLOCK_ADJTIME: i32 = 305;
pub const SYS_SYNCFS: i32 = 306;
pub const SYS_SENDMMSG: i32 = 307;
pub const SYS_SETNS: i32 = 308;
pub const SYS_GETCPU: i32 = 309;
pub const SYS_PROCESS_VM_READV: i32 = 310;
pub const SYS_PROCESS_VM_WRITEV: i32 = 311;
pub const SYS_KCMP: i32 = 312;
pub const SYS_FINIT_MODULE: i32 = 313;
pub const SYS_SCHED_SETATTR: i32 = 314;
pub const SYS_SCHED_GETATTR: i32 = 315;
pub const SYS_RENAMEAT2: i32 = 316;
pub const SYS_SECCOMP: i32 = 317;
pub const SYS_GETRANDOM: i32 = 318;
pub const SYS_MEMFD_CREATE: i32 = 319;
pub const SYS_KEXEC_FILE_LOAD: i32 = 320;
pub const SYS_BPF: i32 = 321;
pub const SYS_EXECVEAT: i32 = 322;
pub const SYS_USERFAULTFD: i32 = 323;
pub const SYS_MEMBARRIER: i32 = 324;
pub const SYS_MLOCK2: i32 = 325;
pub const SYS_COPY_FILE_RANGE: i32 = 326;
pub const SYS_PREADV2: i32 = 327;
pub const SYS_PWRITEV2: i32 = 328;
pub const SYS_PKEY_MPROTECT: i32 = 329;
pub const SYS_PKEY_ALLOC: i32 = 330;
pub const SYS_PKEY_FREE: i32 = 331;
pub const SYS_STATX: i32 = 332;
pub const SYS_IO_PGETEVENTS: i32 = 333;
pub const SYS_RSEQ: i32 = 334;
pub const SYS_PIDFD_SEND_SIGNAL: i32 = 424;
pub const SYS_IO_URING_SETUP: i32 = 425;
pub const SYS_IO_URING_ENTER: i32 = 426;
pub const SYS_IO_URING_REGISTER: i32 = 427;
pub const SYS_OPEN_TREE: i32 = 428;
pub const SYS_MOVE_MOUNT: i32 = 429;
pub const SYS_FSOPEN: i32 = 430;
pub const SYS_FSCONFIG: i32 = 431;
pub const SYS_FSMOUNT: i32 = 432;
pub const SYS_FSPICK: i32 = 433;
pub const SYS_PIDFD_OPEN: i32 = 434;
pub const SYS_CLONE3: i32 = 435;
pub const SYS_CLOSE_RANGE: i32 = 436;
pub const SYS_OPENAT2: i32 = 437;
pub const SYS_PIDFD_GETFD: i32 = 438;
pub const SYS_FACCESSAT2: i32 = 439;
pub const SYS_PROCESS_MADVISE: i32 = 440;
pub const SYS_EPOLL_PWAIT2: i32 = 441;
pub const SYS_MOUNT_SETATTR: i32 = 442;
pub const SYS_QUOTACTL_FD: i32 = 443;
pub const SYS_LANDLOCK_CREATE_RULESET: i32 = 444;
pub const SYS_LANDLOCK_ADD_RULE: i32 = 445;
pub const SYS_LANDLOCK_RESTRICT_SELF: i32 = 446;
pub const SYS_MEMFD_SECRET: i32 = 447;
pub const SYS_PROCESS_MRELEASE: i32 = 448;
pub const SYS_FUTEX_WAITV: i32 = 449;
pub const SYS_SET_MEMPOLICY_HOME_NODE: i32 = 450;
pub const SYS_CACHESTAT: i32 = 451;

View file

@ -26,5 +26,5 @@ fn handler(arg: &core::panic::PanicInfo) -> ! {
if let Some(loc) = arg.location() {
libuwuc::io::println!(" at {}:{}:{}", loc.file(), loc.line(), loc.column());
}
libuwuc::start::exit(1);
libuwuc::start::sys_exit(1);
}

View file

@ -1,9 +1,9 @@
use core::ffi::{c_char, c_int};
use libuwuc::{
io::{stream::FileStream, traits::WriteCounter, STDERR, STDIN, STDOUT},
error::IntoOkOrErrno,
io::{fd::Fd, stream::FileStream, traits::WriteCounter, STDERR, STDIN, STDOUT},
utils::SharedThinCstr,
error::IntoOkOrErrno
};
#[no_mangle]
@ -11,6 +11,13 @@ pub unsafe extern "C" fn puts(s: *const c_char) -> i32 {
libuwuc::io::puts(s)
}
// RAW FD:
#[no_mangle]
pub unsafe extern "C" fn open(path: SharedThinCstr, flags: i32) -> Fd {
libuwuc::io::fd::open(path, flags).into_ok_or_errno()
}
// PRINTF:
#[no_mangle]
@ -79,6 +86,14 @@ pub static stdout: &FileStream = &FileStream::from_raw_fd(STDOUT);
#[no_mangle]
pub static stderr: &FileStream = &FileStream::from_raw_fd(STDERR);
#[no_mangle]
pub unsafe extern "C" fn fopen<'a>(
pathname: SharedThinCstr,
mode: SharedThinCstr,
) -> Option<&'a FileStream> {
todo!()
}
#[no_mangle]
pub unsafe extern "C" fn fgetc(_stream: *mut FileStream) -> c_int {
todo!()

View file

@ -1,6 +1,6 @@
use core::ffi::{c_int, c_long};
use libuwuc::utils::SharedThinCstr;
use libuwuc::{error::IntoOkOrErrno, utils::SharedThinCstr};
#[no_mangle]
pub unsafe extern "C" fn malloc(size: usize) -> *mut u8 {
@ -14,7 +14,7 @@ pub unsafe extern "C" fn free(ptr: *mut u8) {
#[no_mangle]
pub unsafe extern "C" fn exit(code: i32) -> ! {
libuwuc::start::exit(code as i64 as _)
libuwuc::start::sys_exit(code as i64 as _)
}
#[no_mangle]
@ -25,6 +25,7 @@ pub unsafe extern "C" fn strtol(nptr: *const u8, endptr: *mut *const u8, base: c
core::mem::transmute::<*mut *const u8, Option<&mut Option<SharedThinCstr<'_>>>>(endptr),
base,
)
.into_ok_or_errno()
}
#[no_mangle]

View file

@ -9,5 +9,6 @@
'';
packages = (with pkgs; [
gef
rust-bindgen
]);
}