Skip to content

Commit

Permalink
Auto merge of #2579 - devnexen:sd14_linux_sched_compat, r=Amanieu
Browse files Browse the repository at this point in the history
freebsd 14 adding linux sched api compatibility fn.
  • Loading branch information
bors committed Dec 9, 2021
2 parents 1725ca0 + 75dad06 commit ba77f26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,8 @@ fn test_freebsd(target: &str) {
_ => &mut cfg,
};

// For sched linux compat fn
cfg.define("_WITH_CPU_SET_T", None);
// Required for `getline`:
cfg.define("_WITH_GETLINE", None);
// Required for making freebsd11_stat available in the headers
Expand Down Expand Up @@ -2224,6 +2226,13 @@ fn test_freebsd(target: &str) {
// https://github.com/gnzlbg/ctest/issues/68
"lio_listio" => true,

// Those are introduced in FreeBSD 14.
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu"
if Some(14) > freebsd_ver =>
{
true
}

_ => false,
}
});
Expand Down
10 changes: 10 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3976,6 +3976,16 @@ extern "C" {
cpusetp: *const cpuset_t,
) -> ::c_int;

// sched.h linux compatibility api
pub fn sched_getaffinity(pid: ::pid_t, cpusetsz: ::size_t, cpuset: *mut ::cpuset_t) -> ::c_int;
// FIXME: the first argument's type might not be correct, fix later if that changes.
pub fn sched_setaffinity(
pid: ::c_int,
cpusetsz: ::size_t,
cpuset: *const ::cpuset_t,
) -> ::c_int;
pub fn sched_getcpu() -> ::c_int;

pub fn pthread_mutex_consistent(mutex: *mut ::pthread_mutex_t) -> ::c_int;

pub fn pthread_mutexattr_getrobust(
Expand Down

0 comments on commit ba77f26

Please sign in to comment.