Skip to content

Commit e14de14

Browse files
committed
fix compile
1 parent bec28bd commit e14de14

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/sched.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,16 @@ mod sched_priority {
326326
use crate::errno::Errno;
327327
use crate::unistd::Pid;
328328
use crate::Result;
329-
use libc::{self, c_int};
329+
use libc;
330330

331331
#[repr(C)]
332+
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
332333
pub struct SchedParam {
333-
pub sched_priority: c_int,
334+
pub sched_priority: libc::c_int,
334335
}
335336

336337
impl SchedParam {
337-
pub fn from_priority(priority: c_int) -> Self {
338+
pub fn from_priority(priority: libc::c_int) -> Self {
338339
SchedParam {
339340
sched_priority: priority,
340341
}
@@ -357,6 +358,7 @@ mod sched_priority {
357358
}
358359

359360
libc_enum! {
361+
#[repr(i32)]
360362
pub enum Scheduler {
361363
SCHED_OTHER,
362364
SCHED_FIFO,
@@ -365,17 +367,17 @@ mod sched_priority {
365367
SCHED_IDLE,
366368
SCHED_DEADLINE,
367369
}
368-
impl TryFrom<c_int>
370+
impl TryFrom<libc::c_int>
369371
}
370372

371-
pub fn sched_get_priority_max(sched: Scheduler) -> Result<c_int> {
372-
let res = unsafe { libc::sched_get_priority_max(sched as c_int) };
373-
Errno::result(res).map(|int| int as c_int)
373+
pub fn sched_get_priority_max(sched: Scheduler) -> Result<libc::c_int> {
374+
let res = unsafe { libc::sched_get_priority_max(sched as libc::c_int) };
375+
Errno::result(res).map(|int| int as libc::c_int)
374376
}
375377

376-
pub fn sched_get_priority_min(sched: Scheduler) -> Result<c_int> {
377-
let res = unsafe { libc::sched_get_priority_min(sched as c_int) };
378-
Errno::result(res).map(|int| int as c_int)
378+
pub fn sched_get_priority_min(sched: Scheduler) -> Result<libc::c_int> {
379+
let res = unsafe { libc::sched_get_priority_min(sched as libc::c_int) };
380+
Errno::result(res).map(|int| int as libc::c_int)
379381
}
380382

381383
pub fn sched_getscheduler(pid: Pid) -> Result<Scheduler> {
@@ -391,7 +393,7 @@ mod sched_priority {
391393
) -> Result<()> {
392394
let param: libc::sched_param = param.into();
393395
let res = unsafe {
394-
libc::sched_setscheduler(pid.into(), sched as c_int, &param)
396+
libc::sched_setscheduler(pid.into(), sched as libc::c_int, &param)
395397
};
396398

397399
Errno::result(res).map(drop)

0 commit comments

Comments
 (0)