/ src / Ryujinx.Common / Memory / PartialUnmaps / PartialUnmapHelpers.cs
PartialUnmapHelpers.cs
 1  using System.Runtime.CompilerServices;
 2  
 3  namespace Ryujinx.Common.Memory.PartialUnmaps
 4  {
 5      static class PartialUnmapHelpers
 6      {
 7          /// <summary>
 8          /// Calculates a byte offset of a given field within a struct.
 9          /// </summary>
10          /// <typeparam name="T">Struct type</typeparam>
11          /// <typeparam name="T2">Field type</typeparam>
12          /// <param name="storage">Parent struct</param>
13          /// <param name="target">Field</param>
14          /// <returns>The byte offset of the given field in the given struct</returns>
15          public static int OffsetOf<T, T2>(ref T2 storage, ref T target)
16          {
17              return (int)Unsafe.ByteOffset(ref Unsafe.As<T2, T>(ref storage), ref target);
18          }
19      }
20  }