Skip to content

Commit

Permalink
Auto merge of rust-lang#294 - lemonrock:getpriority, r=alexcrichton
Browse files Browse the repository at this point in the history
Added nice, setpriority and getpriority along with constants and type…

… definitions
  • Loading branch information
bors committed May 25, 2016
2 parents 505575f + cbc88ca commit a200a04
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub type fsfilcnt_t = ::c_uint;
pub type speed_t = ::c_ulong;
pub type tcflag_t = ::c_ulong;
pub type nl_item = ::c_int;
pub type id_t = ::c_uint;

pub enum timezone {}

Expand Down Expand Up @@ -1241,6 +1242,11 @@ pub const CTL_DEBUG_NAME: ::c_int = 0;
pub const CTL_DEBUG_VALUE: ::c_int = 1;
pub const CTL_DEBUG_MAXID: ::c_int = 20;

pub const PRIO_DARWIN_THREAD: ::c_int = 3;
pub const PRIO_DARWIN_PROCESS: ::c_int = 4;
pub const PRIO_DARWIN_BG: ::c_int = 0x1000;
pub const PRIO_DARWIN_NONUI: ::c_int = 0x1001;

f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
Expand Down Expand Up @@ -1356,6 +1362,8 @@ extern {
base: ::locale_t) -> ::locale_t;
pub fn uselocale(loc: ::locale_t) -> ::locale_t;
pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char;
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub type pthread_key_t = ::c_int;
pub type tcflag_t = ::c_uint;
pub type speed_t = ::c_uint;
pub type nl_item = ::c_int;
pub type id_t = i64;

pub enum timezone {}

Expand Down Expand Up @@ -749,6 +750,8 @@ extern {
pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
stackaddr: *mut *mut ::c_void,
stacksize: *mut ::size_t) -> ::c_int;
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
3 changes: 3 additions & 0 deletions src/unix/bsd/openbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub type speed_t = ::c_uint;
pub type tcflag_t = ::c_uint;
pub type nl_item = c_long;
pub type clockid_t = ::c_int;
pub type id_t = ::uint32_t;

pub enum timezone {}

Expand Down Expand Up @@ -472,6 +473,8 @@ extern {
name: *mut ::c_char,
termp: *mut termios,
winp: *mut ::winsize) -> ::pid_t;
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
10 changes: 10 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ pub const LOG_NOWAIT: ::c_int = 0x10;
pub const LOG_PRIMASK: ::c_int = 7;
pub const LOG_FACMASK: ::c_int = 0x3f8;

pub const PRIO_PROCESS: ::c_int = 0;
pub const PRIO_PGRP: ::c_int = 1;
pub const PRIO_USER: ::c_int = 2;

pub const PRIO_MIN: ::c_int = -20;
pub const PRIO_MAX: ::c_int = 20;

cfg_if! {
if #[cfg(dox)] {
// on dox builds don't pull in anything
Expand Down Expand Up @@ -773,6 +780,9 @@ extern {
pub fn closelog();
pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "nice$UNIX2003")]
pub fn nice(incr: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/notbsd/android/b32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__reserved: [0; 12],
};
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
pub const CPU_SETSIZE: ::size_t = 32;
pub const __CPU_BITS: ::size_t = 32;

extern {
pub fn timegm64(tm: *const ::tm) -> ::time64_t;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/notbsd/android/b64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__reserved: [0; 36],
};
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4;
pub const CPU_SETSIZE: ::size_t = 1024;
pub const __CPU_BITS: ::size_t = 64;

extern {
pub fn timegm(tm: *const ::tm) -> ::time64_t;
Expand Down
13 changes: 13 additions & 0 deletions src/unix/notbsd/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub type nfds_t = ::c_uint;
pub type rlim_t = ::c_ulong;
pub type dev_t = ::c_ulong;
pub type ino_t = ::c_ulong;
pub type __CPU_BITTYPE = ::c_ulong;

s! {
pub struct dirent {
Expand Down Expand Up @@ -87,6 +88,13 @@ s! {
pub l_len: ::off_t,
pub l_pid: ::pid_t,
}

pub struct cpu_set_t {
#[cfg(target_pointer_width = "64")]
__bits: [__CPU_BITTYPE; 16],
#[cfg(target_pointer_width = "32")]
__bits: [__CPU_BITTYPE; 1],
}
}

pub const BUFSIZ: ::c_uint = 1024;
Expand Down Expand Up @@ -546,6 +554,11 @@ extern {
sevlen: ::size_t,
flags: ::c_int) -> ::c_int;
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
pub fn __sched_cpualloc(count: ::size_t) -> *mut ::cpu_set_t;
pub fn __sched_cpufree(set: *mut ::cpu_set_t);
pub fn __sched_cpucount(setsize: ::size_t, set: *mut cpu_set_t) -> ::c_int;
}

cfg_if! {
Expand Down
2 changes: 2 additions & 0 deletions src/unix/notbsd/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ pub const CLOCK_TAI: ::clockid_t = 11;
extern {
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
4 changes: 4 additions & 0 deletions src/unix/notbsd/linux/other/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
pub type rlim_t = c_ulong;
pub type __priority_which_t = ::c_uint;

s! {
pub struct sigaction {
Expand Down Expand Up @@ -495,6 +496,9 @@ extern {
pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
cpusetsize: ::size_t,
cpuset: *const ::cpu_set_t) -> ::c_int;
pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::__priority_which_t, who: ::id_t,
prio: ::c_int) -> ::c_int;
pub fn pthread_getaffinity_np(thread: ::pthread_t,
cpusetsize: ::size_t,
cpuset: *mut ::cpu_set_t) -> ::c_int;
Expand Down
1 change: 1 addition & 0 deletions src/unix/notbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub type speed_t = ::c_uint;
pub type tcflag_t = ::c_uint;
pub type loff_t = ::c_longlong;
pub type clockid_t = ::c_int;
pub type id_t = ::c_uint;

pub enum timezone {}

Expand Down
2 changes: 2 additions & 0 deletions src/unix/solaris/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,5 +907,7 @@ extern {
pub fn getprogname() -> *const ::c_char;
pub fn setprogname(name: *const ::c_char);
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
}

0 comments on commit a200a04

Please sign in to comment.