mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 15:00:17 +02:00
This was accidentally setting `CurrentSize` instead of just returning the newly allocated size to the frontend. This was causing the frontend to then fail to detect the reallocation actually occured and no longer get stats for new threads. Also happened to not use `NewSize` but instead `CurrentSize * 2` which didn't matter as it matched the growth pattern, but was technically incorrect. Fixes SHM stats since the introduction of the unixlib, ezpz.
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#include "Windows/Common/FEXUnixLib.h"
|
|
#include "Windows/Common/SHMStats.h"
|
|
|
|
#include <FEXCore/fextl/fmt.h>
|
|
#include <FEXCore/Utils/LogManager.h>
|
|
#include <FEXCore/Utils/TypeDefines.h>
|
|
|
|
#include <ntstatus.h>
|
|
#include <windef.h>
|
|
#include <winternl.h>
|
|
#include <winnt.h>
|
|
#include <wine/debug.h>
|
|
|
|
namespace FEX::Windows {
|
|
uint32_t StatAlloc::FrontendAllocateSlots(uint32_t NewSize) {
|
|
if (CurrentSize == MAX_STATS_SIZE) {
|
|
LogMan::Msg::DFmt("Ran out of slots. Can't allocate more");
|
|
return CurrentSize;
|
|
}
|
|
|
|
auto Result = UnixLib::AllocateSHMSlots(Base, std::min(NewSize, MAX_STATS_SIZE), MAX_STATS_SIZE);
|
|
|
|
// Return the new size allocated, if it happened to change.
|
|
return Result.MappedSize;
|
|
}
|
|
|
|
StatAlloc::StatAlloc(FEXCore::SHMStats::AppType AppType) {
|
|
auto Result = UnixLib::AllocateSHMSlots(Base, FEXCore::Utils::FEX_PAGE_SIZE, MAX_STATS_SIZE);
|
|
|
|
if (Result.SHMBase) {
|
|
CurrentSize = Result.MappedSize;
|
|
Base = Result.SHMBase;
|
|
SaveHeader(AppType);
|
|
return;
|
|
}
|
|
}
|
|
|
|
StatAlloc::~StatAlloc() {
|
|
UnixLib::DeleteSHMStatsFile();
|
|
}
|
|
|
|
} // namespace FEX::Windows
|