sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use objc2_core_foundation::{CFData, CFString, kCFAllocatorDefault};
use objc2_io_kit::{IORegistryEntryCreateCFProperty, io_object_t};

pub(super) unsafe fn is_gpu(device: io_object_t, class_code_key: &CFString) -> bool {
    unsafe {
        if let Some(prop) =
            IORegistryEntryCreateCFProperty(device, Some(class_code_key), kCFAllocatorDefault, 0)
            && let Ok(prop_ref) = prop.downcast::<CFData>()
            // Standard PCI layout in Open Firmware maps the class code to bytes [1] and [2], or to a raw 32-bit integer where the high/mid bytes dictate the base class.
            && let [_, _, 0x03, ..] = prop_ref.as_bytes_unchecked()
        {
            true
        } else {
            false
        }
    }
}