[all] refactor cpuInfo function names

This commit is contained in:
Geoffrey McRae 2023-11-19 01:22:09 +11:00
parent 750cab83a3
commit 5d4c1d348c
6 changed files with 11 additions and 10 deletions

View File

@ -1632,7 +1632,7 @@ restart:
int procs; int procs;
int cores; int cores;
int sockets; int sockets;
if (lgCPUInfo(model, sizeof model, &procs, &cores, &sockets) && if (cpuInfo_get(model, sizeof model, &procs, &cores, &sockets) &&
procs > cores) procs > cores)
hostHasSMP = true; hostHasSMP = true;
@ -1858,7 +1858,7 @@ int main(int argc, char * argv[])
DEBUG_INFO("Looking Glass (%s)", BUILD_VERSION); DEBUG_INFO("Looking Glass (%s)", BUILD_VERSION);
DEBUG_INFO("Locking Method: " LG_LOCK_MODE); DEBUG_INFO("Locking Method: " LG_LOCK_MODE);
lgDebugCPU(); cpuInfo_log();
if (!installCrashHandler("/proc/self/exe")) if (!installCrashHandler("/proc/self/exe"))
DEBUG_WARN("Failed to install the crash handler"); DEBUG_WARN("Failed to install the crash handler");

View File

@ -24,8 +24,9 @@
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores, bool cpuInfo_get(char * model, size_t modelSize, int * procs, int * cores,
int * sockets); int * sockets);
void lgDebugCPU(void);
void cpuInfo_log(void);
#endif #endif

View File

@ -21,14 +21,14 @@
#include "common/cpuinfo.h" #include "common/cpuinfo.h"
#include "common/debug.h" #include "common/debug.h"
void lgDebugCPU(void) void cpuInfo_log(void)
{ {
char model[1024]; char model[1024];
int procs; int procs;
int cores; int cores;
int sockets; int sockets;
if (!lgCPUInfo(model, sizeof model, &procs, &cores, &sockets)) if (!cpuInfo_get(model, sizeof model, &procs, &cores, &sockets))
{ {
DEBUG_WARN("Failed to get CPU information"); DEBUG_WARN("Failed to get CPU information");
return; return;

View File

@ -27,7 +27,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores, bool cpuInfo_get(char * model, size_t modelSize, int * procs, int * cores,
int * sockets) int * sockets)
{ {
FILE * cpuinfo = fopen("/proc/cpuinfo", "r"); FILE * cpuinfo = fopen("/proc/cpuinfo", "r");

View File

@ -108,7 +108,7 @@ static bool getCoreCount(int * cores, int * procs, int * sockets)
return true; return true;
} }
bool lgCPUInfo(char * model, size_t modelSize, int * procs, int * cores, bool cpuInfo_get(char * model, size_t modelSize, int * procs, int * cores,
int * sockets) int * sockets)
{ {
return getCPUModel(model, modelSize) && getCoreCount(cores, procs, sockets); return getCPUModel(model, modelSize) && getCoreCount(cores, procs, sockets);

View File

@ -618,7 +618,7 @@ static bool newKVMFRData(KVMFRUserData * dst)
{ {
int cpus, cores, sockets; int cpus, cores, sockets;
char model[1024]; char model[1024];
if (!lgCPUInfo(model, sizeof(model), &cpus, &cores, &sockets)) if (!cpuInfo_get(model, sizeof(model), &cpus, &cores, &sockets))
return false; return false;
KVMFRRecord_VMInfo vmInfo = KVMFRRecord_VMInfo vmInfo =
@ -807,7 +807,7 @@ int app_main(int argc, char * argv[])
return LG_HOST_EXIT_FATAL; return LG_HOST_EXIT_FATAL;
DEBUG_INFO("Looking Glass Host (%s)", BUILD_VERSION); DEBUG_INFO("Looking Glass Host (%s)", BUILD_VERSION);
lgDebugCPU(); cpuInfo_log();
struct IVSHMEM shmDev = { 0 }; struct IVSHMEM shmDev = { 0 };
if (!ivshmemInit(&shmDev)) if (!ivshmemInit(&shmDev))