package core:sys/info
Warning: This was generated for -target:windows_amd64 and might not represent every target this package supports.
Overview
Gathers system information on Windows, Linux, macOS, FreeBSD & OpenBSD.
Simply import the package and you'll have access to the OS version, RAM amount and CPU information.
On Windows, GPUs will also be enumerated using the registry.
CPU feature flags can be tested against cpu_features, where applicable, e.g.:
if .aes in info.cpu_features() { ... }
Example:
package main
import "core:fmt"
import si "core:sys/info"
main :: proc() {
fmt.printfln("Odin: %v", ODIN_VERSION)
if version, version_ok := si.os_version(context.allocator); version_ok {
defer si.destroy_os_version(version, context.allocator)
fmt.printfln("OS (full): %v", version.full)
fmt.printfln("OS (rel): %v", version.release)
fmt.printfln("OS: %v", version.os)
fmt.printfln("Kernel: %v", version.kernel)
}
fmt.printfln("CPU: %v", si.cpu_name())
fmt.printfln(" %v", si.cpu_features())
if physical, logical, cores_ok := si.cpu_core_count(); cores_ok {
fmt.printfln("CPU cores: %vc/%vt", physical, logical)
}
if total_ram, free_ram, total_swap, free_swap, ram_ok := si.ram_stats(); ram_ok {
fmt.printfln("RAM: %#.1M/%#.1M", free_ram, total_ram)
fmt.printfln("SWAP: %#.1M/%#.1M", free_swap, total_swap)
}
it: si.GPU_Iterator
for gpu, i in si.iterate_gpus(&it) {
fmt.printfln("%d:", i)
fmt.printfln("\tVendor: %v", gpu.vendor)
fmt.printfln("\tModel: %v", gpu.model)
fmt.printfln("\tVRAM: %#.1M", gpu.vram)
fmt.printfln("\tDriver: %v", gpu.driver)
}
}
/*
Example Windows output:
Odin: dev-2026-02
OS (full): Windows 10 Professional (version: 22H2), build: 19045.6575
OS (rel): 22H2
OS: Version{major = 10, minor = 0, patch = 0}
Kernel: Version{major = 10, minor = 19045, patch = 6575}
CPU: AMD Ryzen 9 5950X 16-Core Processor
CPU_Features{aes, adx, avx, avx2, bmi1, bmi2, erms, fma, os_xsave, pclmulqdq, popcnt, rdrand, rdseed, sha, sse2, sse3, ssse3, sse41, sse42}
CPU cores: 16c/32t
RAM: 32.1 GiB/63.9 GiB
SWAP: 21.6 GiB/73.4 GiB
GPU #0:
Vendor: Advanced Micro Devices, Inc.
Model: AMD Radeon RX 9070
VRAM: 15.9 GiB
Driver: 32.0.22029.1019
Example Linux output:
Odin: dev-2026-02
OS (full): Ubuntu 24.04.3 LTS, Linux 6.6.87.2-microsoft-standard-WSL2
OS (rel): microsoft-standard-WSL2
OS: Version{major = 24, minor = 4, patch = 3}
Kernel: Version{major = 6, minor = 6, patch = 87}
CPU: AMD Ryzen 9 5950X 16-Core Processor
CPU_Features{aes, adx, avx, avx2, bmi1, bmi2, erms, fma, os_xsave, pclmulqdq, popcnt, rdrand, rdseed, sha, sse2, sse3, ssse3, sse41, sse42}
CPU cores: 16c/32t
RAM: 29.2 GiB/31.3 GiB
SWAP: 8.0 GiB/8.0 GiB
Example macOS output:
Odin: dev-2026-02
OS (full): macOS Tahoe 26.3.0 (build 25D125, kernel 25.3.0)
OS (rel): 25D125
OS: Version{major = 26, minor = 3, patch = 0}
Kernel: Version{major = 25, minor = 3, patch = 0}
CPU: Apple M4 Pro
CPU_Features{asimd, floatingpoint, asimdhp, bf16, fcma, fhm, fp16, frint, i8mm, jscvt, rdm, flagm, flagm2, crc32, lse, lrcpc, lrcpc2, aes, pmull, sha1, sha256, sha512, sha3, sb}
CPU cores: 12c/12t
RAM: 0.0 B/24.0 GiB
SWAP: 0.0 B/0.0 B
Example FreeBSD output:
Odin: dev-2026-02
OS (full): FreeBSD 15.0-RELEASE-p2 releng/15.0-n281005-5fb0f8e9e61d GENERIC, revision 199506
OS (rel):
OS: Version{major = 15, minor = 0, patch = 199506}
Kernel: Version{major = 15, minor = 0, patch = 199506}
CPU: AMD Ryzen 9 5950X 16-Core Processor
CPU_Features{aes, fma, os_xsave, pclmulqdq, popcnt, rdrand, sse2, sse3, ssse3, sse41, sse42}
RAM: 7.6 GiB/7.9 GiB
SWAP: 0.0 B/0.0 B
*/
Index
Constants (0)
This section is empty.
Variables (0)
This section is empty.
Procedure Groups (0)
This section is empty.
Types
CPU_Feature ¶
CPU_Feature :: enum u64 { aes, // AES hardware implementation (AES NI) adx, // Multi-precision add-carry instruction extensions avx, // Advanced vector extension avx2, // Advanced vector extension 2 bmi1, // Bit manipulation instruction set 1 bmi2, // Bit manipulation instruction set 2 erms, // Enhanced REP for MOVSB and STOSB fma, // Fused-multiply-add instructions os_xsave, // OS supports XSAVE/XRESTOR for saving/restoring XMM registers. pclmulqdq, // PCLMULQDQ instruction - most often used for AES-GCM popcnt, // Hamming weight instruction POPCNT. rdrand, // RDRAND instruction (on-chip random number generator) rdseed, // RDSEED instruction (on-chip random number generator) sha, // SHA Extensions (SHA-1, SHA-224, SHA-256) sse2, // Streaming SIMD extension 2 (always available on amd64) sse3, // Streaming SIMD extension 3 ssse3, // Supplemental streaming SIMD extension 3 sse41, // Streaming SIMD extension 4 and 4.1 sse42, // Streaming SIMD extension 4 and 4.2 avx512bf16, // Vector Neural Network Instructions supporting bfloat16 avx512bitalg, // Bit Algorithms avx512bw, // Byte and Word instructions avx512cd, // Conflict Detection instructions avx512dq, // Doubleword and Quadword instructions avx512er, // Exponential and Reciprocal instructions avx512f, // Foundation avx512fp16, // Vector 16-bit float instructions avx512ifma, // Integer Fused Multiply Add avx512pf, // Prefetch instructions avx512vbmi, // Vector Byte Manipulation Instructions avx512vbmi2, // Vector Byte Manipulation Instructions 2 avx512vl, // Vector Length extensions avx512vnni, // Vector Neural Network Instructions avx512vp2intersect, // Vector Pair Intersection to a Pair of Mask Registers avx512vpopcntdq, // Vector Population Count for Doubleword and Quadword }
GPU ¶
Related Procedures With Returns
GPU_Iterator ¶
GPU_Iterator :: struct { // Public iterator index index: int, // Internal buffer + index _buffer: [512]u8, _index: int, }
Related Procedures With Parameters
OS_Version ¶
OS_Version :: struct { platform: OS_Version_Platform, // Windows, Linux, MacOS, iOS, etc. full: string, // e.g. Windows 10 Professional (version: 22H2), build: 19045.6575 release: string, // e.g. 22H2 os: Version, // e.g. {major = 10, minor = 10, patch = 0} kernel: Version, }
Related Procedures With Parameters
Related Procedures With Returns
OS_Version_Platform ¶
OS_Version_Platform :: enum int { Unknown, Windows, Linux, MacOS, iOS, FreeBSD, OpenBSD, NetBSD, }
Constants
This section is empty.
Variables
This section is empty.
Procedures
cpu_core_count ¶
Retrieves the number of physical and logical CPU cores
Returns:
physical: The number of physical cores
logical: The number of logical cores
ok: true when we could retrieve the CPU information, false otherwise
cpu_features ¶
cpu_features :: proc "contextless" () -> (features: CPU_Features) {…}
Returns CPU features where available
The results are looked up before main enters and cached
Returns:
features: An architecture-specific bit_set, empty if we couldn't retrieve them
cpu_name ¶
cpu_name :: proc() -> (name: string) {…}
Returns the CPU's name
The results are looked up before main enters and cached
Returns:
name: A string containing the CPU model name, empty if the lookup failed
cpuid ¶
cpuid :: intrinsics.x86_cpuid
cpuid :: proc(ax, cx: u32) -> (eax, ebx, ecx, edx: u32) {…}
cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) ---
destroy_os_version ¶
destroy_os_version :: proc(version: OS_Version, allocator: runtime.Allocator) {…}
Releases an OS_Version's strings
Frees Using Provided Allocator
Inputs:
version: An OS_Version struct
allocator: A runtime.Allocator on which the version strings will be freed
iterate_gpus ¶
iterate_gpus :: proc(it: ^GPU_Iterator, minimum_vram: i64 = i64(256 * 1024 * 1024)) -> (gpu: GPU, index: int, ok: bool) {…}
Iterates over GPU adapters
On Windows: Enumerates Computer\HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}
Elsewhere: Unsupported at the moment, returns {}, 0, false
Important: The vendor name, model name and driver version strings are backed by the GPU_Iterator.
Clone them if you want to these to persist.
Inputs:
it: A pointer to a GPU_Iterator
minimum_vram: The number of bytes of VRAM an adapter has to have to be considered, default 256 MiB
(This excludes most screen mirroring / remote desktop drivers)
Returns:
gpu: A `GPU` struct which contains `vendor` name, `model` name, `driver` version and `vram` in bytes index: Loop index, optional ok: `true` if this was a success and we should continue, `false` otherwise
os_version ¶
os_version :: proc(allocator: runtime.Allocator, loc := #caller_location) -> (res: OS_Version, ok: bool) {…}
Retrieves OS version information
Allocates Using Provided Allocator
You can use destroy_os_version to free the results
Inputs:
allocator: A runtime.Allocator on which the version strings will be allocated
loc: The caller location
Returns:
res: An OS_Version struct
ok: true when we could retrieve OS version information, false otherwise
ram_stats ¶
ram_stats :: proc "contextless" () -> (total_ram, free_ram, total_swap, free_swap: i64, ok: bool) {…}
Retrieves RAM statistics
Unavailable stats will be returned as 0 bytes
Returns:
total_ram: Total RAM reported by the operating system, in bytes
free_ram: Free RAM reported by the operating system, in bytes
total_swap: Total SWAP reported by the operating system, in bytes
free_swap: Free SWAP reported by the operating system, in bytes
ok: true when we could retrieve RAM statistics, false otherwise
xgetbv ¶
xgetbv :: intrinsics.x86_xgetbv
xgetbv :: proc(cx: u32) -> (eax, edx: u32) {…}
xgetbv :: proc(cx: u32) -> (eax, edx: u32) ---
Procedure Groups
This section is empty.
Source Files
- cpu_intel.odin
- doc.odin
- sysinfo.odin
- (hidden platform specific files)
Generation Information
Generated with odin version dev-2026-02 (vendor "odin") Windows_amd64 @ 2026-02-28 21:12:57.577960200 +0000 UTC