KDK_CPU_GET_CORENUMS(3)
💖 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 ⭐
kdk_cpu_get_vendor(3)kdk_cpu_get_model(3)kdk_cpu_get_freq_MHz(3)kdk_cpu_get_arch(3)kdk_cpu_get_virt(3)kdk_cpu_get_process(3)
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
- arch rolling: libkysdk-system 3.0.1.4-1 · LGPL-3.0-or-later AND LGPL-2.1-only OR LGPL-3.0-only AND LGPL-2.1-only WITH Qt-LGPL-exception-1.1 OR LGPL-3.0-only WITH Qt-LGPL-exception-1.1 AND MIT
- ubuntu resolute: libkysdk-system-dev 3.0.1.2-0ubuntu1 · LGPL-3.0-only
- ubuntu stonking: libkysdk-system-dev 3.0.1.3-0ubuntu1 · LGPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms