include/linux/units.h
Source file repositories/reference/linux-study-clean/include/linux/units.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/units.h- Extension
.h- Size
- 3709 bytes
- Lines
- 145
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
Dependency Surface
linux/bits.hlinux/math.h
Detected Declarations
function milli_kelvin_to_millicelsiusfunction millicelsius_to_milli_kelvinfunction kelvin_to_millicelsiusfunction millicelsius_to_kelvinfunction deci_kelvin_to_celsiusfunction celsius_to_deci_kelvinfunction deci_kelvin_to_millicelsius_with_offsetfunction deci_kelvin_to_millicelsiusfunction millicelsius_to_deci_kelvinfunction kelvin_to_celsiusfunction celsius_to_kelvin
Annotated Snippet
#ifndef _LINUX_UNITS_H
#define _LINUX_UNITS_H
#include <linux/bits.h>
#include <linux/math.h>
/* Metric prefixes in accordance with Système international (d'unités) */
#define PETA 1000000000000000ULL
#define TERA 1000000000000ULL
#define GIGA 1000000000UL
#define MEGA 1000000UL
#define KILO 1000UL
#define HECTO 100UL
#define DECA 10UL
#define DECI 10UL
#define CENTI 100UL
#define MILLI 1000UL
#define MICRO 1000000UL
#define NANO 1000000000UL
#define PICO 1000000000000ULL
#define FEMTO 1000000000000000ULL
/*
* Percentage and related scaling units
*
* These macros define scaling factors used to convert between ratio and
* percentage-based representations with different decimal resolutions.
* They are used for precise fractional calculations in engineering, finance,
* and measurement applications.
*
* Examples:
* 1% = 0.01 = 1 / PERCENT
* 0.1% = 0.001 = 1 / PERMILLE
* 0.01% = 0.0001 = 1 / PERMYRIAD (1 basis point)
* 0.001% = 0.00001 = 1 / PERCENTMILLE
*/
#define PERCENT 100
#define PERMILLE 1000
#define PERMYRIAD 10000
#define PERCENTMILLE 100000
#define NANOHZ_PER_HZ 1000000000UL
#define MICROHZ_PER_HZ 1000000UL
#define MILLIHZ_PER_HZ 1000UL
/* Hz based multipliers */
#define HZ_PER_KHZ 1000UL
#define HZ_PER_MHZ 1000000UL
#define HZ_PER_GHZ 1000000000UL
/* kHz based multipliers */
#define KHZ_PER_MHZ 1000UL
#define KHZ_PER_GHZ 1000000UL
#define MILLIWATT_PER_WATT 1000UL
#define MICROWATT_PER_MILLIWATT 1000UL
#define MICROWATT_PER_WATT 1000000UL
#define MICROJOULE_PER_JOULE 1000000UL
#define NANOJOULE_PER_JOULE 1000000000UL
#define BYTES_PER_KBIT (KILO / BITS_PER_BYTE)
#define BYTES_PER_MBIT (MEGA / BITS_PER_BYTE)
#define BYTES_PER_GBIT (GIGA / BITS_PER_BYTE)
#define ABSOLUTE_ZERO_MILLICELSIUS -273150
static inline long milli_kelvin_to_millicelsius(long t)
{
return t + ABSOLUTE_ZERO_MILLICELSIUS;
}
static inline long millicelsius_to_milli_kelvin(long t)
{
return t - ABSOLUTE_ZERO_MILLICELSIUS;
}
#define MILLIDEGREE_PER_DEGREE 1000
#define MILLIDEGREE_PER_DECIDEGREE 100
static inline long kelvin_to_millicelsius(long t)
{
return milli_kelvin_to_millicelsius(t * MILLIDEGREE_PER_DEGREE);
}
static inline long millicelsius_to_kelvin(long t)
{
t = millicelsius_to_milli_kelvin(t);
return DIV_ROUND_CLOSEST(t, MILLIDEGREE_PER_DEGREE);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/math.h`.
- Detected declarations: `function milli_kelvin_to_millicelsius`, `function millicelsius_to_milli_kelvin`, `function kelvin_to_millicelsius`, `function millicelsius_to_kelvin`, `function deci_kelvin_to_celsius`, `function celsius_to_deci_kelvin`, `function deci_kelvin_to_millicelsius_with_offset`, `function deci_kelvin_to_millicelsius`, `function millicelsius_to_deci_kelvin`, `function kelvin_to_celsius`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.