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 called check_cpu() β€” which, btw, is automatically called by allegro_init(). so like… if you haven't inited Allegro yet, don't come for her. πŸ™ˆ

πŸ’œ SEE ALSO πŸ’œ


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 πŸ‘‘βœ¨πŸ¦‹πŸŒΈ