diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 17b441320de6544653569d317ff3e7e589e21329..60cb9d5cb1431890d061696b1e2e94dc810de485 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -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 {} @@ -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 @@ -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! { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index c2713979f174eabe70d799fd6f516d74768ab58b..f584133b577e8639d8de96f209132e7ae7576ee6 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -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 {} @@ -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! { diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 8bb15cffc08f15c5613683118a8a70997a273fca..573975bd4087a3f0c5baebf5e2ad4af124bdfef3 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -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 {} @@ -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! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 29de88bf4455c9f6a3a99ff40797b5981b59509c..cc79c6e2ef7f78a56d80de7be02fab656fe3770a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -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 @@ -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! { diff --git a/src/unix/notbsd/android/b32.rs b/src/unix/notbsd/android/b32.rs index 0b1f8d24598ecbb0b6b6dbf133a6a236e8e1cfb2..91a56a3fcaf95c4f19e281ddf634a0301d50f872 100644 --- a/src/unix/notbsd/android/b32.rs +++ b/src/unix/notbsd/android/b32.rs @@ -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; diff --git a/src/unix/notbsd/android/b64.rs b/src/unix/notbsd/android/b64.rs index e9beff44783a9a6c3761228bfa79f2e1499b0d16..025dabd45833a9e0e46a2a36d5f2734daa6a416a 100644 --- a/src/unix/notbsd/android/b64.rs +++ b/src/unix/notbsd/android/b64.rs @@ -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; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 14dba30c7820011453199d2487ef9fb8eba1932e..647e57e1c4e6495fd1bbcfb4a7c9053336efb5cf 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -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 { @@ -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; @@ -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! { diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 0631495ee44349152e3b49829c8df8be42dedf3d..47fa8886750086371d07c15c7765f6fe4e5dc36f 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -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! { diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index b869a89b7d346f3aeccf57282ae4332668648319..3e6e1217449194336ac63c1b4b8a571d2c554de3 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -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 { @@ -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; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index d94ce78354c811c77a6835d4367595c024f9a4a7..5ee8aa1e5ef3008e11bf51876d1df557465902c3 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -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 {} diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 3413974740dca81ec7fcbf4d7bfb8d288268f3d1..96a5bf3d63d6978c7eb1a8750dbdfe185e54d4bd 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -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; }