Merge branch 'getsetpriority_impl' into 'master'
sys_resource: get/setpriority implementations. See merge request redox-os/relibc!369
This commit is contained in:
@@ -61,10 +61,23 @@ pub struct rusage {
|
||||
pub ru_nivcsw: c_long,
|
||||
}
|
||||
|
||||
// #[no_mangle]
|
||||
// pub unsafe extern "C" fn getpriority(which: c_int, who: id_t) -> c_int {
|
||||
// unimplemented!();
|
||||
// }
|
||||
pub const PRIO_PROGRESS: c_int = 0;
|
||||
pub const PRIO_PGRP: c_int = 1;
|
||||
pub const PRIO_USER: c_int = 2;
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getpriority(which: c_int, who: id_t) -> c_int {
|
||||
let r = Sys::getpriority(which, who);
|
||||
if r < 0 {
|
||||
return r
|
||||
}
|
||||
20-r
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn setpriority(which: c_int, who: id_t, nice: c_int) -> c_int {
|
||||
Sys::setpriority(which, who, nice)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn getrlimit(resource: c_int, rlp: *mut rlimit) -> c_int {
|
||||
|
||||
@@ -259,6 +259,10 @@ impl Pal for Sys {
|
||||
e(unsafe { syscall!(GETPPID) }) as pid_t
|
||||
}
|
||||
|
||||
fn getpriority(which: c_int, who: id_t) -> c_int {
|
||||
e(unsafe { syscall!(GETPRIORITY, which, who) }) as c_int
|
||||
}
|
||||
|
||||
fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t {
|
||||
e(unsafe { syscall!(GETRANDOM, buf.as_mut_ptr(), buf.len(), flags) }) as ssize_t
|
||||
}
|
||||
@@ -456,6 +460,10 @@ impl Pal for Sys {
|
||||
e(unsafe { syscall!(SETPGID, pid, pgid) }) as c_int
|
||||
}
|
||||
|
||||
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int {
|
||||
e(unsafe { syscall!(SETPRIORITY, which, who, prio) }) as c_int
|
||||
}
|
||||
|
||||
fn setregid(rgid: gid_t, egid: gid_t) -> c_int {
|
||||
e(unsafe { syscall!(SETREGID, rgid, egid) }) as c_int
|
||||
}
|
||||
|
||||
@@ -96,6 +96,8 @@ pub trait Pal {
|
||||
|
||||
fn getppid() -> pid_t;
|
||||
|
||||
fn getpriority(which: c_int, who: id_t) -> c_int;
|
||||
|
||||
fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t;
|
||||
|
||||
unsafe fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int;
|
||||
@@ -165,6 +167,8 @@ pub trait Pal {
|
||||
|
||||
fn setpgid(pid: pid_t, pgid: pid_t) -> c_int;
|
||||
|
||||
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int;
|
||||
|
||||
fn setregid(rgid: gid_t, egid: gid_t) -> c_int;
|
||||
|
||||
fn setreuid(ruid: uid_t, euid: uid_t) -> c_int;
|
||||
|
||||
@@ -499,6 +499,12 @@ impl Pal for Sys {
|
||||
e(syscall::getppid()) as pid_t
|
||||
}
|
||||
|
||||
fn getpriority(which: c_int, who: id_t) -> c_int {
|
||||
// TODO
|
||||
unsafe { errno = ENOSYS };
|
||||
-1
|
||||
}
|
||||
|
||||
fn getrandom(buf: &mut [u8], flags: c_uint) -> ssize_t {
|
||||
//TODO: make this a system call?
|
||||
|
||||
@@ -790,6 +796,12 @@ impl Pal for Sys {
|
||||
e(syscall::setpgid(pid as usize, pgid as usize)) as c_int
|
||||
}
|
||||
|
||||
fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int {
|
||||
// TODO
|
||||
unsafe { errno = ENOSYS };
|
||||
-1
|
||||
}
|
||||
|
||||
fn setregid(rgid: gid_t, egid: gid_t) -> c_int {
|
||||
e(syscall::setregid(rgid as usize, egid as usize)) as c_int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user