Skip to content

Commit c5e165f

Browse files
authored
Merge pull request #3963 from biabbas/vxworks_threads
pthread constants and functions for VxWorks
2 parents c988312 + fea199a commit c5e165f

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

src/vxworks/mod.rs

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ s! {
253253
}
254254

255255
// b_struct__Sched_param.h
256-
pub struct _Sched_param {
256+
pub struct sched_param {
257257
pub sched_priority: ::c_int, /* scheduling priority */
258258
pub sched_ss_low_priority: ::c_int, /* low scheduling priority */
259259
pub sched_ss_repl_period: ::_Timespec, /* replenishment period */
@@ -274,7 +274,7 @@ s! {
274274
pub threadAttrSchedpolicy : ::c_int,
275275
pub threadAttrName : *mut ::c_char,
276276
pub threadAttrOptions : ::c_int,
277-
pub threadAttrSchedparam : ::_Sched_param,
277+
pub threadAttrSchedparam : ::sched_param,
278278
}
279279

280280
// signal.h
@@ -613,6 +613,19 @@ pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
613613
pub const PTHREAD_STACK_MIN: usize = 4096;
614614
pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30;
615615

616+
//sched.h
617+
pub const SCHED_FIFO: ::c_int = 0x01;
618+
pub const SCHED_RR: ::c_int = 0x02;
619+
pub const SCHED_OTHER: ::c_int = 0x04;
620+
pub const SCHED_SPORADIC: ::c_int = 0x08;
621+
pub const PRIO_PROCESS: ::c_uint = 0;
622+
pub const SCHED_FIFO_HIGH_PRI: ::c_int = 255;
623+
pub const SCHED_FIFO_LOW_PRI: ::c_int = 0;
624+
pub const SCHED_RR_HIGH_PRI: ::c_int = 255;
625+
pub const SCHED_RR_LOW_PRI: ::c_int = 0;
626+
pub const SCHED_SPORADIC_HIGH_PRI: ::c_int = 255;
627+
pub const SCHED_SPORADIC_LOW_PRI: ::c_int = 0;
628+
616629
// ERRNO STUFF
617630
pub const ERROR: ::c_int = -1;
618631
pub const OK: ::c_int = 0;
@@ -1388,6 +1401,29 @@ extern "C" {
13881401
value: *mut ::c_void,
13891402
) -> ::c_int;
13901403

1404+
//pthread.h
1405+
pub fn pthread_setschedparam(
1406+
native: ::pthread_t,
1407+
policy: ::c_int,
1408+
param: *const ::sched_param,
1409+
) -> ::c_int;
1410+
1411+
//pthread.h
1412+
pub fn pthread_getschedparam(
1413+
native: ::pthread_t,
1414+
policy: *mut ::c_int,
1415+
param: *mut ::sched_param,
1416+
) -> ::c_int;
1417+
1418+
//pthread.h
1419+
pub fn pthread_attr_setinheritsched(
1420+
attr: *mut ::pthread_attr_t,
1421+
inheritsched: ::c_int,
1422+
) -> ::c_int;
1423+
1424+
//pthread.h
1425+
pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int;
1426+
13911427
// pthread.h
13921428
pub fn pthread_attr_destroy(thread: *mut ::pthread_attr_t) -> ::c_int;
13931429

@@ -1400,6 +1436,7 @@ extern "C" {
14001436
parent: ::Option<unsafe extern "C" fn()>,
14011437
child: ::Option<unsafe extern "C" fn()>,
14021438
) -> ::c_int;
1439+
14031440
// stat.h
14041441
pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
14051442

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

1794+
//sched.h
1795+
pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
1796+
1797+
//sched.h
1798+
pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
1799+
1800+
//sched.h
1801+
pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int;
1802+
1803+
//sched.h
1804+
pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
1805+
1806+
//sched.h
1807+
pub fn sched_setscheduler(
1808+
pid: ::pid_t,
1809+
policy: ::c_int,
1810+
param: *const ::sched_param,
1811+
) -> ::c_int;
1812+
1813+
//sched.h
1814+
pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
1815+
1816+
//sched.h
1817+
pub fn sched_rr_get_interval(pid: ::pid_t, tp: *mut ::timespec) -> ::c_int;
1818+
17571819
// sched.h
17581820
pub fn sched_yield() -> ::c_int;
17591821

0 commit comments

Comments
 (0)