Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizon (Nintendo 3DS) pthread functions and non-portable extensions #2715

Merged
merged 6 commits into from
Mar 12, 2022
42 changes: 42 additions & 0 deletions src/unix/newlib/horizon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ s! {
pub sun_family: ::sa_family_t,
pub sun_path: [::c_char; 104usize],
}

pub struct sched_param {
pub sched_priority: ::c_int,
}
}

pub const SIGEV_NONE: ::c_int = 1;
Expand Down Expand Up @@ -147,6 +151,10 @@ pub const FIONBIO: ::c_ulong = 1;

pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void;

// For pthread get/setschedparam
pub const SCHED_FIFO: ::c_int = 1;
pub const SCHED_RR: ::c_int = 2;

// Horizon OS works doesn't or can't hold any of this information
safe_f! {
pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool {
Expand Down Expand Up @@ -190,5 +198,39 @@ extern "C" {
value: *mut ::c_void,
) -> ::c_int;

pub fn pthread_attr_getschedparam(
attr: *const ::pthread_attr_t,
param: *mut sched_param,
) -> ::c_int;

pub fn pthread_attr_setschedparam(
attr: *mut ::pthread_attr_t,
param: *const sched_param,
) -> ::c_int;

pub fn pthread_attr_getprocessorid_np(
attr: *const ::pthread_attr_t,
processor_id: *mut ::c_int,
) -> ::c_int;

pub fn pthread_attr_setprocessorid_np(
attr: *mut ::pthread_attr_t,
processor_id: ::c_int,
) -> ::c_int;

pub fn pthread_getschedparam(
native: ::pthread_t,
policy: *mut ::c_int,
param: *mut ::sched_param,
) -> ::c_int;

pub fn pthread_setschedparam(
native: ::pthread_t,
policy: ::c_int,
param: *const ::sched_param,
) -> ::c_int;

pub fn pthread_getprocessorid_np() -> ::c_int;

pub fn gethostid() -> ::c_long;
}