#memory-region #format #parser #mechanism #processor #linux #list

cpulist

Parse and emit the Linux 'cpulist' data format used to list processors, memory regions and similar entities

3 releases

Uses new Rust 2024

new 0.0.1-pre.3 Mar 14, 2025
0.0.1-pre.2 Mar 8, 2025

#1110 in Rust patterns

Download history 244/week @ 2025-03-07

244 downloads per month
Used in 5 crates (2 directly)

MIT license

12KB
200 lines

Utilities for parsing and emitting strings in the the cpulist format often used by Linux utilities that work with processor IDs, memory region IDs and similar numeric hardware identifiers.

Example cpulist string: 0,1,2-4,5-9:2,6-10:2

More details in the crate documentation.

This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.


lib.rs:

Utilities for parsing and emitting strings in the the cpulist format often used by Linux utilities that work with processor IDs, memory region IDs and similar numeric hardware identifiers.

Example cpulist string: 0-9,32-35,40

This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.

Format

The value is a comma-separated list of zero or more integers or integer ranges, where each item is either:

  • a single integer (e.g. 1)
  • a range of integers (e.g. 2-4)
  • a range of integers with a stride (step size) operator (e.g. 5-9:2 which is equivalent to 5,7,9)

Whitespace or extra characters are not allowed anywhere in the string.

The identifiers in the list are of size u32.

Example

Basic conversion from/to strings:

The stride operator is also supported for parsing:

Dependencies

~4–16MB
~145K SLoC