70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuCpuInfo.cpp
|
|
Date: 2021-6-12
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "AuHWInfo.hpp"
|
|
#include "AuCpuInfo.hpp"
|
|
#include "AuCpuId.hpp"
|
|
|
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
|
#include <stdlib.h>
|
|
#include <sys/sysinfo.h>
|
|
#endif
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
#include "AuCpuInfo.NT.hpp"
|
|
#endif
|
|
|
|
#if defined(AURORA_IS_BSD_DERIVED)
|
|
#include "AuCpuInfo.BSD.hpp"
|
|
#endif
|
|
|
|
#if defined(AURORA_IS_LINUX_DERIVED)
|
|
#include "AuCpuInfo.Linux.hpp"
|
|
#endif
|
|
|
|
namespace Aurora::HWInfo
|
|
{
|
|
static void SetCpuTopology()
|
|
{
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
SetCpuTopologyNT();
|
|
#elif defined(AURORA_IS_BSD_DERIVED)
|
|
SetCpuTopologyBSD();
|
|
#elif defined(AURORA_IS_LINUX_DERIVED)
|
|
SetCpuTopologyLinux();
|
|
#elif defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
gCpuInfo.uSocket = 1;
|
|
gCpuInfo.uCores = 1;
|
|
gCpuInfo.uThreads = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
#endif
|
|
}
|
|
|
|
static void SetFakeTopologyIfMissing()
|
|
{
|
|
// This stunk
|
|
}
|
|
|
|
void InitCpuInfo()
|
|
{
|
|
gCpuInfo.bMaskMTContig = false;
|
|
gCpuInfo.bMaskMTHalf = false;
|
|
gCpuInfo.cpuArch = Aurora::Build::kCurrentArchitecture;
|
|
SetCpuId();
|
|
SetCpuTopology();
|
|
SetFakeTopologyIfMissing();
|
|
}
|
|
|
|
|
|
AUKN_SYM const CpuInfo &GetCPUInfo()
|
|
{
|
|
return gCpuInfo;
|
|
}
|
|
}
|