Skip to content

Commit a200a04

Browse files
committed
Auto merge of rust-lang#294 - lemonrock:getpriority, r=alexcrichton
Added nice, setpriority and getpriority along with constants and type… … definitions
2 parents 505575f + cbc88ca commit a200a04

File tree

11 files changed

+50
-0
lines changed

11 files changed

+50
-0
lines changed

src/unix/bsd/apple/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub type fsfilcnt_t = ::c_uint;
1919
pub type speed_t = ::c_ulong;
2020
pub type tcflag_t = ::c_ulong;
2121
pub type nl_item = ::c_int;
22+
pub type id_t = ::c_uint;
2223

2324
pub enum timezone {}
2425

@@ -1241,6 +1242,11 @@ pub const CTL_DEBUG_NAME: ::c_int = 0;
12411242
pub const CTL_DEBUG_VALUE: ::c_int = 1;
12421243
pub const CTL_DEBUG_MAXID: ::c_int = 20;
12431244

1245+
pub const PRIO_DARWIN_THREAD: ::c_int = 3;
1246+
pub const PRIO_DARWIN_PROCESS: ::c_int = 4;
1247+
pub const PRIO_DARWIN_BG: ::c_int = 0x1000;
1248+
pub const PRIO_DARWIN_NONUI: ::c_int = 0x1001;
1249+
12441250
f! {
12451251
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
12461252
status >> 8
@@ -1356,6 +1362,8 @@ extern {
13561362
base: ::locale_t) -> ::locale_t;
13571363
pub fn uselocale(loc: ::locale_t) -> ::locale_t;
13581364
pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char;
1365+
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
1366+
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
13591367
}
13601368

13611369
cfg_if! {

src/unix/bsd/freebsdlike/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub type pthread_key_t = ::c_int;
1010
pub type tcflag_t = ::c_uint;
1111
pub type speed_t = ::c_uint;
1212
pub type nl_item = ::c_int;
13+
pub type id_t = i64;
1314

1415
pub enum timezone {}
1516

@@ -749,6 +750,8 @@ extern {
749750
pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
750751
stackaddr: *mut *mut ::c_void,
751752
stacksize: *mut ::size_t) -> ::c_int;
753+
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
754+
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
752755
}
753756

754757
cfg_if! {

src/unix/bsd/openbsdlike/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub type speed_t = ::c_uint;
1010
pub type tcflag_t = ::c_uint;
1111
pub type nl_item = c_long;
1212
pub type clockid_t = ::c_int;
13+
pub type id_t = ::uint32_t;
1314

1415
pub enum timezone {}
1516

@@ -472,6 +473,8 @@ extern {
472473
name: *mut ::c_char,
473474
termp: *mut termios,
474475
winp: *mut ::winsize) -> ::pid_t;
476+
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
477+
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
475478
}
476479

477480
cfg_if! {

src/unix/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ pub const LOG_NOWAIT: ::c_int = 0x10;
181181
pub const LOG_PRIMASK: ::c_int = 7;
182182
pub const LOG_FACMASK: ::c_int = 0x3f8;
183183

184+
pub const PRIO_PROCESS: ::c_int = 0;
185+
pub const PRIO_PGRP: ::c_int = 1;
186+
pub const PRIO_USER: ::c_int = 2;
187+
188+
pub const PRIO_MIN: ::c_int = -20;
189+
pub const PRIO_MAX: ::c_int = 20;
190+
184191
cfg_if! {
185192
if #[cfg(dox)] {
186193
// on dox builds don't pull in anything
@@ -773,6 +780,9 @@ extern {
773780
pub fn closelog();
774781
pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
775782
pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
783+
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
784+
link_name = "nice$UNIX2003")]
785+
pub fn nice(incr: ::c_int) -> ::c_int;
776786
}
777787

