KDK_CPU_GET_CORENUMS(3)

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

💖 KDK_CPU_GET_CORENUMS(3) 💖

okay so bestie, welcome to the Library Functions Manual — this is the one about counting your CPU cores, and honestly? it's giving essential. let's go 🫶


✨ NAME ✨

kdk_cpu_get_corenums — 获取CPU核心数量 (aka: how many cores does this CPU even have, fr fr) 🧚


🌸 SYNOPSIS 🌸

#include <libkycpu.h>

extern unsigned int kdk_cpu_get_corenums()

Link with -lkyhw.

lowkey important: that -lkyhw is not optional, bestie. don't forget it or the linker will simply not know her 💅

👑 DESCRIPTION 👑

The main function of the interface is to obtain the number of CPU cores. that's it, that's the whole vibe — she counts cores and she does it well. main character energy tbh 💀✨


🎀 RETURN VALUE 🎀

  • On success — returns the number of all available CPU cores of type int. slay.
  • On error — return 0.
so if you get 0 back, that's not "zero cores," bestie, that's the error path. don't get it twisted 😭

🦋 EXAMPLES 🦋

here's the whole thing in action, copy-paste ready, no cap:

#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;
}

look at her go 🌈 notice how kdk_cpu_get_corenums() gets printed with %u — unsigned, periodt.


💜 CONFORMING TO 💜

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

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

"withdrawn" is doing a lot of heavy lifting there ngl — POSIX.1e never actually made it, but these functions are still out here living their truth 🫶

⭐ SEE ALSO ⭐

the whole friend group, all linked up 💖 go read them too, iykyk.


Linux Programmer's Manual — dated Thu Aug 24 2023 🎀 that's the version and the date bestie, that's the sign-off, mwah 💅✨

📦 where this page comes from