summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-05-25 11:07:21 -0700
committerbors <bors@rust-lang.org>2016-05-25 11:07:21 -0700
commita200a04d446303944d7295909800210182499552 (patch)
tree663c318a13949afa3a71937ca63aed027bc020a9
parent505575f8b651eb88a0959aead0dec7d152bf5786 (diff)
parentcbc88ca0d565146d0f759b6c3060225df6e74535 (diff)
downloadrust-libc-a200a04d446303944d7295909800210182499552.tar.gz
Auto merge of #294 - lemonrock:getpriority, r=alexcrichton
Added nice, setpriority and getpriority along with constants and type… … definitions
-rw-r--r--src/unix/bsd/apple/mod.rs8
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs3
-rw-r--r--src/unix/bsd/openbsdlike/mod.rs3
-rw-r--r--src/unix/mod.rs10
-rw-r--r--src/unix/notbsd/android/b32.rs2
-rw-r--r--src/unix/notbsd/android/b64.rs2
-rw-r--r--src/unix/notbsd/android/mod.rs13
-rw-r--r--src/unix/notbsd/linux/musl/mod.rs2
-rw-r--r--src/unix/notbsd/linux/other/mod.rs4
-rw-r--r--src/unix/notbsd/mod.rs1
-rw-r--r--src/unix/solaris/mod.rs2
11 files changed, 50 insertions, 0 deletions
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 17b441320d..60cb9d5cb1 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 c2713979f1..f584133b57 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 8bb15cffc0..573975bd40 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 29de88bf44..cc79c6e2ef 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 0b1f8d2459..91a56a3fca 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 e9beff4478..025dabd458 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 14dba30c78..647e57e1c4 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 0631495ee4..47fa888675 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 b869a89b7d..3e6e121744 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 d94ce78354..5ee8aa1e5e 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 3413974740..96a5bf3d63 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;
}