cpu_capabilities(3alleg4)
π cpu_capabilities β the Allegro manual, but make it make sense β¨
okay bestie, welcome to Allegro β yes, the game programming library, the iconic one π. Today's main character is a little global variable called cpu_capabilities, and honestly? she's doing a LOT. let's get into it π
πΈ SYNOPSIS πΈ
#include <allegro.h>
extern int cpu_capabilities;
β¨ DESCRIPTION β¨
So cpu_capabilities holds CPU flags that tell you which features your current CPU actually has. and when I say "any combination", I mean it β these flags can mix and match however your silicon feels like it π¦:
CPU_IDβ says the"cpuid"instruction is available. and here's the tea: if this flag is set, then all Allegro CPU variables are 100% reliable. if it's NOT set? there may be some mistakes. πCPU_FPUβ an FPU is available.CPU_IA64β you're running on an Intel 64 bit CPU.CPU_AMD64β you're running on an AMD 64 bit CPU.CPU_MMXβ Intel MMX instruction set is available.CPU_MMXPLUSβ Intel MMX+ instruction set is available.CPU_SSEβ Intel SSE instruction set is available.CPU_SSE2β Intel SSE2 instruction set is available.CPU_SSE3β Intel SSE3 instruction set is available.CPU_3DNOWβ AMD 3DNow! instruction set is available.CPU_ENH3DNOWβ AMD Enhanced 3DNow! instruction set is available.CPU_CMOVβ Pentium Pro"cmov"instruction is available.
π§ checking for multiple things at once (the way thatβ¦ π)
you can vibe check several features at the same time by OR-ing the flags together. for example, wanna know if the CPU has both an FPU and MMX instructions? boom:
if ((cpu_capabilities & (CPU_FPU | CPU_MMX)) ==
(CPU_FPU | CPU_MMX)) {
printf("CPU has both an FPU and MMX instructions!\n");
}
periodt. that's it, that's the whole flex π
π«Ά when can I read this?? (important, bestie)
you can read this variable after you have calledcheck_cpu()β which, btw, is automatically called byallegro_init(). so likeβ¦ if you haven't inited Allegro yet, don't come for her. π
π SEE ALSO π
check_cpu(3alleg4)cpu_vendor(3alleg4)cpu_family(3alleg4)cpu_model(3alleg4)cpu_capabilities(3alleg4)allegro_init(3alleg4)
okay that's the whole page, no notes π this was the Allegro manual, version 4.4.3, and yeah β that's the whole vibe. go forth and detect some CPU features, you absolute icon πβ¨π¦πΈ
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms