DiskCache: use memory-mapped IO for reads when possible

On Wine, use a unixlib call to get a quality mapping that can track a growing
file.
This commit is contained in:
Pierre-Loup A. Griffais committed 2026-08-27 21:15:22 -07:00
1 parent 0814780c2f
commit 2a82f58195
12 files changed
+139 -8

No files matched your search

+14
View File
@@ -163,6 +163,19 @@ static NTSTATUS FEXUnixLib_DeleteSHMStatsFileHandler(void* _Args) {
return STATUS_SUCCESS;
}
static NTSTATUS FEXUnixLib_MapFileHandler(void* _Args) {
auto Args = reinterpret_cast<FEXUnixLib_MapFile*>(_Args);
// could find a way to dedupe with DiskCacheFilemapper in FEXInterpreter but it's barely any code
// fd was already duped by Wine handle translation
Args->Result = mmap(nullptr, Args->MapSize, PROT_READ, MAP_SHARED | MAP_NORESERVE, Args->FD, 0);
close(Args->FD);
if (Args->Result == (void*)-1) {
Args->Result = nullptr;
return STATUS_INTERNAL_ERROR;
}
return STATUS_SUCCESS;
}
extern "C" const unixlib_entry_t __wine_unix_call_funcs[] = {
FEXUnixLib_SetHardwareTSOControlHandler,
FEXUnixLib_SetKernelUnalignedAtomicControlHandler,
@@ -170,6 +183,7 @@ extern "C" const unixlib_entry_t __wine_unix_call_funcs[] = {
FEXUnixLib_SetVMANameHandler,
FEXUnixLib_GetSHMStatsVMAHandler,
FEXUnixLib_DeleteSHMStatsFileHandler,
FEXUnixLib_MapFileHandler,
};
static_assert(sizeof(__wine_unix_call_funcs) / sizeof(__wine_unix_call_funcs[0]) == ToUnderlying(FEXUnixLibFunctions::MAX));