#define pr_fmt(fmt) …
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/prime_numbers.h>
#include <linux/slab.h>
struct primes { … };
#if BITS_PER_LONG == 64
static const struct primes small_primes = …;
#elif BITS_PER_LONG == 32
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)
}
};
#else
#error "unhandled BITS_PER_LONG"
#endif
static DEFINE_MUTEX(lock);
static const struct primes __rcu *primes = …;
static unsigned long selftest_max;
static bool slow_is_prime_number(unsigned long x)
{ … }
static unsigned long slow_next_prime_number(unsigned long x)
{ … }
static unsigned long clear_multiples(unsigned long x,
unsigned long *p,
unsigned long start,
unsigned long end)
{ … }
static bool expand_to_next_prime(unsigned long x)
{ … }
static void free_primes(void)
{ … }
unsigned long next_prime_number(unsigned long x)
{ … }
EXPORT_SYMBOL(…);
bool is_prime_number(unsigned long x)
{ … }
EXPORT_SYMBOL(…);
static void dump_primes(void)
{ … }
static int selftest(unsigned long max)
{ … }
static int __init primes_init(void)
{ … }
static void __exit primes_exit(void)
{ … }
module_init(…) …;
module_exit(primes_exit);
module_param_named(selftest, selftest_max, ulong, 0400);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;