Skip to content

Commit

Permalink
VxWorks
Browse files Browse the repository at this point in the history
1. Rename Schedparam to match other unix platforms
2. Add Pthread functions and constants
  • Loading branch information
biabbas committed Oct 14, 2024
1 parent fbec928 commit b5d9955
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 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,12 @@ 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;

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;

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

pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;

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

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

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

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 Down

0 comments on commit b5d9955

Please sign in to comment.