Final Platform Layer 0.9.8-beta
No Matches
Query Hardware information

FPL provides a couple of functions for getting hardware functions, such as CPU & memory Infos, etc.

Get number of CPU-Cores

You can retrieve the number of processor cores by calling fplCPUGetCoreCount() .

size_t coreCount = fplCPUGetCoreCount();
// Do something with the core count
fpl_platform_api size_t fplCPUGetCoreCount()
Retrieves the total number of processor cores.
Hyperthreads will be included as well, so on a typical 4-core HT CPU, this function will return eight cores.

Get CPU architecture

You can query the CPU architecture type by calling fplCPUGetArchitecture() . This will return a fplCPUArchType value, which you can use test for different architecture types.

Use fplCPUGetArchName() to convert a fplCPUArchType into a string.

if (cpuArch == fplCPUArchType_Arm64) {
// Do something on a ARM-64 CPU
// or just print it out
const char *cpuArchString = fplCPUGetArchName(cpuArch);
fplConsoleFormatOut("CPU Architecture: %s\n", cpuArchString);
fpl_common_api void fplConsoleFormatOut(const char *format,...)
Writes the given formatted text to the standard output console buffer.
fpl_common_api const char * fplCPUGetArchName(const fplCPUArchType type)
Gets the string representation of the given architecture type.
An enumeration of architecture types.
fpl_platform_api fplCPUArchType fplCPUGetArchitecture()
Gets the processor architecture type.
@ fplCPUArchType_Arm64
ARM64 architecture.

Get the CPU Name

You can query the CPU name by calling fplCPUGetName() .

// Print out the CPU-Name
char nameBuffer[1024];
fplCPUGetName(nameBuffer, fplArrayCount(nameBuffer));
fplConsoleFormatOut("CPU Name: %s\n", nameBuffer);
fpl_common_api size_t fplCPUGetName(char *destBuffer, const size_t maxDestBufferLen)
Retrieves the name of the processor.
#define fplArrayCount(arr)
Returns the element count from a static array. This should ideally produce a compile error when passi...

Query memory state

With fplMemoryGetInfos() you can query the current memory state.
This includes the size of the physical memory, the current memory usage, and more.
See fplMemoryInfos for more details.

if (fplMemoryGetInfos(&memInfos)) {
fplConsoleFormatOut("%llu of %llu physical memory is available.\n", memInfos.freePhysicalSize, memInfos.totalPhysicalSize);
#define fplZeroInit
Initializes a struct to zero.
fpl_platform_api bool fplMemoryGetInfos(fplMemoryInfos *outInfos)
Retrieves the current system memory usage.
A structure that contains informations about current memory usage.
uint64_t totalPhysicalSize
Total size of physical memory in bytes (May be less than size of installed physical memory,...
uint64_t freePhysicalSize
Available physical memory in bytes.

Query CPU Capabilities

Use the fplCPUGetCapabilities() to retrieve a full set of available processor capabilities, like MMX/SSE/AVX support, etc.

if (fplCPUGetCapabilities(&caps)) {
if (caps.x86.hasSSE2) {
// Do something when the x86 CPU supports SSE2 - this should be true, on most modern x86 CPUs.
fpl_common_api bool fplCPUGetCapabilities(fplCPUCapabilities *outCaps)
Gets the capabilities of the processor.
A structure that containing the processor capabilities, like MMX,SSE,AVX etc.
fpl_b32 hasSSE2
Is SSE-2 supported.