Skip to content

Commit 02bdb0a

Browse files
committed
Auto merge of #2733 - vityafx:add-pthread-functions-to-bsd, r=Amanieu
Expose more thread bindings for BSD-like OSes. Fixes #2721
2 parents f59a970 + 576f86d commit 02bdb0a

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

libc-test/semver/netbsd.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,7 @@ pthread_condattr_setclock
13601360
pthread_getattr_np
13611361
pthread_getaffinity_np
13621362
pthread_getname_np
1363+
pthread_getschedparam
13631364
pthread_kill
13641365
pthread_mutex_timedlock
13651366
pthread_spin_destroy
@@ -1370,6 +1371,7 @@ pthread_spin_unlock
13701371
pthread_spinlock_t
13711372
pthread_setaffinity_np
13721373
pthread_setname_np
1374+
pthread_setschedparam
13731375
ptrace
13741376
ptrace_io_desc
13751377
ptrace_lwpinfo

libc-test/semver/openbsd.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,10 +1089,12 @@ pthread_attr_getstack
10891089
pthread_cancel
10901090
pthread_condattr_setclock
10911091
pthread_get_name_np
1092+
pthread_getschedparam
10921093
pthread_kill
10931094
pthread_main_np
10941095
pthread_mutex_timedlock
10951096
pthread_set_name_np
1097+
pthread_setschedparam
10961098
pthread_spin_destroy
10971099
pthread_spin_init
10981100
pthread_spin_lock
@@ -1120,6 +1122,7 @@ regmatch_t
11201122
regoff_t
11211123
sched_get_priority_max
11221124
sched_get_priority_min
1125+
sched_param
11231126
seed48
11241127
seed48_deterministic
11251128
seekdir

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ impl ::Clone for sem {
3131
}
3232

3333
s! {
34+
pub struct sched_param {
35+
pub sched_priority: ::c_int,
36+
}
37+
3438
pub struct sigaction {
3539
pub sa_sigaction: ::sighandler_t,
3640
pub sa_mask: ::sigset_t,
@@ -724,6 +728,16 @@ extern "C" {
724728
pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int;
725729
pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int;
726730
pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::c_int;
731+
pub fn pthread_setschedparam(
732+
native: ::pthread_t,
733+
policy: ::c_int,
734+
param: *const sched_param,
735+
) -> ::c_int;
736+
pub fn pthread_getschedparam(
737+
native: ::pthread_t,
738+
policy: *mut ::c_int,
739+
param: *mut sched_param,
740+
) -> ::c_int;
727741
pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
728742

729743
pub fn getgrouplist(

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,6 @@ s! {
487487
af_arg: [[::c_char; 10]; 24],
488488
}
489489

490-
pub struct sched_param {
491-
pub sched_priority: ::c_int,
492-
}
493-
494490
pub struct kinfo_vmentry {
495491
pub kve_start: u64,
496492
pub kve_end: u64,
@@ -527,7 +523,7 @@ s! {
527523
pub struct posix_spawnattr_t {
528524
pub sa_flags: ::c_short,
529525
pub sa_pgroup: ::pid_t,
530-
pub sa_schedparam: sched_param,
526+
pub sa_schedparam: ::sched_param,
531527
pub sa_schedpolicy: ::c_int,
532528
pub sa_sigdefault: sigset_t,
533529
pub sa_sigmask: sigset_t,
@@ -2516,8 +2512,8 @@ extern "C" {
25162512
) -> *mut ::c_void;
25172513

25182514
pub fn sched_rr_get_interval(pid: ::pid_t, t: *mut ::timespec) -> ::c_int;
2519-
pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int;
2520-
pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int;
2515+
pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int;
2516+
pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
25212517
pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
25222518
pub fn sched_setscheduler(
25232519
pid: ::pid_t,

0 commit comments

Comments
 (0)