64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: CpuInfo.cpp
|
|
Date: 2021-6-12
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "HWInfo.hpp"
|
|
#include "CpuInfo.hpp"
|
|
#include "CpuId.hpp"
|
|
|
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
|
#include <stdlib.h>
|
|
#include <sys/sysinfo.h>
|
|
#endif
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
#include "CpuInfo.NT.hpp"
|
|
#endif
|
|
|
|
#if defined(AURORA_IS_BSD_DERIVED)
|
|
#include "CpuInfo.BSD.hpp"
|
|
#endif
|
|
|
|
#if defined(AURORA_IS_LINUX_DERIVED)
|
|
#include "CpuInfo.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();
|
|
}
|
|
}
|