use core::ffi;
use super::raw;
use super::result::{prepare_arg as arg, prepare_standard_result as mkresult, Result};
use super::types::*;
macro_rules! syscall {
($n:expr) => {
mkresult(raw::syscall0($n))
};
($n:expr, $a0:expr) => {
mkresult(raw::syscall1($n, arg($a0)))
};
($n:expr, $a0:expr, $a1:expr) => {
mkresult(raw::syscall2($n, arg($a0), arg($a1)))
};
($n:expr, $a0:expr, $a1:expr, $a2:expr) => {
mkresult(raw::syscall3($n, arg($a0), arg($a1), arg($a2)))
};
($n:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr) => {
mkresult(raw::syscall4($n, arg($a0), arg($a1), arg($a2), arg($a3)))
};
($n:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr) => {
mkresult(raw::syscall5(
$n,
arg($a0),
arg($a1),
arg($a2),
arg($a3),
arg($a4),
))
};
($n:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr) => {
mkresult(raw::syscall6(
$n,
arg($a0),
arg($a1),
arg($a2),
arg($a3),
arg($a4),
arg($a5),
))
};
}
#[cfg(have_syscall = "accept")]
#[inline(always)]
pub unsafe fn accept(sockfd: int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> Result<int> {
syscall!(raw::ACCEPT, sockfd, addr as *const void, addrlen)
}
#[cfg(have_syscall = "accept4")]
#[inline(always)]
pub unsafe fn accept4(
sockfd: int,
addr: *mut sockaddr,
addrlen: *mut socklen_t,
flags: int,
) -> Result<int> {
syscall!(raw::ACCEPT4, sockfd, addr as *const void, addrlen, flags)
}
#[cfg(have_syscall = "access")]
#[inline(always)]
pub unsafe fn access(pathname: *const char, mode: int) -> Result<int> {
syscall!(raw::ACCESS, pathname, mode)
}
#[cfg(have_syscall = "acct")]
#[inline(always)]
pub unsafe fn acct(filename: *const char) -> Result<int> {
syscall!(raw::ACCT, filename)
}
#[cfg(have_syscall = "alarm")]
#[inline(always)]
pub unsafe fn alarm(seconds: uint) -> uint {
use crate::args::AsRawV;
uint::from_raw_result(raw::syscall1(raw::ALARM, arg(seconds)))
}
#[cfg(have_syscall = "bind")]
#[inline(always)]
pub unsafe fn bind(sockfd: int, addr: *const sockaddr, addrlen: socklen_t) -> Result<int> {
syscall!(raw::BIND, sockfd, addr as *const void, addrlen)
}
#[cfg(have_syscall = "brk")]
#[inline(always)]
pub unsafe fn brk(brk: ulong) -> long {
use crate::args::AsRawV;
long::from_raw_result(raw::syscall1(raw::BRK, arg(brk)))
}
#[cfg(have_syscall = "chdir")]
#[inline(always)]
pub unsafe fn chdir(path: *const char) -> Result<int> {
syscall!(raw::CHDIR, path)
}
#[cfg(have_syscall = "chmod")]
#[inline(always)]
pub unsafe fn chmod(pathname: *const char, mode: mode_t) -> Result<int> {
syscall!(raw::CHMOD, pathname, mode)
}
#[cfg(all(have_syscall = "chown", not(have_syscall = "chown32")))]
#[inline(always)]
pub unsafe fn chown(pathname: *const char, owner: uid_t, group: gid_t) -> Result<int> {
syscall!(raw::CHOWN, pathname, owner, group)
}
#[cfg(have_syscall = "chown32")]
#[inline(always)]
pub unsafe fn chown(pathname: *const char, owner: uid_t, group: gid_t) -> Result<int> {
syscall!(raw::CHOWN32, pathname, owner, group)
}
#[cfg(have_syscall = "chroot")]
#[inline(always)]
pub unsafe fn chroot(path: *const char) -> Result<int> {
syscall!(raw::CHROOT, path)
}
#[cfg(have_syscall = "close")]
#[inline(always)]
pub unsafe fn close(fd: int) -> Result<int> {
syscall!(raw::CLOSE, fd)
}
#[cfg(have_syscall = "close_range")]
#[inline(always)]
pub unsafe fn close_range(first: int, last: int, flags: uint) -> Result<int> {
syscall!(raw::CLOSE_RANGE, first, last, flags)
}
#[cfg(have_syscall = "connect")]
#[inline(always)]
pub unsafe fn connect(sockfd: int, addr: *const sockaddr, addrlen: socklen_t) -> Result<int> {
syscall!(raw::CONNECT, sockfd, addr as *const void, addrlen)
}
#[cfg(have_syscall = "creat")]
#[inline(always)]
pub unsafe fn creat(pathname: *const char, mode: mode_t) -> Result<int> {
syscall!(raw::CREAT, pathname, mode)
}
#[cfg(have_syscall = "dup")]
#[inline(always)]
pub unsafe fn dup(oldfd: int) -> Result<int> {
syscall!(raw::DUP, oldfd)
}
#[cfg(have_syscall = "dup2")]
#[inline(always)]
pub unsafe fn dup2(oldfd: int, newfd: int) -> Result<int> {
syscall!(raw::DUP2, oldfd, newfd)
}
#[cfg(have_syscall = "dup3")]
#[inline(always)]
pub unsafe fn dup3(oldfd: int, newfd: int, flags: int) -> Result<int> {
syscall!(raw::DUP3, oldfd, newfd, flags)
}
#[cfg(have_syscall = "epoll_create")]
#[inline(always)]
pub unsafe fn epoll_create(size: int) -> Result<int> {
syscall!(raw::EPOLL_CREATE, size)
}
#[cfg(have_syscall = "epoll_create1")]
#[inline(always)]
pub unsafe fn epoll_create1(flags: int) -> Result<int> {
syscall!(raw::EPOLL_CREATE1, flags)
}
#[cfg(have_syscall = "epoll_ctl")]
#[inline(always)]
pub unsafe fn epoll_ctl(epfd: int, op: int, fd: int, event: *const epoll_event) -> Result<int> {
syscall!(raw::EPOLL_CTL, epfd, op, fd, event)
}
#[cfg(have_syscall = "epoll_wait")]
#[inline(always)]
pub unsafe fn epoll_wait(
epfd: int,
events: *const epoll_event,
maxevents: int,
timeout: int,
) -> Result<int> {
syscall!(raw::EPOLL_WAIT, epfd, events, maxevents, timeout)
}
#[cfg(have_syscall = "eventfd")]
#[inline(always)]
pub unsafe fn eventfd(initval: uint) -> Result<int> {
syscall!(raw::EVENTFD, initval)
}
#[cfg(have_syscall = "eventfd2")]
#[inline(always)]
pub unsafe fn eventfd2(initval: uint, flags: int) -> Result<int> {
syscall!(raw::EVENTFD2, initval, flags)
}
#[cfg(have_syscall = "exit")]
#[inline(always)]
pub unsafe fn exit(status: int) -> ! {
raw::syscall1(raw::EXIT, arg(status));
unreachable!()
}
#[cfg(have_syscall = "exit_group")]
#[inline(always)]
pub unsafe fn exit_group(status: int) -> ! {
raw::syscall1(raw::EXIT_GROUP, arg(status));
unreachable!()
}
#[cfg(have_syscall = "faccessat")]
#[inline(always)]
pub unsafe fn faccessat(dirfd: int, pathname: *const char, mode: int) -> Result<int> {
syscall!(raw::FACCESSAT, dirfd, pathname, mode)
}
#[cfg(have_syscall = "faccessat2")]
#[inline(always)]
pub unsafe fn faccessat2(dirfd: int, pathname: *const char, mode: int, flags: int) -> Result<int> {
syscall!(raw::FACCESSAT2, dirfd, pathname, mode, flags)
}
#[cfg(have_syscall = "fchdir")]
#[inline(always)]
pub unsafe fn fchdir(fd: int) -> Result<int> {
syscall!(raw::FCHDIR, fd)
}
#[cfg(have_syscall = "fchmod")]
#[inline(always)]
pub unsafe fn fchmod(fd: int, mode: mode_t) -> Result<int> {
syscall!(raw::FCHMOD, fd, mode)
}
#[cfg(have_syscall = "fchmodat")]
#[inline(always)]
pub unsafe fn fchmodat(dirfd: int, pathname: *const char, mode: mode_t) -> Result<int> {
syscall!(raw::FCHMODAT, dirfd, pathname, mode)
}
#[cfg(have_syscall = "fchown")]
#[inline(always)]
pub unsafe fn fchown(fd: int, owner: uid_t, group: gid_t) -> Result<int> {
syscall!(raw::FCHOWN, fd, owner, group)
}
#[cfg(have_syscall = "fchownat")]
#[inline(always)]
pub unsafe fn fchownat(
dirfd: int,
pathname: *const char,
owner: uid_t,
group: gid_t,
) -> Result<int> {
syscall!(raw::FCHOWN, dirfd, pathname, owner, group)
}
#[cfg(have_syscall = "fcntl")]
#[inline(always)]
pub unsafe fn fcntl(fd: int, cmd: int, arg: impl crate::args::AsRawV) -> Result<int> {
if arg.raw_is_void() {
syscall!(raw::FCNTL, fd, cmd)
} else {
syscall!(raw::FCNTL, fd, cmd, arg)
}
}
#[cfg(have_syscall = "fdatasync")]
#[inline(always)]
pub unsafe fn fdatasync(fd: int) -> Result<int> {
syscall!(raw::FDATASYNC, fd)
}
#[cfg(have_syscall = "fsync")]
#[inline(always)]
pub unsafe fn fsync(fd: int) -> Result<int> {
syscall!(raw::FSYNC, fd)
}
#[cfg(have_syscall = "ftruncate")]
#[inline(always)]
pub unsafe fn ftruncate(fd: int, length: off_t) -> Result<int> {
syscall!(raw::FTRUNCATE, fd, length)
}
#[cfg(have_syscall = "futex")]
#[inline(always)]
pub unsafe fn futex(
uaddr: *const u32,
futex_op: int,
val: impl crate::args::AsRawV,
val2: impl crate::args::AsRawV,
uaddr2: *const u32,
val3: impl crate::args::AsRawV,
) -> Result<int> {
syscall!(raw::FUTEX, uaddr, futex_op, val, val2, uaddr2, val3)
}
#[cfg(have_syscall = "getcpu")]
#[inline(always)]
pub unsafe fn getcpu(cpu: *const uint, node: *const uint) -> Result<int> {
syscall!(raw::GETCPU, cpu, node)
}
#[cfg(have_syscall = "getcwd")]
#[inline(always)]
pub unsafe fn getcwd(buf: *mut char, size: size_t) -> Result<*mut char> {
syscall!(raw::GETCWD, buf, size)
}
#[cfg(have_syscall = "getdents")]
#[inline(always)]
pub unsafe fn getdents(fd: int, dirp: *mut void, count: int) -> Result<int> {
syscall!(raw::GETDENTS, fd, dirp as *mut void, count)
}
#[cfg(have_syscall = "getdents64")]
#[inline(always)]
pub unsafe fn getdents64(fd: int, dirp: *mut void, count: int) -> Result<int> {
syscall!(raw::GETDENTS64, fd, dirp as *mut void, count)
}
#[cfg(have_syscall = "getegid")]
#[inline(always)]
pub unsafe fn getegid() -> gid_t {
raw::syscall0(raw::GETEGID) as gid_t
}
#[cfg(have_syscall = "geteuid")]
#[inline(always)]
pub unsafe fn geteuid() -> uid_t {
raw::syscall0(raw::GETEUID) as uid_t
}
#[cfg(have_syscall = "getgid")]
#[inline(always)]
pub unsafe fn getgid() -> gid_t {
raw::syscall0(raw::GETGID) as gid_t
}
#[cfg(have_syscall = "getgroups")]
#[inline(always)]
pub unsafe fn getgroups(size: int, list: *mut gid_t) -> Result<int> {
syscall!(raw::GETGROUPS, size, list)
}
#[cfg(have_syscall = "getpeername")]
#[inline(always)]
pub unsafe fn getpeername(
sockfd: int,
addr: *mut sockaddr,
addrlen: *mut socklen_t,
) -> Result<int> {
syscall!(raw::GETPEERNAME, sockfd, addr as *mut void, addrlen)
}
#[cfg(have_syscall = "getpid")]
#[inline(always)]
pub unsafe fn getpid() -> pid_t {
raw::syscall0(raw::GETPID) as pid_t
}
#[cfg(have_syscall = "getppid")]
#[inline(always)]
pub unsafe fn getppid() -> pid_t {
raw::syscall0(raw::GETPPID) as pid_t
}
#[cfg(have_syscall = "getrandom")]
#[inline(always)]
pub unsafe fn getrandom(buf: *mut void, buflen: size_t, flags: uint) -> Result<int> {
syscall!(raw::GETRANDOM, buf, buflen, flags)
}
#[cfg(all(have_syscall = "getresgid", not(have_syscall = "getresgid32")))]
#[inline(always)]
pub unsafe fn getresgid(rgid: *mut gid_t, egid: *mut gid_t, sgid: *mut gid_t) -> Result<int> {
syscall!(raw::GETRESGID, rgid, egid, sgid)
}
#[cfg(all(have_syscall = "getresgid32"))]
#[inline(always)]
pub unsafe fn getresgid(rgid: *mut gid_t, egid: *mut gid_t, sgid: *mut gid_t) -> Result<int> {
syscall!(raw::GETRESGID32, rgid, egid, sgid)
}
#[cfg(all(have_syscall = "getresuid", not(have_syscall = "getresuid32")))]
#[inline(always)]
pub unsafe fn getresuid(ruid: *mut uid_t, euid: *mut uid_t, suid: *mut uid_t) -> Result<int> {
syscall!(raw::GETRESUID, ruid, euid, suid)
}
#[cfg(all(have_syscall = "getresuid32"))]
#[inline(always)]
pub unsafe fn getresuid(ruid: *mut uid_t, euid: *mut uid_t, suid: *mut uid_t) -> Result<int> {
syscall!(raw::GETRESUID32, ruid, euid, suid)
}
#[cfg(have_syscall = "getsid")]
#[inline(always)]
pub unsafe fn getsid(pid: pid_t) -> Result<pid_t> {
syscall!(raw::GETSID, pid)
}
#[cfg(have_syscall = "getsockname")]
#[inline(always)]
pub unsafe fn getsockname(
sockfd: int,
addr: *mut sockaddr,
addrlen: *mut socklen_t,
) -> Result<int> {
syscall!(raw::GETSOCKNAME, sockfd, addr as *mut void, addrlen)
}
#[cfg(have_syscall = "getsockopt")]
#[inline(always)]
pub unsafe fn getsockopt(
sockfd: int,
level: int,
optname: int,
optval: *mut void,
optlen: *mut socklen_t,
) -> Result<int> {
syscall!(raw::GETSOCKOPT, sockfd, level, optname, optval, optlen)
}
#[cfg(have_syscall = "gettid")]
#[inline(always)]
pub unsafe fn gettid() -> pid_t {
raw::syscall0(raw::GETTID) as pid_t
}
#[cfg(all(have_syscall = "getuid", not(have_syscall = "getuid32")))]
#[inline(always)]
pub unsafe fn getuid() -> uid_t {
raw::syscall0(raw::GETUID) as uid_t
}
#[cfg(have_syscall = "getuid32")]
#[inline(always)]
pub unsafe fn getuid() -> uid_t {
raw::syscall0(raw::GETUID32) as uid_t
}
#[cfg(have_syscall = "inotify_add_watch")]
#[inline(always)]
pub unsafe fn inotify_add_watch(fd: int, pathname: *const char, mask: u32) -> Result<int> {
syscall!(raw::INOTIFY_ADD_WATCH, fd, pathname, mask)
}
#[cfg(have_syscall = "inotify_init")]
#[inline(always)]
pub unsafe fn inotify_init() -> Result<int> {
syscall!(raw::INOTIFY_INIT)
}
#[cfg(have_syscall = "inotify_rm_watch")]
#[inline(always)]
pub unsafe fn inotify_rm_watch(fd: int, wd: int) -> Result<int> {
syscall!(raw::INOTIFY_RM_WATCH, fd, wd)
}
#[cfg(have_syscall = "inotify_init1")]
#[inline(always)]
pub unsafe fn inotify_init1(flags: int) -> Result<int> {
syscall!(raw::INOTIFY_INIT1, flags)
}
#[cfg(have_syscall = "io_uring_enter")]
#[inline(always)]
pub unsafe fn io_uring_enter(
fd: int,
to_submit: uint,
min_complete: uint,
flags: uint,
sig: *mut sigset_t,
) -> Result<int> {
syscall!(raw::IO_URING_ENTER, fd, to_submit, min_complete, flags, sig)
}
#[cfg(have_syscall = "io_uring_enter2")]
#[inline(always)]
pub unsafe fn io_uring_enter2(
fd: int,
to_submit: uint,
min_complete: uint,
flags: uint,
sig: *mut sigset_t,
sz: size_t,
) -> Result<int> {
syscall!(
raw::IO_URING_ENTER2,
fd,
to_submit,
min_complete,
flags,
sig,
sz,
)
}
#[cfg(have_syscall = "io_uring_register")]
#[inline(always)]
pub unsafe fn io_uring_register(
fd: int,
opcode: uint,
arg: *mut void,
nr_args: uint,
) -> Result<int> {
syscall!(raw::IO_URING_REGISTER, fd, opcode, arg, nr_args)
}
#[cfg(have_syscall = "io_uring_setup")]
#[inline(always)]
pub unsafe fn io_uring_setup(entries: u32, p: *mut io_uring_params) -> Result<int> {
syscall!(raw::IO_URING_SETUP, entries, p)
}
#[cfg(have_syscall = "ioctl")]
#[inline(always)]
pub unsafe fn ioctl(fd: int, request: ulong, arg: impl crate::args::AsRawV) -> Result<int> {
if arg.raw_is_void() {
syscall!(raw::IOCTL, fd, request)
} else {
syscall!(raw::IOCTL, fd, request, arg)
}
}
#[cfg(have_syscall = "kill")]
#[inline(always)]
pub unsafe fn kill(pid: pid_t, sig: int) -> Result<int> {
syscall!(raw::KILL, pid, sig)
}
#[cfg(all(have_syscall = "lchown", not(have_syscall = "lchown32")))]
#[inline(always)]
pub unsafe fn lchown(pathname: *const char, owner: uid_t, group: gid_t) -> Result<int> {
syscall!(raw::LCHOWN, pathname, owner, group)
}
#[cfg(have_syscall = "lchown32")]
#[inline(always)]
pub unsafe fn lchown(pathname: *const char, owner: uid_t, group: gid_t) -> Result<int> {
syscall!(raw::LCHOWN32, pathname, owner, group)
}
#[cfg(have_syscall = "link")]
#[inline(always)]
pub unsafe fn link(oldpath: *const char, newpath: *const char) -> Result<int> {
syscall!(raw::LINK, oldpath, newpath)
}
#[cfg(have_syscall = "linkat")]
#[inline(always)]
pub unsafe fn linkat(
olddirfd: int,
oldpath: *const char,
newdirfd: int,
newpath: *const char,
flags: int,
) -> Result<int> {
syscall!(raw::LINKAT, olddirfd, oldpath, newdirfd, newpath, flags)
}
#[cfg(have_syscall = "listen")]
#[inline(always)]
pub unsafe fn listen(fd: int, backlog: int) -> Result<int> {
syscall!(raw::LISTEN, fd, backlog)
}
#[cfg(have_syscall = "lseek")]
#[inline(always)]
pub unsafe fn lseek(fd: int, offset: off_t, whence: int) -> Result<off_t> {
syscall!(raw::LSEEK, fd, offset, whence)
}
#[cfg(all(have_syscall = "mmap", not(have_syscall = "mmap2")))]
#[inline(always)]
pub unsafe fn mmap(
addr: *mut void,
length: size_t,
prot: int,
flags: int,
fd: int,
offset: off_t,
) -> Result<*mut void> {
syscall!(raw::MMAP, addr, length, prot, flags, fd, offset)
}
#[cfg(have_syscall = "mmap2")]
#[inline(always)]
pub unsafe fn mmap(
addr: *mut void,
length: size_t,
prot: int,
flags: int,
fd: int,
offset: off_t,
) -> Result<*mut void> {
syscall!(raw::MMAP2, addr, length, prot, flags, fd, offset / 4096)
}
#[cfg(have_syscall = "munmap")]
#[inline(always)]
pub unsafe fn munmap(addr: *mut void, length: size_t) -> Result<*mut void> {
syscall!(raw::MUNMAP, addr, length)
}
#[cfg(have_syscall = "mremap")]
#[inline(always)]
pub unsafe fn mremap(
old_address: *mut void,
old_size: size_t,
new_size: size_t,
flags: int,
new_address: *mut void,
) -> Result<*mut void> {
syscall!(
raw::MREMAP,
old_address,
old_size,
new_size,
flags,
new_address
)
}
#[cfg(have_syscall = "pause")]
#[inline(always)]
pub unsafe fn pause() -> Result<int> {
syscall!(raw::PAUSE)
}
#[cfg(have_syscall = "open")]
#[inline(always)]
pub unsafe fn open(pathname: *const char, flags: int, mode: mode_t) -> Result<int> {
syscall!(raw::OPEN, pathname, flags, mode)
}
#[cfg(have_syscall = "openat")]
#[inline(always)]
pub unsafe fn openat(dirfd: int, pathname: *const char, flags: int, mode: mode_t) -> Result<int> {
syscall!(raw::OPENAT, dirfd, pathname, flags, mode)
}
#[cfg(have_syscall = "pidfd_open")]
#[inline(always)]
pub unsafe fn pidfd_open(pid: pid_t, flags: uint) -> Result<int> {
syscall!(raw::PIDFD_OPEN, pid, flags)
}
#[cfg(have_syscall = "pipe")]
#[inline(always)]
pub unsafe fn pipe(fds: *mut int) -> Result<int> {
syscall!(raw::PIPE, fds)
}
#[cfg(have_syscall = "pipe2")]
#[inline(always)]
pub unsafe fn pipe2(fds: *mut int, flags: int) -> Result<int> {
syscall!(raw::PIPE2, fds, flags)
}
#[cfg(have_syscall = "pivot_root")]
#[inline(always)]
pub unsafe fn pivot_root(new_root: *const char, put_old: *const char) -> Result<int> {
syscall!(raw::PIVOT_ROOT, new_root, put_old)
}
#[cfg(have_syscall = "poll")]
#[inline(always)]
pub unsafe fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: int) -> Result<int> {
syscall!(raw::POLL, fds, nfds, timeout)
}
#[cfg(have_syscall = "ppoll")]
#[inline(always)]
pub unsafe fn ppoll(
fds: *mut pollfd,
nfds: nfds_t,
tmo_p: *const timespec,
sigmask: *const sigset_t,
) -> Result<int> {
syscall!(raw::PPOLL, fds, nfds, tmo_p, sigmask)
}
#[cfg(have_syscall = "prctl")]
#[inline(always)]
pub unsafe fn prctl(
option: int,
arg2: ulong,
arg3: ulong,
arg4: ulong,
arg5: ulong,
) -> Result<int> {
syscall!(raw::PRCTL, option, arg2, arg3, arg4, arg5)
}
#[cfg(have_syscall = "read")]
#[inline(always)]
pub unsafe fn read(fd: int, buf: *mut void, count: size_t) -> Result<ssize_t> {
syscall!(raw::READ, fd, buf, count)
}
#[cfg(have_syscall = "readv")]
#[inline(always)]
pub unsafe fn readv(fd: int, iov: *mut iovec, iovcount: int) -> Result<size_t> {
syscall!(raw::READV, fd, iov, iovcount)
}
#[cfg(have_syscall = "setsockopt")]
#[inline(always)]
pub unsafe fn setsockopt(
sockfd: int,
level: int,
optname: int,
optval: *const void,
optlen: socklen_t,
) -> Result<int> {
syscall!(raw::SETSOCKOPT, sockfd, level, optname, optval, optlen)
}
#[cfg(have_syscall = "sendfile")]
#[inline(always)]
pub unsafe fn sendfile(out_fd: int, in_fd: int, offset: *mut off_t, count: size_t) -> Result<int> {
syscall!(raw::SENDFILE, out_fd, in_fd, offset, count)
}
#[cfg(have_syscall = "sendfile64")]
#[inline(always)]
pub unsafe fn sendfile64(
out_fd: int,
in_fd: int,
offset: *mut loff_t,
count: size_t,
) -> Result<int> {
syscall!(raw::SENDFILE64, out_fd, in_fd, offset, count)
}
#[cfg(have_syscall = "socket")]
#[inline(always)]
pub unsafe fn socket(family: sa_family_t, typ: sock_type, protocol: int) -> Result<int> {
syscall!(raw::SOCKET, family, typ as u32, protocol)
}
#[cfg(have_syscall = "socketpair")]
#[inline(always)]
pub unsafe fn socketpair(
family: sa_family_t,
typ: sock_type,
protocol: int,
sv: *mut [int; 2],
) -> Result<int> {
syscall!(raw::SOCKETPAIR, family, typ as u32, protocol, sv)
}
#[cfg(have_syscall = "splice")]
#[inline(always)]
pub unsafe fn splice(
fd_in: int,
off_in: *mut off64_t,
fd_out: int,
off_out: *mut off64_t,
len: size_t,
flags: uint,
) -> Result<int> {
syscall!(raw::SPLICE, fd_in, off_in, fd_out, off_out, len, flags)
}
#[cfg(have_syscall = "sync")]
#[inline(always)]
pub unsafe fn sync() {
raw::syscall0(raw::SYNC);
}
#[cfg(have_syscall = "syncfs")]
#[inline(always)]
pub unsafe fn syncfs(fd: int) -> Result<int> {
syscall!(raw::SYNCFS, fd)
}
#[cfg(have_syscall = "tee")]
#[inline(always)]
pub unsafe fn tee(fd_in: int, fd_out: int, len: size_t, flags: uint) -> Result<int> {
syscall!(raw::TEE, fd_in, fd_out, len, flags)
}
#[cfg(have_syscall = "truncate")]
#[inline(always)]
pub unsafe fn truncate(path: *const char, length: off_t) -> Result<int> {
syscall!(raw::TRUNCATE, path, length)
}
#[cfg(have_syscall = "write")]
#[inline(always)]
pub unsafe fn write(fd: int, buf: *const ffi::c_void, count: size_t) -> Result<ssize_t> {
syscall!(raw::WRITE, fd, buf, count)
}
#[cfg(have_syscall = "writev")]
#[inline(always)]
pub unsafe fn writev(fd: int, iov: *const iovec, iovcount: int) -> Result<size_t> {
syscall!(raw::WRITEV, fd, iov, iovcount)
}
#[cfg(have_syscall = "_llseek")]
#[inline(always)]
pub unsafe fn _llseek(
fd: int,
offset_high: ffi::c_ulong,
offset_low: ffi::c_ulong,
result: *mut loff_t,
whence: uint,
) -> Result<int> {
syscall!(raw::_LLSEEK, fd, offset_high, offset_low, result, whence)
}