package core:sys/info

Warning: This was generated for -target:windows_amd64 and might not represent every target this package supports.

⌘K
Ctrl+K
or
/

    Overview

    Package core:sys/info 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)
    	fmt.printfln("OS:    %v",    si.os_version.as_string)
    	fmt.printfln("OS:    %#v",   si.os_version)
    	fmt.printfln("CPU:   %v",    si.cpu_name)
    	fmt.printfln("RAM:   %#.1M", si.ram.total_ram)
    
    	// fmt.printfln("Features: %v",      si.cpu_features)
    	// fmt.printfln("MacOS version: %v", si.macos_version)
    
    	fmt.println()
    	for gpu, i in si.gpus {
    		fmt.printfln("GPU #%v:", i)
    		fmt.printfln("\tVendor: %v",    gpu.vendor_name)
    		fmt.printfln("\tModel:  %v",    gpu.model_name)
    		fmt.printfln("\tVRAM:   %#.1M", gpu.total_ram)
    	}
    }
    

    Example Windows output:

    Odin:  dev-2022-09
    OS:    Windows 10 Professional (version: 20H2), build: 19042.1466
    OS:    OS_Version{
    	platform = "Windows",
    	major = 10,
    	minor = 0,
    	patch = 0,
    	build = [
    		19042,
    		1466,
    	],
    	version = "20H2",
    	as_string = "Windows 10 Professional (version: 20H2), build: 19042.1466",
    }
    CPU:   AMD Ryzen 7 1800X Eight-Core Processor
    RAM:   64.0 GiB
    GPU #0:
    	Vendor: Advanced Micro Devices, Inc.
    	Model:  Radeon RX Vega
    	VRAM:   8.0 GiB
    
    

    Example macOS output:

    ODIN: dev-2022-09
    OS:   OS_Version{
    		platform = "MacOS",
    		major = 21,
    		minor = 5,
    		patch = 0,
    		build = [
    				0,
    				0,
    		],
    		version = "21F79",
    		as_string = "macOS Monterey 12.4 (build 21F79, kernel 21.5.0)",
    }
    CPU:  Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    RAM:  8.0 GiB
    

    Index

    Constants (0)

    This section is empty.

    Procedures (2)
    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)
    	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
    }

    CPU_Features ¶

    CPU_Features :: distinct bit_set[CPU_Feature; u64]

    GPU ¶

    GPU :: struct {
    	vendor_name: string,
    	model_name:  string,
    	total_ram:   int,
    }

    OS_Version ¶

    OS_Version :: struct {
    	platform:  OS_Version_Platform,
    	using _:   Version,
    	build:     [2]int,
    	version:   string,
    	as_string: string,
    }

    OS_Version_Platform ¶

    OS_Version_Platform :: enum int {
    	Unknown, 
    	Windows, 
    	Linux, 
    	MacOS, 
    	iOS, 
    	FreeBSD, 
    	OpenBSD, 
    	NetBSD, 
    }

    RAM ¶

    RAM :: struct {
    	total_ram:  int,
    	free_ram:   int,
    	total_swap: int,
    	free_swap:  int,
    }

    Version ¶

    Version :: struct {
    	major: int,
    	minor: int,
    	patch: int,
    }

    Constants

    This section is empty.

    Variables

    cpu_features ¶

    cpu_features: runtime.Maybe($T=CPU_Features)

    cpu_name ¶

    cpu_name: runtime.Maybe($T=string)

    macos_version ¶

    macos_version: Version
     

    Only on MacOS, contains the actual MacOS version, while the os_version contains the kernel version.

    Procedures

    cpuid ¶

    cpuid :: intrinsics.x86_cpuid
     

    cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) ---

    xgetbv ¶

    xgetbv :: intrinsics.x86_xgetbv
     

    xgetbv :: proc(cx: u32) -> (eax, edx: u32) ---

    Procedure Groups

    This section is empty.

    Source Files

    Generation Information

    Generated with odin version dev-2024-12 (vendor "odin") Windows_amd64 @ 2024-12-17 21:11:01.316695400 +0000 UTC