Skip to content

Commit ba77f26

Browse files
committed
Auto merge of #2579 - devnexen:sd14_linux_sched_compat, r=Amanieu
freebsd 14 adding linux sched api compatibility fn.
2 parents 1725ca0 + 75dad06 commit ba77f26

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

libc-test/build.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,8 @@ fn test_freebsd(target: &str) {
17701770
_ => &mut cfg,
17711771
};
17721772

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

2229+
// Those are introduced in FreeBSD 14.
2230+
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu"
2231+
if Some(14) > freebsd_ver =>
2232+
{
2233+
true
2234+
}
2235+
22272236
_ => false,
22282237
}
22292238
});

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3976,6 +3976,16 @@ extern "C" {
39763976
cpusetp: *const cpuset_t,
39773977
) -> ::c_int;
39783978

3979+
// sched.h linux compatibility api
3980+
pub fn sched_getaffinity(pid: ::pid_t, cpusetsz: ::size_t, cpuset: *mut ::cpuset_t) -> ::c_int;
3981+
// FIXME: the first argument's type might not be correct, fix later if that changes.
3982+
pub fn sched_setaffinity(
3983+
pid: ::c_int,
3984+
cpusetsz: ::size_t,
3985+
cpuset: *const ::cpuset_t,
3986+
) -> ::c_int;
3987+
pub fn sched_getcpu() -> ::c_int;
3988+
39793989
pub fn pthread_mutex_consistent(mutex: *mut ::pthread_mutex_t) -> ::c_int;
39803990

39813991
pub fn pthread_mutexattr_getrobust(

0 commit comments

Comments
 (0)