primal_sieve/
lib.rs

1//! Highly optimised prime sieves.
2//!
3//! This is designed to be used via the `primal` crate.
4
5// black boxes for pointers; LLVM isn't so happy without
6// them. Unfortunately only usable with 1.59+ asm!, but the code isn't
7// *too* much slower without them.
8#[cfg(feature = "unstable")]
9#[inline(always)]
10fn b<T>(mut p: *mut T) -> *mut T { unsafe { core::arch::asm!("/* {0} */", inout(reg) p) } p }
11#[cfg(not(feature = "unstable"))]
12#[inline(always)]
13fn b<T>(p: *mut T) -> *mut T { p }
14
15#[cfg(feature = "safe")]
16macro_rules! safe_assert {
17    ($x: expr) => {
18        assert!($x);
19    }
20}
21#[cfg(not(feature = "safe"))]
22macro_rules! safe_assert {
23    ($x: expr) => { () }
24}
25
26mod streaming;
27pub use crate::streaming::StreamingSieve;
28pub use crate::streaming::primes::Primes;
29
30// mod wheel6;
31mod wheel;
32mod sieve;
33
34pub use crate::sieve::{Sieve, SievePrimes};