aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Kernel/Process/CapabilityExtensions.cs
blob: 66d56fe31bb53376449111b0d8c0bdcd28ae66c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Numerics;

namespace Ryujinx.HLE.HOS.Kernel.Process
{
    static class CapabilityExtensions
    {
        public static CapabilityType GetCapabilityType(this uint cap)
        {
            return (CapabilityType)(((cap + 1) & ~cap) - 1);
        }

        public static uint GetFlag(this CapabilityType type)
        {
            return (uint)type + 1;
        }

        public static uint GetId(this CapabilityType type)
        {
            return (uint)BitOperations.TrailingZeroCount(type.GetFlag());
        }
    }
}