tools/include/linux/math64.h
Source file repositories/reference/linux-study-clean/tools/include/linux/math64.h
File Facts
- System
- Linux kernel
- Corpus path
tools/include/linux/math64.h- Extension
.h- Size
- 1332 bytes
- Lines
- 81
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
linux/types.h
Detected Declarations
function mul_u64_u64_div64function mul_u64_u32_shrfunction mul_u32_u32function mul_u32_u32function mul_u64_u32_shrfunction mul_u64_u64_div64function div_u64
Annotated Snippet
#ifndef _LINUX_MATH64_H
#define _LINUX_MATH64_H
#include <linux/types.h>
#ifdef __x86_64__
static inline u64 mul_u64_u64_div64(u64 a, u64 b, u64 c)
{
u64 q;
asm ("mulq %2; divq %3" : "=a" (q)
: "a" (a), "rm" (b), "rm" (c)
: "rdx");
return q;
}
#define mul_u64_u64_div64 mul_u64_u64_div64
#endif
#ifdef __SIZEOF_INT128__
static inline u64 mul_u64_u32_shr(u64 a, u32 b, unsigned int shift)
{
return (u64)(((unsigned __int128)a * b) >> shift);
}
#else
#ifdef __i386__
static inline u64 mul_u32_u32(u32 a, u32 b)
{
u32 high, low;
asm ("mull %[b]" : "=a" (low), "=d" (high)
: [a] "a" (a), [b] "rm" (b) );
return low | ((u64)high) << 32;
}
#else
static inline u64 mul_u32_u32(u32 a, u32 b)
{
return (u64)a * b;
}
#endif
static inline u64 mul_u64_u32_shr(u64 a, u32 b, unsigned int shift)
{
u32 ah, al;
u64 ret;
al = a;
ah = a >> 32;
ret = mul_u32_u32(al, b) >> shift;
if (ah)
ret += mul_u32_u32(ah, b) << (32 - shift);
return ret;
}
#endif /* __SIZEOF_INT128__ */
#ifndef mul_u64_u64_div64
static inline u64 mul_u64_u64_div64(u64 a, u64 b, u64 c)
{
u64 quot, rem;
quot = a / c;
rem = a % c;
return quot * b + (rem * b) / c;
}
#endif
static inline u64 div_u64(u64 dividend, u32 divisor)
{
return dividend / divisor;
}
#endif /* _LINUX_MATH64_H */
Annotation
- Immediate include surface: `linux/types.h`.
- Detected declarations: `function mul_u64_u64_div64`, `function mul_u64_u32_shr`, `function mul_u32_u32`, `function mul_u32_u32`, `function mul_u64_u32_shr`, `function mul_u64_u64_div64`, `function div_u64`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source 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.