def from_uint32s(one: int, two: int) -> t.Set[CAP]: return { *{CAP(bit) for bit in bits(one, one_indexed=False)}, *{CAP(bit + 32) for bit in bits(two, one_indexed=False)} }
def from_bytes(cls: t.Type[T], data: bytes) -> T: struct = ffi.cast('cpu_set_t*', ffi.from_buffer(data)) ret: t.List[int] = [] for i, val in enumerate(getattr(struct, '__bits')): inc = (64 * i) for bit in bits(val, one_indexed=False): ret.append(bit) return cls(ret)
def from_cffi(cls: t.Type[T], struct: t.Any) -> T: return cls({SIG(bit) for bit in bits(struct.val)})