Skip to content

Commit 75dad06

Browse files
committed
freebsd 14 adding linux sched api compatibility fn.
1 parent e497f18 commit 75dad06

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
@@ -1767,6 +1767,8 @@ fn test_freebsd(target: &str) {
17671767
_ => &mut cfg,
17681768
};
17691769

1770+
// For sched linux compat fn
1771+
cfg.define("_WITH_CPU_SET_T", None);
17701772
// Required for `getline`:
17711773
cfg.define("_WITH_GETLINE", None);
17721774
// Required for making freebsd11_stat available in the headers
@@ -2221,6 +2223,13 @@ fn test_freebsd(target: &str) {
22212223
// https://github.com/gnzlbg/ctest/issues/68
22222224
"lio_listio" => true,
22232225

2226+
// Those are introduced in FreeBSD 14.
2227+
"sched_getaffinity" | "sched_setaffinity" | "sched_getcpu"
2228+
if Some(14) > freebsd_ver =>
2229+
{
2230+
true
2231+
}
2232+
22242233
_ => false,
22252234
}
22262235
});

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)