memory: Add Android support

This commit is contained in:
Mary 2023-05-08 15:09:02 +02:00 committed by Emmanuel Hansen
parent c27a12df2c
commit 0b14eb3a61
4 changed files with 36 additions and 16 deletions

View file

@ -8,6 +8,7 @@ namespace Ryujinx.Memory
{
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("android")]
static class MemoryManagementUnix
{
private static readonly ConcurrentDictionary<IntPtr, ulong> _allocations = new();
@ -156,6 +157,22 @@ namespace Ryujinx.Memory
}
}
}
else if (OperatingSystem.IsAndroid())
{
byte[] memName = Encoding.ASCII.GetBytes("Ryujinx-XXXXXX");
fixed (byte* pMemName = memName)
{
fd = ASharedMemory_create((IntPtr)pMemName, (nuint)size);
if (fd <= 0)
{
throw new OutOfMemoryException();
}
}
// ASharedMemory_create handle ftruncate for us.
return (IntPtr)fd;
}
else
{
byte[] fileName = "/dev/shm/Ryujinx-XXXXXX"u8.ToArray();