1use std::{iter, mem};
2
3use crate::{Errno, kernel::errno};
4
5pub mod signal;
6pub mod timer;
7
8pub mod affinity;
9pub mod raw;
10
11cfg_select! {
12 target_arch = "aarch64" => {
13 mod aarch64;
14 use aarch64::crc32;
15 }
16 target_arch = "x86_64" => {
17 mod x86_64;
18 use x86_64::crc32;
19 }
20 _ => {
21 mod scalar;
22 use scalar::crc32;
23 }
24}
25
26pub const STACK_MIN: usize = libc::PTHREAD_STACK_MIN;
28
29pub trait Thread: errno::Source {
31 type Cpus: DoubleEndedIterator<Item = affinity::raw::Cpu>
32 + ExactSizeIterator
33 + iter::FusedIterator;
34 type Timer: crate::Timer;
35 type Receiver: signal::raw::Receiver;
36
37 fn current() -> Result<Self::Cpus, affinity::Error>;
38 fn bind(cpu: affinity::raw::Cpu) -> Result<(), affinity::Error>;
39
40 fn crc32() -> Option<bool> {
42 crc32()
43 }
44
45 fn entropy<const N: usize>(
47 bytes: &mut mem::MaybeUninit<[u8; N]>,
48 ) -> Result<&mut [u8; N], Errno> {
49 raw::entropy::<Self, N>(bytes)
50 }
51}