Add getrusage

This commit is contained in:
Jeremy Soller
2024-09-19 16:08:54 -06:00
parent 8a0b2dcbd0
commit 1b7d059707
4 changed files with 23 additions and 19 deletions
+5 -6
View File
@@ -6,9 +6,8 @@ use crate::{
c_str::CStr,
header::{dirent::dirent, errno::EINVAL, signal::SIGCHLD, sys_stat::S_IFIFO},
};
// use header::sys_resource::rusage;
use crate::header::{
sys_resource::rlimit,
sys_resource::{rlimit, rusage},
sys_stat::stat,
sys_statvfs::statvfs,
sys_time::{timeval, timezone},
@@ -76,10 +75,6 @@ pub fn e(sys: usize) -> usize {
pub struct Sys;
impl Sys {
// fn getrusage(who: c_int, r_usage: *mut rusage) -> c_int {
// e(unsafe { syscall!(GETRUSAGE, who, r_usage) }) as c_int
// }
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
@@ -342,6 +337,10 @@ impl Pal for Sys {
e(syscall!(SETRLIMIT, resource, rlimit)) as c_int
}
fn getrusage(who: c_int, r_usage: &mut rusage) -> c_int {
e(unsafe { syscall!(GETRUSAGE, who, r_usage) }) as c_int
}
fn getsid(pid: pid_t) -> pid_t {
e(unsafe { syscall!(GETSID, pid) }) as pid_t
}