778788
cfg_if! {

src/unix/notbsd/android/b32.rs

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
139139
__reserved: [0; 12],
140140
};
141141
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
142+
pub const CPU_SETSIZE: ::size_t = 32;
143+
pub const __CPU_BITS: ::size_t = 32;
142144

143145
extern {
144146
pub fn timegm64(tm: *const ::tm) -> ::time64_t;

src/unix/notbsd/android/b64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
149149
__reserved: [0; 36],
150150
};
151151
pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 4;
152+
pub const CPU_SETSIZE: ::size_t = 1024;
153+
pub const __CPU_BITS: ::size_t = 64;
152154

153155
extern {
154156
pub fn timegm(tm: *const ::tm) -> ::time64_t;

src/unix/notbsd/android/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub type nfds_t = ::c_uint;
2121
pub type rlim_t = ::c_ulong;
2222
pub type dev_t = ::c_ulong;
2323
pub type ino_t = ::c_ulong;
24+
pub type __CPU_BITTYPE = ::c_ulong;
2425

2526
s! {
2627
pub struct dirent {
@@ -87,6 +88,13 @@ s! {
8788
pub l_len: ::off_t,
8889
pub l_pid: ::pid_t,
8990
}
91+
92+
pub struct cpu_set_t {
93+
#[cfg(target_pointer_width = "64")]
94+
__bits: [__CPU_BITTYPE; 16],
95+
#[cfg(target_pointer_width = "32")]
96+
__bits: [__CPU_BITTYPE; 1],
97+
}
9098
}
9199

92100
pub const BUFSIZ: ::c_uint = 1024;
@@ -546,6 +554,11 @@ extern {
546554
sevlen: ::size_t,
547555
flags: ::c_int) -> ::c_int;
548556
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
557+
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
558+
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
559+
pub fn __sched_cpualloc(count: ::size_t) -> *mut ::cpu_set_t;
560+
pub fn __sched_cpufree(set: *mut ::cpu_set_t);
561+
pub fn __sched_cpucount(setsize: ::size_t, set: *mut cpu_set_t) -> ::c_int;
549562
}
550563

551564
cfg_if! {

src/unix/notbsd/linux/musl/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ pub const CLOCK_TAI: ::clockid_t = 11;
173173
extern {
174174
pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
175175
pub fn ptrace(request: ::c_int, ...) -> ::c_long;
176+
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
177+
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
176178
}
177179

178180
cfg_if! {

src/unix/notbsd/linux/other/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub type fsblkcnt_t = ::c_ulong;
22
pub type fsfilcnt_t = ::c_ulong;
33
pub type rlim_t = c_ulong;
4+
pub type __priority_which_t = ::c_uint;
45

56
s! {
67
pub struct sigaction {
@@ -495,6 +496,9 @@ extern {
495496
pub fn pthread_attr_setaffinity_np(attr: *mut ::pthread_attr_t,
496497
cpusetsize: ::size_t,
497498
cpuset: *const ::cpu_set_t) -> ::c_int;
499+
pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
500+
pub fn setpriority(which: ::__priority_which_t, who: ::id_t,
501+
prio: ::c_int) -> ::c_int;
498502
pub fn pthread_getaffinity_np(thread: ::pthread_t,
499503
cpusetsize: ::size_t,
500504
cpuset: *mut ::cpu_set_t) -> ::c_int;

src/unix/notbsd/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub type speed_t = ::c_uint;
66
pub type tcflag_t = ::c_uint;
77
pub type loff_t = ::c_longlong;
88
pub type clockid_t = ::c_int;
9+
pub type id_t = ::c_uint;
910

1011
pub enum timezone {}
1112

src/unix/solaris/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -907,5 +907,7 @@ extern {
907907
pub fn getprogname() -> *const ::c_char;
908908
pub fn setprogname(name: *const ::c_char);
909909
pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int;
910+
pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int;
911+
pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int;
910912
}
911913

0 commit comments

Comments
 (0)