Skip to content
Open
59 changes: 47 additions & 12 deletions src/unix/linux_like/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,53 @@ extern_ty! {
pub enum timezone {}
}

cfg_if! {
if #[cfg(not(any(
target_env = "musl",
target_os = "emscripten",
target_env = "ohos"
)))] {
s! {
pub struct sched_param {
pub sched_priority: c_int,
}
}
} else if #[cfg(musl_v1_2_3)] {
s! {
struct __c_anon_sched_param__reserved2 {
__reserved1: crate::time_t,
__reserved2: c_long,
}

pub struct sched_param {
pub sched_priority: c_int,

__reserved1: c_int,
#[cfg(musl32_time64)]
__reserved2: [c_long; 4],
#[cfg(not(musl32_time64))]
__reserved2: [__c_anon_sched_param__reserved2; 2],
__reserved3: c_int,
}
}
} else {
s! {
pub struct sched_param {
pub sched_priority: c_int,

#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
pub sched_ss_low_priority: c_int,
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
pub sched_ss_repl_period: crate::timespec,
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
pub sched_ss_init_budget: crate::timespec,
#[deprecated(since = "0.2.173", note = "This field has been removed upstream")]
pub sched_ss_max_repl: c_int,
}
}
}
}
Comment on lines +15 to +60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit "musl: time64: update struct sched_param": to keep things a bit cleaner, move these musl definitions to the musl module. Then keep the existing struct sched_param in this module but add the deprecated notes and move it to a cfg_if block with the not(any(musl, emscripten, ohos)) bit.

Also could you put this cfg_if! after the main s! macro with the others? Around line 252 looking at this file currently.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if you wouldn't mind, the musl-specific bits could move directly to the new source structure a src/new/musl/sched.rs. Add pub(crate) mod sched; to src/new/musl/mod.rs and reexport its contents in the musl block at the bottom of new/mod.rs


s! {
// FIXME(1.0): This should not implement `PartialEq`
#[allow(unpredictable_function_pointer_comparisons)]
Expand Down Expand Up @@ -109,18 +156,6 @@ s! {
pub tm_zone: *const c_char,
}

pub struct sched_param {
pub sched_priority: c_int,
#[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_low_priority: c_int,
#[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_repl_period: crate::timespec,
#[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_init_budget: crate::timespec,
#[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))]
pub sched_ss_max_repl: c_int,
}

pub struct Dl_info {
pub dli_fname: *const c_char,
pub dli_fbase: *mut c_void,
Expand Down