Final Platform Layer  0.9.6-beta
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
Note
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);

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);

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

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.
}
}
fplCPUGetArchitecture
fpl_platform_api fplCPUArchType fplCPUGetArchitecture()
Gets the processor architecture type.
fplMemoryInfos
A structure that contains informations about current memory usage.
Definition: final_platform_layer.h:3078
fplCPUGetName
fpl_common_api size_t fplCPUGetName(char *destBuffer, const size_t maxDestBufferLen)
Retrieves the name of the processor.
fplCPUGetCoreCount
fpl_platform_api size_t fplCPUGetCoreCount()
Retrieves the total number of processor cores.
fplCPUCapabilities::hasSSE2
fpl_b32 hasSSE2
Is SSE-2 supported.
Definition: final_platform_layer.h:3276
fplMemoryGetInfos
fpl_platform_api bool fplMemoryGetInfos(fplMemoryInfos *outInfos)
Retrieves the current system memory usage.
fplCPUArchType
fplCPUArchType
An enumeration of architecture types.
Definition: final_platform_layer.h:3249
fplCPUGetArchName
const fpl_common_api char * fplCPUGetArchName(const fplCPUArchType type)
Gets the string representation of the given architecture type.
fplArrayCount
#define fplArrayCount(arr)
Returns the element count from a static array. This should ideally produce a compile error when passi...
Definition: final_platform_layer.h:2254
fplMemoryInfos::totalPhysicalSize
uint64_t totalPhysicalSize
Total size of physical memory in bytes (May be less than size of installed physical memory,...
Definition: final_platform_layer.h:3082
fplCPUGetCapabilities
fpl_common_api bool fplCPUGetCapabilities(fplCPUCapabilities *outCaps)
Gets the capabilities of the processor.
fplZeroInit
#define fplZeroInit
Initializes a struct to zero.
Definition: final_platform_layer.h:2208
fplMemoryInfos::freePhysicalSize
uint64_t freePhysicalSize
Available physical memory in bytes.
Definition: final_platform_layer.h:3084
fplCPUCapabilities
A structure that containing the processor capabilities, like MMX,SSE,AVX etc.
Definition: final_platform_layer.h:3270
fplCPUArchType_Arm64
ARM64 architecture.
Definition: final_platform_layer.h:3261
fplConsoleFormatOut
fpl_common_api void fplConsoleFormatOut(const char *format,...)
Writes the given formatted text to the standard output console buffer.