Skip to content

Commit

Permalink
VxWorks Sched_param renamed, pthread functions and constants added
Browse files Browse the repository at this point in the history
(backport <rust-lang#3963>)
(cherry picked from commit fea199a)
  • Loading branch information
biabbas authored and tgross35 committed Oct 16, 2024
1 parent b4a2e15 commit f39e871
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions src/vxworks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ s! {
}

// b_struct__Sched_param.h
pub struct _Sched_param {
pub struct sched_param {
pub sched_priority: ::c_int, /* scheduling priority */
pub sched_ss_low_priority: ::c_int, /* low scheduling priority */
pub sched_ss_repl_period: ::_Timespec, /* replenishment period */
Expand All @@ -274,7 +274,7 @@ s! {
pub threadAttrSchedpolicy : ::c_int,
pub threadAttrName : *mut ::c_char,
pub threadAttrOptions : ::c_int,
pub threadAttrSchedparam : ::_Sched_param,
pub threadAttrSchedparam : ::sched_param,
}

// signal.h
Expand Down Expand Up @@ -613,6 +613,19 @@ pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
pub const PTHREAD_STACK_MIN: usize = 4096;
pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30;

//sched.h
pub const SCHED_FIFO: ::c_int = 0x01;
pub const SCHED_RR: ::c_int = 0x02;
pub const SCHED_OTHER: ::c_int = 0x04;
pub const SCHED_SPORADIC: ::c_int = 0x08;
pub const PRIO_PROCESS: ::c_uint = 0;
pub const SCHED_FIFO_HIGH_PRI: ::c_int = 255;
pub const SCHED_FIFO_LOW_PRI: ::c_int = 0;
pub const SCHED_RR_HIGH_PRI: ::c_int = 255;
pub const SCHED_RR_LOW_PRI: ::c_int = 0;
pub const SCHED_SPORADIC_HIGH_PRI: ::c_int = 255;
pub const SCHED_SPORADIC_LOW_PRI: ::c_int = 0;

// ERRNO STUFF
pub const ERROR: ::c_int = -1;
pub const OK: ::c_int = 0;
Expand Down Expand Up @@ -1388,6 +1401,29 @@ extern "C" {
value: *mut ::c_void,
) -> ::c_int;

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

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

//pthread.h
pub fn pthread_attr_setinheritsched(
attr: *mut ::pthread_attr_t,
inheritsched: ::c_int,
) -> ::c_int;

//pthread.h
pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int;

// pthread.h
pub fn pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int;

Expand All @@ -1400,6 +1436,7 @@ extern "C" {
parent: ::Option<unsafe extern "C" fn()>,
child: ::Option<unsafe extern "C" fn()>,
) -> ::c_int;

// stat.h
pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;

Expand Down Expand Up @@ -1754,6 +1791,31 @@ extern "C" {
// dirent.h
pub fn closedir(ptr: *mut ::DIR) -> ::c_int;

//sched.h
pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;

//sched.h
pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;

//sched.h
pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int;

//sched.h
pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;

//sched.h
pub fn sched_setscheduler(
pid: ::pid_t,
policy: ::c_int,
param: *const ::sched_param,
) -> ::c_int;

//sched.h
pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;

//sched.h
pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int;

// sched.h
pub fn sched_yield() -> ::c_int;

Expand Down

0 comments on commit f39e871

Please sign in to comment.