KDK_CPU_GET_VIRT(3)

📦 version 3.0.1.4, in arch rolling, ubuntu resolute, ubuntu stonking

💖 KDK_CPU_GET_VIRT(3) — the "does my CPU do virtualization tho" page 💖

okay bestie, welcome to KDK_CPU_GET_VIRT(3), straight out of the Library Functions Manual ✨ this is a libkycpu situation and it is literally so simple you're gonna scream.


🌸 NAME 🌸

kdk_cpu_get_virt — 获取CPU对虚拟化的支持

(translation for the girlies: it gets you the CPU's virtualization support 🧚 like, does this chip do the thing or not)


✨ SYNOPSIS ✨

#include <libkycpu.h>

extern const char* kdk_cpu_get_virt();

Link with -lkyhw.

no cap, you HAVE to link with -lkyhw or the linker will simply not know her 💀

🦋 Detailed Description 🦋

The main function of the interface is to obtain CPU support for virtualization.

that's it. that's the whole vibe. one job, one function, main character energy 👑


💅 RETURN VALUE 💅

  • If the CPU supports virtualization, it returns the virtualization technology, like "vmx" 🔥
  • If it's not supported, it returns NULL 😭 (she said no)
  • The return type is const char*
DO NOT free IT. 🚨 the return is const char* and it is NOT yours to free, so put the free() down bestie, walk away, we don't do that here 🫶

🎀 EXAMPLES 🎀

here's the whole little demo, iconic behavior:

#include "libkycpu.h"
#include <stdio.h>

int main()
{
    printf("架构:%s\n", kdk_cpu_get_arch());
    printf("生产厂商:%s\n", kdk_cpu_get_vendor());
    printf("CPU 型号:%s\n", kdk_cpu_get_model());
    printf("CPU 主频:%s MHz\n", kdk_cpu_get_freq_MHz());
    printf("CPU 单核核心数量:%u\n", kdk_cpu_get_corenums());
    printf("CPU 虚拟化支持:%s\n", kdk_cpu_get_virt());
    printf("CPU 线程数:%u\n", kdk_cpu_get_process());
    return 0;
}

like look at her go, printing every single CPU fact she can find 🌈


📜 CONFORMING TO 📜

These functions are as per the withdrawn POSIX.1e draft specification.

The following functions are Linux extensions: kdk_cpu_get_arch(), kdk_cpu_get_model(), kdk_cpu_get_freq_MHz(), kdk_cpu_get_corenums(), kdk_cpu_get_vendor() and kdk_cpu_get_process().

lowkey important: POSIX.1e draft is withdrawn, and those six functions up there are Linux extensions, not POSIX. periodt 💅

👀 SEE ALSO 👀

go read those too, the whole squad is serving 🌟


sign-off besties 💜 this one came from the Linux Programmer's Manual, dated Thu Aug 24 2023 — so yes, she's been iconic since 2023 and she's still not freeing that const char* 🎀✨ bye love u, go virtualize something 🦋

📦 where this page comes from