lib/math/lcm.c
Source file repositories/reference/linux-study-clean/lib/math/lcm.c
File Facts
- System
- Linux kernel
- Corpus path
lib/math/lcm.c- Extension
.c- Size
- 482 bytes
- Lines
- 27
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/compiler.hlinux/gcd.hlinux/export.hlinux/lcm.h
Detected Declarations
function lcmfunction lcm_not_zeroexport lcmexport lcm_not_zero
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
#include <linux/compiler.h>
#include <linux/gcd.h>
#include <linux/export.h>
#include <linux/lcm.h>
/* Lowest common multiple */
unsigned long lcm(unsigned long a, unsigned long b)
{
if (a && b)
return (a / gcd(a, b)) * b;
else
return 0;
}
EXPORT_SYMBOL_GPL(lcm);
unsigned long lcm_not_zero(unsigned long a, unsigned long b)
{
unsigned long l = lcm(a, b);
if (l)
return l;
return (b ? : a);
}
EXPORT_SYMBOL_GPL(lcm_not_zero);
Annotation
- Immediate include surface: `linux/compiler.h`, `linux/gcd.h`, `linux/export.h`, `linux/lcm.h`.
- Detected declarations: `function lcm`, `function lcm_not_zero`, `export lcm`, `export lcm_not_zero`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.