Source
x
* searching for sequential primes, see next_prime_number()), but if the number
struct primes {
struct rcu_head rcu;
unsigned long last, sz;
unsigned long primes[];
};
static const struct primes small_primes = {
.last = 61,
.sz = 64,
.primes = {
BIT(2) |
BIT(3) |
BIT(5) |
BIT(7) |
BIT(11) |
BIT(13) |
BIT(17) |
BIT(19) |
BIT(23) |
BIT(29) |
BIT(31) |
BIT(37) |
BIT(41) |
BIT(43) |
BIT(47) |
BIT(53) |
BIT(59) |
BIT(61)
}
};
static const struct primes small_primes = {
.last = 31,
.sz = 32,
.primes = {
BIT(2) |
BIT(3) |
BIT(5) |
BIT(7) |
BIT(11) |
BIT(13) |
BIT(17) |
BIT(19) |
BIT(23) |
BIT(29) |
BIT(31)
}
};
static DEFINE_MUTEX(lock);
static const struct primes __rcu *primes = RCU_INITIALIZER(&small_primes);
static unsigned long selftest_max;
static bool slow_is_prime_number(unsigned long x)
{
unsigned long y = int_sqrt(x);
while (y > 1) {
if ((x % y) == 0)
break;
y--;
}
return y == 1;
}
static unsigned long slow_next_prime_number(unsigned long x)
{
while (x < ULONG_MAX && !slow_is_prime_number(++x))
;
return x;
}
static unsigned long clear_multiples(unsigned long x,
unsigned long *p,
unsigned long start,
unsigned long end)