kernel

Module sizes

Source
Expand description

Commonly used sizes.

C headers: include/linux/sizes.h.

The top-level SZ_* constants are usize-typed, for use in kernel page arithmetic and similar CPU-side work.

The SizeConstants trait provides the same constants as associated constants on u32, u64, and usize, for use in device address spaces where the address width depends on the hardware. Device drivers frequently need these constants as u64 (or u32) rather than usize, because device address spaces are sized independently of the CPU pointer width.

§Examples

use kernel::{
    page::PAGE_SIZE,
    sizes::{
        SizeConstants,
        SZ_1M, //
    }, //
};

// Module-level constants continue to work without a type qualifier.
let num_pages_in_1m = SZ_1M / PAGE_SIZE;

// Trait associated constants require a type qualifier.
let heap_size = 14 * u64::SZ_1M;
let small = u32::SZ_4K;

Constants§

Traits§