]> git.ozlabs.org Git - ccan/blob - ccan/eratosthenes/eratosthenes.h
crypto/shachain/tools: update to new rbuf API.
[ccan] / ccan / eratosthenes / eratosthenes.h
1 /* Licensed under LGPLv2+ - see LICENSE file for details */
2 #ifndef CCAN_ERATOSTHENES_H_
3 #define CCAN_ERATOSTHENES_H_
4
5 #include "config.h"
6
7 #include <stdbool.h>
8
9 #include <ccan/bitmap/bitmap.h>
10
11 struct eratosthenes {
12         unsigned long limit;
13         bitmap *b;
14 };
15
16 void eratosthenes_init(struct eratosthenes *s);
17
18 void eratosthenes_reset(struct eratosthenes *s);
19
20 void eratosthenes_sieve(struct eratosthenes *s, unsigned long limit);
21
22 bool eratosthenes_isprime(const struct eratosthenes *s, unsigned long n);
23
24 unsigned long eratosthenes_nextprime(const struct eratosthenes *s,
25                                      unsigned long n);
26
27 #endif /* CCAN_ERATOSTHENES_H_ */