2022-01-26 04:22:12 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: CpuId.BSD.cpp
|
|
|
|
Date: 2022-1-25
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#include <Source/RuntimeInternal.hpp>
|
|
|
|
#include "HWInfo.hpp"
|
|
|
|
#include "CpuInfo.hpp"
|
|
|
|
#include "CpuInfo.BSD.hpp"
|
|
|
|
|
|
|
|
#if defined(AURORA_IS_BSD_DERIVED)
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/sysinfo.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace Aurora::HWInfo
|
|
|
|
{
|
|
|
|
void SetCpuTopologyBSD()
|
|
|
|
{
|
|
|
|
auto opt = QueryBsdHwStat(HW_AVAILCPU);
|
|
|
|
if (opt.value_or(0) < 1)
|
|
|
|
{
|
|
|
|
opt = QueryBsdHwStat(HW_NCPU);
|
|
|
|
}
|
|
|
|
|
2022-02-18 10:46:51 +00:00
|
|
|
gCpuInfo.uSocket = 1;
|
|
|
|
gCpuInfo.uCores = 1;
|
|
|
|
gCpuInfo.uThreads = opt.value_or(1);
|
2022-01-26 04:22:12 +00:00
|
|
|
|
|
|
|
// TODO: parse sysctl kern.sched.topology_spec
|
2022-02-18 10:46:51 +00:00
|
|
|
gCpuInfo.bMaskMTHalf = true;
|
2022-01-26 04:22:12 +00:00
|
|
|
}
|
|
|
|
}
|