mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-10 00:00:19 +02:00
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:
1 parent
0814780c2f
commit
2a82f58195
12 files changed
+139
-8
No files matched your search
@@ -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));
|
||||
Reference in new issue
Block a user