about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail-dep/libc/affinity.rs
blob: 3acbd83d0e5f53c98f5b60ae7edd0f507b244b65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//@only-target: linux # these are Linux-specific APIs
//@compile-flags: -Zmiri-disable-isolation -Zmiri-num-cpus=4

fn main() {
    use std::mem::size_of;

    use libc::{cpu_set_t, sched_setaffinity};

    // If pid is zero, then the calling thread is used.
    const PID: i32 = 0;

    let cpuset: cpu_set_t = unsafe { core::mem::MaybeUninit::zeroed().assume_init() };

    let err = unsafe { sched_setaffinity(PID, size_of::<cpu_set_t>() + 1, &cpuset) }; //~ ERROR: memory access failed
    assert_eq!(err, 0);
}