use ::libc::c_int;
use ::libc::c_long;
use ::libc::pthread_t;
use ::libc::size_t;
use ::std::mem::size_of;
const _BITSET_BITS: usize = size_of::<c_long>() * 8;
#[inline(always)]
const fn __howmany(x: usize, y: usize) -> usize
{
(x + (y - 1)) / y
}
#[inline(always)]
const fn __bitset_words(_s: usize) -> usize
{
__howmany(_s, _BITSET_BITS)
}
macro_rules! BITSET_DEFINE
{
($t: tt, $_s: ident) =>
{
pub(crate) type $t = [c_long; __bitset_words($_s)]
}
}
#[inline(always)]
fn __bitset_mask(_s: usize, n: size_t) -> c_long
{
let relative_bit = if __bitset_words(_s) == 1
{
n
}
else
{
n % _BITSET_BITS
};
(1 << relative_bit) as c_long
}
#[inline(always)]
fn __bitset_word(_s: usize, n: size_t) -> usize
{
if __bitset_words(_s) == 1
{
0
}
else
{
n / _BITSET_BITS
}
}
#[inline(always)]
fn BIT_SET(_s: usize, n: size_t, p: &mut _cpuset)
{
p.__bits[__bitset_word(_s, n)] |= __bitset_mask(_s, n)
}
const CPU_MAXSIZE: usize = 256;
const CPU_SETSIZE: usize = CPU_MAXSIZE;
BITSET_DEFINE!(_cpuset, CPU_SETSIZE);
pub(crate) type cpuset_t = _cpuset;
#[inline(always)]
pub(crate) const fn CPU_SET(n: usize, p: &mut _cpuset)
{
BIT_SET(CPU_SETSIZE, n, p)
}
extern "C"
{
pub(crate) fn pthread_setaffinity_np(td: pthread_t, cpusetsize: size_t, cpusetp: *const cpuset_t) -> c_int;
}