![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef __LINUX_PRIME_NUMBERS_H 0003 #define __LINUX_PRIME_NUMBERS_H 0004 0005 #include <linux/types.h> 0006 0007 bool is_prime_number(unsigned long x); 0008 unsigned long next_prime_number(unsigned long x); 0009 0010 /** 0011 * for_each_prime_number - iterate over each prime upto a value 0012 * @prime: the current prime number in this iteration 0013 * @max: the upper limit 0014 * 0015 * Starting from the first prime number 2 iterate over each prime number up to 0016 * the @max value. On each iteration, @prime is set to the current prime number. 0017 * @max should be less than ULONG_MAX to ensure termination. To begin with 0018 * @prime set to 1 on the first iteration use for_each_prime_number_from() 0019 * instead. 0020 */ 0021 #define for_each_prime_number(prime, max) \ 0022 for_each_prime_number_from((prime), 2, (max)) 0023 0024 /** 0025 * for_each_prime_number_from - iterate over each prime upto a value 0026 * @prime: the current prime number in this iteration 0027 * @from: the initial value 0028 * @max: the upper limit 0029 * 0030 * Starting from @from iterate over each successive prime number up to the 0031 * @max value. On each iteration, @prime is set to the current prime number. 0032 * @max should be less than ULONG_MAX, and @from less than @max, to ensure 0033 * termination. 0034 */ 0035 #define for_each_prime_number_from(prime, from, max) \ 0036 for (prime = (from); prime <= (max); prime = next_prime_number(prime)) 0037 0038 #endif /* !__LINUX_PRIME_NUMBERS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |