summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-04-02 23:14:55 +0000
committerbors <bors@rust-lang.org>2022-04-02 23:14:55 +0000
commit02bdb0a39f414bc5e0434dc48270747b3812e619 (patch)
treebceefa681af903137498765db197ac307aeca212
parentf59a9703842b6536e7cadea08146bcf889fc0fb3 (diff)
parent576f86d26f588a620240ef294994c6e9dcd9d6c2 (diff)
downloadrust-libc-02bdb0a39f414bc5e0434dc48270747b3812e619.tar.gz
Auto merge of #2733 - vityafx:add-pthread-functions-to-bsd, r=Amanieu
Expose more thread bindings for BSD-like OSes. Fixes https://github.com/rust-lang/libc/issues/2721
-rw-r--r--libc-test/semver/netbsd.txt2
-rw-r--r--libc-test/semver/openbsd.txt3
-rw-r--r--src/unix/bsd/netbsdlike/mod.rs14
-rw-r--r--src/unix/bsd/netbsdlike/netbsd/mod.rs10
4 files changed, 22 insertions, 7 deletions
diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt
index a2ce837d18..67a5faa073 100644
--- a/libc-test/semver/netbsd.txt
+++ b/libc-test/semver/netbsd.txt
@@ -1360,6 +1360,7 @@ pthread_condattr_setclock
pthread_getattr_np
pthread_getaffinity_np
pthread_getname_np
+pthread_getschedparam
pthread_kill
pthread_mutex_timedlock
pthread_spin_destroy
@@ -1370,6 +1371,7 @@ pthread_spin_unlock
pthread_spinlock_t
pthread_setaffinity_np
pthread_setname_np
+pthread_setschedparam
ptrace
ptrace_io_desc
ptrace_lwpinfo
diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt
index 30813314d1..0fed559825 100644
--- a/libc-test/semver/openbsd.txt
+++ b/libc-test/semver/openbsd.txt
@@ -1089,10 +1089,12 @@ pthread_attr_getstack
pthread_cancel
pthread_condattr_setclock
pthread_get_name_np
+pthread_getschedparam
pthread_kill
pthread_main_np
pthread_mutex_timedlock
pthread_set_name_np
+pthread_setschedparam
pthread_spin_destroy
pthread_spin_init
pthread_spin_lock
@@ -1120,6 +1122,7 @@ regmatch_t
regoff_t
sched_get_priority_max
sched_get_priority_min
+sched_param
seed48
seed48_deterministic
seekdir
diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs
index 7356e7ae23..d7b23ba4cc 100644
--- a/src/unix/bsd/netbsdlike/mod.rs
+++ b/src/unix/bsd/netbsdlike/mod.rs
@@ -31,6 +31,10 @@ impl ::Clone for sem {
}
s! {
+ pub struct sched_param {
+ pub sched_priority: ::c_int,
+ }
+
pub struct sigaction {
pub sa_sigaction: ::sighandler_t,
pub sa_mask: ::sigset_t,
@@ -724,6 +728,16 @@ extern "C" {
pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int;
pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> ::c_int;
pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> ::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 pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
pub fn getgrouplist(
diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs
index ef5877885f..84f17f1f13 100644
--- a/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -487,10 +487,6 @@ s! {
af_arg: [[::c_char; 10]; 24],
}
- pub struct sched_param {
- pub sched_priority: ::c_int,
- }
-
pub struct kinfo_vmentry {
pub kve_start: u64,
pub kve_end: u64,
@@ -527,7 +523,7 @@ s! {
pub struct posix_spawnattr_t {
pub sa_flags: ::c_short,
pub sa_pgroup: ::pid_t,
- pub sa_schedparam: sched_param,
+ pub sa_schedparam: ::sched_param,
pub sa_schedpolicy: ::c_int,
pub sa_sigdefault: sigset_t,
pub sa_sigmask: sigset_t,
@@ -2516,8 +2512,8 @@ extern "C" {
) -> *mut ::c_void;
pub fn sched_rr_get_interval(pid: ::pid_t, t: *mut ::timespec) -> ::c_int;
- pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int;
- pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int;
+ pub fn sched_setparam(pid: ::pid_t, param: *const ::sched_param) -> ::c_int;
+ pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int;
pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
pub fn sched_setscheduler(
pid: ::pid_t,