File tree Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Expand file tree Collapse file tree 4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ fn main() {
13
13
let apple = target. contains ( "apple" ) ;
14
14
let musl = target. contains ( "musl" ) ;
15
15
let freebsd = target. contains ( "freebsd" ) ;
16
+ let mips = target. contains ( "mips" ) ;
16
17
let bsdlike = freebsd || apple;
17
18
let mut cfg = ctest:: TestGenerator :: new ( ) ;
18
19
@@ -112,10 +113,12 @@ fn main() {
112
113
if !musl {
113
114
cfg. header ( "linux/netlink.h" ) ;
114
115
}
116
+ cfg. header ( "sched.h" ) ;
115
117
}
116
118
117
119
if freebsd {
118
120
cfg. header ( "pthread_np.h" ) ;
121
+ cfg. header ( "sched.h" ) ;
119
122
}
120
123
121
124
cfg. type_name ( move |ty, is_struct| {
@@ -222,6 +225,8 @@ fn main() {
222
225
"RLIMIT_NLIMITS" |
223
226
"TCP_COOKIE_TRANSACTIONS" |
224
227
"RLIMIT_RTTIME" if musl => true ,
228
+ // work around super old mips toolchain
229
+ "SCHED_IDLE" => mips,
225
230
226
231
_ => false ,
227
232
}
Original file line number Diff line number Diff line change 99
99
pub f_fsid: :: c_ulong,
100
100
pub f_namemax: :: c_ulong,
101
101
}
102
+
103
+ pub struct sched_param {
104
+ pub sched_priority: :: c_int,
105
+ }
102
106
}
103
107
104
108
pub const EXIT_FAILURE : :: c_int = 1 ;
@@ -514,6 +518,10 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _;
514
518
pub const PTHREAD_RWLOCK_INITIALIZER : pthread_rwlock_t = 0 as * mut _ ;
515
519
pub const PTHREAD_MUTEX_RECURSIVE : :: c_int = 2 ;
516
520
521
+ pub const SCHED_FIFO : :: c_int = 1 ;
522
+ pub const SCHED_OTHER : :: c_int = 2 ;
523
+ pub const SCHED_RR : :: c_int = 3 ;
524
+
517
525
extern {
518
526
pub fn mprotect ( addr : * const :: c_void , len : :: size_t , prot : :: c_int )
519
527
-> :: c_int ;
@@ -536,6 +544,8 @@ extern {
536
544
pub fn pthread_set_name_np ( tid : :: pthread_t , name : * const :: c_char ) ;
537
545
pub fn posix_fallocate ( fd : :: c_int , offset : :: off_t ,
538
546
len : :: off_t ) -> :: c_int ;
547
+ pub fn sched_setscheduler ( pid : :: pid_t , policy : :: c_int , param : * const sched_param ) -> :: c_int ;
548
+ pub fn sched_getscheduler ( pid : :: pid_t ) -> :: c_int ;
539
549
}
540
550
541
551
cfg_if ! {
Original file line number Diff line number Diff line change @@ -281,6 +281,12 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
281
281
pub const PTHREAD_MUTEX_RECURSIVE : :: c_int = 1 ;
282
282
pub const __SIZEOF_PTHREAD_COND_T: usize = 48 ;
283
283
284
+ pub const SCHED_OTHER : :: c_int = 0 ;
285
+ pub const SCHED_FIFO : :: c_int = 1 ;
286
+ pub const SCHED_RR : :: c_int = 2 ;
287
+ pub const SCHED_BATCH : :: c_int = 3 ;
288
+ pub const SCHED_IDLE : :: c_int = 5 ;
289
+
284
290
extern {
285
291
pub fn shm_open ( name : * const c_char , oflag : :: c_int ,
286
292
mode : mode_t ) -> :: c_int ;
Original file line number Diff line number Diff line change 86
86
pub tm_gmtoff: :: c_long,
87
87
pub tm_zone: * const :: c_char,
88
88
}
89
+
90
+ pub struct sched_param {
91
+ pub sched_priority: :: c_int,
92
+ #[ cfg( target_env = "musl" ) ]
93
+ pub sched_ss_low_priority: :: c_int,
94
+ #[ cfg( target_env = "musl" ) ]
95
+ pub sched_ss_repl_period: :: timespec,
96
+ #[ cfg( target_env = "musl" ) ]
97
+ pub sched_ss_init_budget: :: timespec,
98
+ #[ cfg( target_env = "musl" ) ]
99
+ pub sched_ss_max_repl: :: c_int,
100
+ }
89
101
}
90
102
91
103
// intentionally not public, only used for fd_set
@@ -377,6 +389,10 @@ extern {
377
389
pub fn memalign ( align : :: size_t , size : :: size_t ) -> * mut :: c_void ;
378
390
pub fn setgroups ( ngroups : :: size_t ,
379
391
ptr : * const :: gid_t ) -> :: c_int ;
392
+ pub fn sched_setscheduler ( pid : :: pid_t , policy : :: c_int , param : * const sched_param ) -> :: c_int ;
393
+ pub fn sched_getscheduler ( pid : :: pid_t ) -> :: c_int ;
394
+ pub fn sched_get_priority_max ( policy : :: c_int ) -> :: c_int ;
395
+ pub fn sched_get_priority_min ( policy : :: c_int ) -> :: c_int ;
380
396
}
381
397
382
398
cfg_if ! {
You can’t perform that action at this time.
0 commit comments