Compare commits

...

2 Commits

Author SHA1 Message Date
Evan Husted
4171913baf misc: One additional usage of Lock & comment why it's not used on the others. 2024-12-21 17:05:55 -06:00
Evan Husted
5b36a9cf9f chore: small cleanups 2024-12-21 17:05:55 -06:00
10 changed files with 22 additions and 15 deletions

View File

@@ -115,6 +115,9 @@ namespace Ryujinx.Cpu.Jit.HostTracked
} }
private readonly AddressIntrusiveRedBlackTree<Mapping> _mappingTree; private readonly AddressIntrusiveRedBlackTree<Mapping> _mappingTree;
// type is not Lock due to the unique usage of this mechanism,
// an arbitrary object is used as the lock passed in by constructor.
private readonly object _lock; private readonly object _lock;
public Block(MemoryTracking tracking, Func<ulong, ulong> readPtCallback, MemoryBlock memory, ulong size, object locker) : base(memory, size) public Block(MemoryTracking tracking, Func<ulong, ulong> readPtCallback, MemoryBlock memory, ulong size, object locker) : base(memory, size)
@@ -174,6 +177,9 @@ namespace Ryujinx.Cpu.Jit.HostTracked
private readonly MemoryTracking _tracking; private readonly MemoryTracking _tracking;
private readonly Func<ulong, ulong> _readPtCallback; private readonly Func<ulong, ulong> _readPtCallback;
// type is not Lock due to the unique usage of this mechanism,
// an arbitrary object is used as the lock passed in by constructor.
private readonly object _lock; private readonly object _lock;
public AddressSpacePartitionAllocator( public AddressSpacePartitionAllocator(

View File

@@ -15,7 +15,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Common
private readonly long[] _current2; private readonly long[] _current2;
private readonly long[] _peak; private readonly long[] _peak;
private readonly object _lock = new(); private readonly Lock _lock = new();
private readonly LinkedList<KThread> _waitingThreads; private readonly LinkedList<KThread> _waitingThreads;

View File

@@ -5,10 +5,10 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
class KCriticalSection class KCriticalSection
{ {
private readonly KernelContext _context; private readonly KernelContext _context;
private readonly object _lock = new();
private int _recursionCount; private int _recursionCount;
public object Lock => _lock; // type is not Lock due to Monitor class usage
public object Lock { get; } = new();
public KCriticalSection(KernelContext context) public KCriticalSection(KernelContext context)
{ {
@@ -17,7 +17,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
public void Enter() public void Enter()
{ {
Monitor.Enter(_lock); Monitor.Enter(Lock);
_recursionCount++; _recursionCount++;
} }
@@ -33,7 +33,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
{ {
ulong scheduledCoresMask = KScheduler.SelectThreads(_context); ulong scheduledCoresMask = KScheduler.SelectThreads(_context);
Monitor.Exit(_lock); Monitor.Exit(Lock);
KThread currentThread = KernelStatic.GetCurrentThread(); KThread currentThread = KernelStatic.GetCurrentThread();
bool isCurrentThreadSchedulable = currentThread != null && currentThread.IsSchedulable; bool isCurrentThreadSchedulable = currentThread != null && currentThread.IsSchedulable;
@@ -56,7 +56,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
} }
else else
{ {
Monitor.Exit(_lock); Monitor.Exit(Lock);
} }
} }
} }

View File

@@ -333,7 +333,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
return Path.Combine(AppDataManager.KeysDirPath, "key_retail.bin"); return Path.Combine(AppDataManager.KeysDirPath, "key_retail.bin");
} }
public static bool HasKeyRetailBinPath => File.Exists(GetKeyRetailBinPath()); public static bool HasAmiiboKeyFile => File.Exists(GetKeyRetailBinPath());
public static DateTime DateTimeFromTag(ushort value) public static DateTime DateTimeFromTag(ushort value)

View File

@@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
private byte[] DeriveKey(AmiiboMasterKey key, bool deriveAes, out byte[] derivedAesKey, out byte[] derivedAesIv) private byte[] DeriveKey(AmiiboMasterKey key, bool deriveAes, out byte[] derivedAesKey, out byte[] derivedAesIv)
{ {
List<byte> seed = new List<byte>(); List<byte> seed = [];
// Start with the type string (14 bytes) // Start with the type string (14 bytes)
seed.AddRange(key.TypeString); seed.AddRange(key.TypeString);

View File

@@ -33,10 +33,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption
byte[] dataBin = combinedBin.Take(80).ToArray(); byte[] dataBin = combinedBin.Take(80).ToArray();
byte[] tagBin = combinedBin.Skip(80).Take(80).ToArray(); byte[] tagBin = combinedBin.Skip(80).Take(80).ToArray();
AmiiboMasterKey dataKey = new AmiiboMasterKey(dataBin); return (new AmiiboMasterKey(dataBin), new AmiiboMasterKey(tagBin));
AmiiboMasterKey tagKey = new AmiiboMasterKey(tagBin);
return (dataKey, tagKey);
} }
} }
} }

View File

@@ -10,6 +10,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
private ulong _value; private ulong _value;
private readonly EventFdFlags _flags; private readonly EventFdFlags _flags;
// type is not Lock due to Monitor class usage
private readonly object _lock = new(); private readonly object _lock = new();
public bool Blocking { get => !_flags.HasFlag(EventFdFlags.NonBlocking); set => throw new NotSupportedException(); } public bool Blocking { get => !_flags.HasFlag(EventFdFlags.NonBlocking); set => throw new NotSupportedException(); }

View File

@@ -1,3 +1,4 @@
using Gommon;
using Ryujinx.Common.Logging; using Ryujinx.Common.Logging;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
@@ -34,6 +35,8 @@ namespace Ryujinx.UI.Common.Helper
} }
} }
public static void OpenFolder(FilePath path) => OpenFolder(path.Path);
public static void LocateFile(string path) public static void LocateFile(string path)
{ {
if (File.Exists(path)) if (File.Exists(path))

View File

@@ -334,7 +334,7 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
} }
public bool CanScanAmiiboBinaries => AmiiboBinReader.HasKeyRetailBinPath; public bool CanScanAmiiboBinaries => AmiiboBinReader.HasAmiiboKeyFile;
public bool ShowLoadProgress public bool ShowLoadProgress
{ {

View File

@@ -178,7 +178,7 @@ namespace Ryujinx.Ava.UI.Views.Main
private void ScanBinAmiiboMenuItem_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e) private void ScanBinAmiiboMenuItem_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)
{ {
if (sender is MenuItem) if (sender is MenuItem)
ViewModel.IsAmiiboBinRequested = ViewModel.IsAmiiboRequested && AmiiboBinReader.HasKeyRetailBinPath; ViewModel.IsAmiiboBinRequested = ViewModel.IsAmiiboRequested && AmiiboBinReader.HasAmiiboKeyFile;
} }
private async void InstallFileTypes_Click(object sender, RoutedEventArgs e) private async void InstallFileTypes_Click(object sender, RoutedEventArgs e)