KDK_CPU_GET_ARCH(3)

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

✨ KDK_CPU_GET_ARCH(3) — Library Functions Manual ✨

okay bestie, sit down, hydrate, and let me tell you about kdk_cpu_get_arch 💖 this lil guy lives in the Library Functions Manual and it is literally the most unbothered function you will ever meet.


🌸 NAME 🌸

kdk_cpu_get_arch — 获取CPU架构 💅

like. it gets your CPU architecture. that's the whole job. that's the assignment. and it ate. 🔥


🦋 SYNOPSIS 🦋

#include <libkycpu.h>

extern const char* kdk_cpu_get_arch();

Link with -lkyhw.

yes bestie, you gotta link with -lkyhw or it's giving undefined reference and you'll be crying in the terminal 😭

💜 DESCRIPTION 💜

So the main function of the interface is to obtain CPU architecture. That's it. That's the vibe. It pulls the arch for you and hands it over, no drama, no side quests, main character energy only 👑


🎀 RETURN VALUE 🎀

  • On success, it returns the CPU architecture of type char*, such as "x86_64" ✨
  • The return is const char*, so do not free it, bestie!! it is NOT yours to free, hands off 🙈
  • On error, it returns NULL.

🍓 EXAMPLES 🍓

here's the whole lil crew showing out together, copy-paste princess 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;
}

slay. compile it. run it. scream. 😭💖


🌈 CONFORMING TO 🌈

These functions are as per the withdrawn POSIX.1e draft specification. (withdrawn!! she's retired but she still shows up to the group chat 💀)

The following functions are Linux extensions:

  • kdk_cpu_get_vendor()
  • kdk_cpu_get_model()
  • kdk_cpu_get_freq_MHz()
  • kdk_cpu_get_corenums()
  • kdk_cpu_get_virt()
  • kdk_cpu_get_process()

👑 SEE ALSO 👑

go read those too, they're the rest of the friend group 🫶


and that's the page, bestie!! this one came from the Linux Programmer's Manual, dated Thu Aug 24 2023 — iconic date, iconic docs, we stan a classic 💅✨🧚

📦 where this page comes from