| // SPDX-License-Identifier: GPL-2.0-only |
| #include <linux/kernel.h> |
| #include <linux/export.h> |
| * This implements the binary GCD algorithm. (Often attributed to Stein, |
| * but as Knuth has noted, appears in a first-century Chinese math text.) |
| * This is faster than the division-based algorithm even on x86, which |
| * has decent hardware division. |
| #if !defined(CONFIG_CPU_NO_EFFICIENT_FFS) |
| /* If __ffs is available, the even/odd algorithm benchmarks slower. */ |
| * gcd - calculate and return the greatest common divisor of 2 unsigned longs |
| unsigned long gcd(unsigned long a, unsigned long b) |
| /* If normalization is done by loops, the even/odd algorithm is a win. */ |
| unsigned long gcd(unsigned long a, unsigned long b) |