aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Common/Extensions/BinaryReaderExtensions.cs
blob: 21da6fc01299fbe6413009ea24698bfb83efd66a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace Ryujinx.Common
{
    public static class BinaryReaderExtensions
    {
        public unsafe static T ReadStruct<T>(this BinaryReader reader)
            where T : unmanaged
        {
            return MemoryMarshal.Cast<byte, T>(reader.ReadBytes(Unsafe.SizeOf<T>()))[0];
        }
    }
}