diff --git a/FEXCore/Source/CMakeLists.txt b/FEXCore/Source/CMakeLists.txt index c3a4bf8eb..d8f97a603 100644 --- a/FEXCore/Source/CMakeLists.txt +++ b/FEXCore/Source/CMakeLists.txt @@ -4,7 +4,6 @@ set (MAN_DIR share/man CACHE PATH "MAN_DIR") set (FEXCORE_BASE_SRCS Interface/Config/Config.cpp Utils/Allocator.cpp - Utils/CPUInfo.cpp Utils/FileLoading.cpp Utils/ForcedAssert.cpp Utils/LogManager.cpp diff --git a/FEXCore/Source/Interface/Config/Config.cpp b/FEXCore/Source/Interface/Config/Config.cpp index 6755bb8ae..e877672c5 100644 --- a/FEXCore/Source/Interface/Config/Config.cpp +++ b/FEXCore/Source/Interface/Config/Config.cpp @@ -4,7 +4,6 @@ #include #include -#include #include #include #include diff --git a/FEXCore/Source/Interface/Core/CPUID.cpp b/FEXCore/Source/Interface/Core/CPUID.cpp index 8628073e2..c3b724060 100644 --- a/FEXCore/Source/Interface/Core/CPUID.cpp +++ b/FEXCore/Source/Interface/Core/CPUID.cpp @@ -13,7 +13,6 @@ $end_info$ #include #include #include -#include #include #include #include diff --git a/Source/Common/CMakeLists.txt b/Source/Common/CMakeLists.txt index 7594295b0..ccf00a1a6 100644 --- a/Source/Common/CMakeLists.txt +++ b/Source/Common/CMakeLists.txt @@ -3,6 +3,7 @@ add_subdirectory(cpp-optparse/) set(NAME Common) set(SRCS Config.cpp + CPUInfo.cpp ArgumentLoader.cpp EnvironmentLoader.cpp HostFeatures.cpp diff --git a/FEXCore/Source/Utils/CPUInfo.cpp b/Source/Common/CPUInfo.cpp similarity index 93% rename from FEXCore/Source/Utils/CPUInfo.cpp rename to Source/Common/CPUInfo.cpp index 0c587656a..fe7faaefd 100644 --- a/FEXCore/Source/Utils/CPUInfo.cpp +++ b/Source/Common/CPUInfo.cpp @@ -12,7 +12,7 @@ #include #endif -namespace FEXCore::CPUInfo { +namespace FEX::CPUInfo { #ifndef _WIN32 uint32_t CalculateNumberOfCPUs() { constexpr auto parse_string = FMT_COMPILE("/sys/devices/system/cpu/cpu{}"); @@ -36,4 +36,4 @@ uint32_t CalculateNumberOfCPUs() { return std::thread::hardware_concurrency(); } #endif -} // namespace FEXCore::CPUInfo +} // namespace FEX::CPUInfo diff --git a/FEXCore/include/FEXCore/Utils/CPUInfo.h b/Source/Common/CPUInfo.h similarity index 67% rename from FEXCore/include/FEXCore/Utils/CPUInfo.h rename to Source/Common/CPUInfo.h index 99d48c3c7..9e56a7d1f 100644 --- a/FEXCore/include/FEXCore/Utils/CPUInfo.h +++ b/Source/Common/CPUInfo.h @@ -4,11 +4,11 @@ #include -namespace FEXCore::CPUInfo { +namespace FEX::CPUInfo { /** * @brief Calculate the number of CPUs in the system regardless of affinity mask. * * @return The number of CPUs in the system. */ -FEX_DEFAULT_VISIBILITY uint32_t CalculateNumberOfCPUs(); -} // namespace FEXCore::CPUInfo +uint32_t CalculateNumberOfCPUs(); +} // namespace FEX::CPUInfo diff --git a/Source/Common/HostFeatures.cpp b/Source/Common/HostFeatures.cpp index cd6c57a62..f94b8d714 100644 --- a/Source/Common/HostFeatures.cpp +++ b/Source/Common/HostFeatures.cpp @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT +#include "Common/CPUInfo.h" #include "Common/HostFeatures.h" #include #include -#include #include #include @@ -14,7 +14,7 @@ namespace FEX { void FillMIDRInformationViaLinux(FEXCore::HostFeatures* Features) { - auto Cores = FEXCore::CPUInfo::CalculateNumberOfCPUs(); + auto Cores = FEX::CPUInfo::CalculateNumberOfCPUs(); Features->CPUMIDRs.resize(Cores); #ifdef _M_ARM_64 for (size_t i = 0; i < Cores; ++i) { diff --git a/Source/Tools/FEXLoader/AOT/AOTGenerator.cpp b/Source/Tools/FEXLoader/AOT/AOTGenerator.cpp index aeddae3cf..7443fd4e3 100644 --- a/Source/Tools/FEXLoader/AOT/AOTGenerator.cpp +++ b/Source/Tools/FEXLoader/AOT/AOTGenerator.cpp @@ -1,9 +1,10 @@ // SPDX-License-Identifier: MIT +#include "Common/CPUInfo.h" + #include "ELFCodeLoader.h" #include "Linux/Utils/ELFContainer.h" #include -#include #include #include #include @@ -103,7 +104,7 @@ void AOTGenSection(FEXCore::Context::Context* CTX, ELFCodeLoader::LoadedSection& // This code is tricky to refactor so it doesn't allocate memory through glibc. FEXCore::Allocator::YesIKnowImNotSupposedToUseTheGlibcAllocator glibc; - for (int i = 0; i < FEXCore::CPUInfo::CalculateNumberOfCPUs(); i++) { + for (int i = 0; i < FEX::CPUInfo::CalculateNumberOfCPUs(); i++) { std::thread thd([&BranchTargets, CTX, &counter, &Compiled, &Section, &QueueMutex, SectionMaxAddress]() { // Set the priority of the thread so it doesn't overwhelm the system when running in the background setpriority(PRIO_PROCESS, FHU::Syscalls::gettid(), 19); diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp index ae3bc9d73..de1697b3d 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp @@ -8,6 +8,7 @@ $end_info$ #include "CodeLoader.h" +#include "Common/CPUInfo.h" #include "Common/FDUtils.h" #include "LinuxSyscalls/Syscalls.h" #include "LinuxSyscalls/EmulatedFiles/EmulatedFiles.h" @@ -15,7 +16,6 @@ $end_info$ #include #include #include -#include #include #include #include @@ -490,7 +490,7 @@ fextl::string GenerateCPUInfo(FEXCore::Context::Context* ctx, uint32_t CPUCores) EmulatedFDManager::EmulatedFDManager(FEXCore::Context::Context* ctx) : CTX {ctx} - , ThreadsConfig {FEXCore::CPUInfo::CalculateNumberOfCPUs()} { + , ThreadsConfig {FEX::CPUInfo::CalculateNumberOfCPUs()} { FDReadCreators["/proc/cpuinfo"] = [&](FEXCore::Context::Context* ctx, int32_t fd, const char* pathname, int32_t flags, mode_t mode) -> int32_t { // Only allow a single thread to initialize the cpu_info. // Jit in-case multiple threads try to initialize at once. diff --git a/Source/Windows/Common/CPUFeatures.cpp b/Source/Windows/Common/CPUFeatures.cpp index dd14099e9..88d2babc7 100644 --- a/Source/Windows/Common/CPUFeatures.cpp +++ b/Source/Windows/Common/CPUFeatures.cpp @@ -1,8 +1,9 @@ // SPDX-License-Identifier: MIT +#include "Common/CPUInfo.h" + #include #include -#include #include #include diff --git a/docs/ProgrammingConcerns.md b/docs/ProgrammingConcerns.md index 5e8d8d672..2c073ae08 100644 --- a/docs/ProgrammingConcerns.md +++ b/docs/ProgrammingConcerns.md @@ -26,7 +26,7 @@ Most C++ APIs allow you to replace their allocators, but some don't and we need running might run out of memory. This isn't an all encompassing list and we will add to it as our CI captures more problems. ### `get_nprocs_conf` -Use `FEXCore::CPUInfo::CalculateNumberOfCPUs` instead. +Use `FEX::CPUInfo::CalculateNumberOfCPUs` instead. ### `getcwd` Don't use getcwd with a nullptr buffer. It will allocate memory behind our back and return a pointer that needs a free.